Conflicts:
	.gitignore
This commit is contained in:
Light2
2013-12-14 21:42:46 +01:00
76 changed files with 10607 additions and 14 deletions
+1
View File
@@ -47,6 +47,7 @@ clientdata/
# SWG Client Folders
footprint/
interiorlayout/
clientdata/quest/
# External tool builders
.externalToolBuilders/
+1
View File
@@ -43,6 +43,7 @@ Then export the following folders to your clientdata folder(should be located in
- object
- quest
- snapshot
- string
- terrain
Export the same folders from sku1_client.toc, sku2_client.toc and sku3_client.toc to avoid errors with kashyyyk.
+1
View File
@@ -1 +1,2 @@
LOAD.SNAPSHOT_OBJECTS=1
LOAD.BUILDOUT_OBJECTS=1
+5 -5
View File
@@ -28,7 +28,7 @@ def run(core, actor, target, commandString):
waypoint.setPlanetCRC(crc.StringtoCRC(planet.getName()))
actorPlayer.getWaypoints().add(waypoint)
actorPlayer.waypointAdd(waypoint)
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
actor.sendSystemMessage('A waypoint has been created in your datapad at the location.', 0)
return
@@ -42,7 +42,7 @@ def run(core, actor, target, commandString):
waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName()))
actorPlayer.getWaypoints().add(waypoint)
actorPlayer.waypointAdd(waypoint)
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
actor.sendSystemMessage('A waypoint has been created in your datapad at the location.', 0)
return
#/wp X Z Name
elif len(commandArgs) >= 3 and isFloat(commandArgs[0]) and isFloat(commandArgs[1]):
@@ -54,7 +54,7 @@ def run(core, actor, target, commandString):
waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName()))
actorPlayer.getWaypoints().add(waypoint)
actorPlayer.waypointAdd(waypoint)
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
actor.sendSystemMessage('A waypoint has been created in your datapad at the location.', 0)
return
#/wp X Z
elif len(commandArgs) >= 2 and isFloat(commandArgs[0]) and isFloat(commandArgs[1]):
@@ -65,7 +65,7 @@ def run(core, actor, target, commandString):
waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName()))
actorPlayer.getWaypoints().add(waypoint)
actorPlayer.waypointAdd(waypoint)
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
actor.sendSystemMessage('A waypoint has been created in your datapad at the location.', 0)
return
#/wp planet x z y name
@@ -81,7 +81,7 @@ def run(core, actor, target, commandString):
waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName()))
actorPlayer.getWaypoints().add(waypoint)
actorPlayer.waypointAdd(waypoint)
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
actor.sendSystemMessage('A waypoint has been created in your datapad at the location.', 0)
return
#/wp NAME
+69
View File
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.common;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public final class AString extends Delta {
private String string;
public AString() {
string = "";
}
public AString(String string) {
this.string = ((string == null) ? "" : string);
}
public String get() {
synchronized(objectMutex) {
return string;
}
}
public void set(String string) {
synchronized(objectMutex) {
this.string = string;
}
}
public short length() {
synchronized(objectMutex) {
return (short) string.length();
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
return IoBuffer.allocate(2 + string.length(), false).order(ByteOrder.LITTLE_ENDIAN).putShort((short) string.length()).put(string.getBytes()).flip().array();
}
}
}
+2 -1
View File
@@ -46,7 +46,8 @@ public class Opcodes {
public static int RequestGalaxyLoopTimes = 0x7D842D68;
public static int SelectCharacter = 0xB5098D76;
public static int SuiEventNotification = 0x092D3564;
public static int DeltasMessage = 0x12862153;
public static int BaselinesMessage = CRC.StringtoCRC("BaselinesMessage");
public static int DeltasMessage = CRC.StringtoCRC("DeltasMessage");
public static int ChatAddFriend = 0x6FE7BD90;
public static int GcwRegionsReq = CRC.StringtoCRC("GcwRegionsReq");
public static int GcwRegionsRsp = CRC.StringtoCRC("GcwRegionsRsp");
+98
View File
@@ -0,0 +1,98 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.common;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.objects.Delta;
import com.sleepycat.persist.model.Persistent;
@Persistent
public class Stf extends Delta {
private AString stfFilename;
private int spacer = 0;
private AString stfName;
public Stf(String stfFilename, int spacer, String stfName) {
this.stfFilename = new AString(stfFilename);
this.spacer = spacer;
this.stfName = new AString(stfName);
}
public Stf() {
}
public String getStfFilename() {
synchronized(objectMutex) {
return stfFilename.get();
}
}
public void setStfFilename(String stfFilename) {
synchronized(objectMutex) {
this.stfFilename = new AString(stfFilename);
}
}
public int getSpacer() {
synchronized(objectMutex) {
return spacer;
}
}
public void setSpacer(int spacer) {
synchronized(objectMutex) {
this.spacer = spacer;
}
}
public String getStfName() {
synchronized(objectMutex) {
return stfName.get();
}
}
public void setStfName(String stfName) {
synchronized(objectMutex) {
this.stfName = new AString(stfName);
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
int size = stfFilename.getBytes().length + 4 + stfName.getBytes().length;
IoBuffer buffer = Baseline.createBuffer(size);
buffer.put(stfFilename.getBytes());
buffer.putInt(spacer);
buffer.put(stfName.getBytes());
buffer.flip();
return buffer.array();
}
}
}
+75
View File
@@ -0,0 +1,75 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.common;
import java.io.UnsupportedEncodingException;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public final class UString extends Delta {
private String string;
public UString() {
string = "";
}
public UString(String string) {
this.string = ((string == null) ? "" : string);
}
public String get() {
synchronized(objectMutex) {
return string;
}
}
public void set(String string) {
synchronized(objectMutex) {
this.string = string;
}
}
public int length() {
synchronized(objectMutex) {
return string.length();
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
try {
return IoBuffer.allocate(4 + string.length(), false).order(ByteOrder.LITTLE_ENDIAN).putInt(string.length()).put(string.getBytes("UTF-16LE")).flip().array();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return new byte[] { 0x00, 0x00, 0x00, 0x00 };
}
}
}
}
+3 -3
View File
@@ -23,8 +23,8 @@ package resources.datatables;
public class FactionStatus {
public static int OnLeave = 0;
public static int Combatant = 1;
public static int SpecialForces = 2;
public static final int OnLeave = 0;
public static final int Combatant = 1;
public static final int SpecialForces = 2;
}
+324
View File
@@ -0,0 +1,324 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.buffs;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.buffer.SimpleBufferAllocator;
import resources.objects.IDelta;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clientdata.ClientFileManager;
import engine.clientdata.visitors.DatatableVisitor;
@Persistent(version=3)
public class Buff implements IDelta {
@NotPersistent
private SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
private float duration;
private String buffName;
private long ownerId;
private String effect1Name, effect2Name, effect3Name, effect4Name, effect5Name;
private float effect1Value, effect2Value, effect3Value, effect4Value, effect5Value;
private String particleEffect;
private boolean isDebuff;
private boolean removeOnDeath;
private boolean isRemovableByPlayer;
private int maxStacks;
private boolean isPersistent;
private boolean removeOnRespec;
private boolean aiRemoveOnEndCombat;
private boolean decayOnPvPDeath;
private long startTime;
private int totalPlayTime;
public Buff(String buffName, long ownerId) {
this.buffName = buffName;
this.ownerId = ownerId;
DatatableVisitor visitor;
try {
visitor = ClientFileManager.loadFile("datatables/buff/buff.iff", DatatableVisitor.class);
for (int i = 0; i < visitor.getRowCount(); i++) {
if (visitor.getObject(i, 0) != null) {
if (((String) visitor.getObject(i, 0)).equalsIgnoreCase(buffName)) {
duration = (Float) visitor.getObject(i, 6);
effect1Name = (String) visitor.getObject(i, 7);
effect1Value = (Float) visitor.getObject(i, 8);
effect2Name = (String) visitor.getObject(i, 9);
effect2Value = (Float) visitor.getObject(i, 10);
effect3Name = (String) visitor.getObject(i, 11);
effect3Value = (Float) visitor.getObject(i, 12);
effect4Name = (String) visitor.getObject(i, 13);
effect4Value = (Float) visitor.getObject(i, 14);
effect5Name = (String) visitor.getObject(i, 15);
effect5Value = (Float) visitor.getObject(i, 16);
particleEffect = (String) visitor.getObject(i, 19);
isDebuff = (Boolean) visitor.getObject(i, 22);
removeOnDeath = (Integer) visitor.getObject(i, 25) != 0;
isRemovableByPlayer = (Integer) visitor.getObject(i, 26) != 0;
maxStacks = (Integer) visitor.getObject(i, 28);
isPersistent = (Integer) visitor.getObject(i, 29) != 0;
removeOnRespec = (Integer) visitor.getObject(i, 31) != 0;
aiRemoveOnEndCombat = (Integer) visitor.getObject(i, 32) != 0;
decayOnPvPDeath = (Integer) visitor.getObject(i, 33) != 0;
}
}
}
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
public Buff() {
}
public byte[] getBytes() {
IoBuffer buffer = bufferPool.allocate(28, false).order(ByteOrder.LITTLE_ENDIAN);
if (duration > 0) {
buffer.putInt((int) (totalPlayTime + getRemainingDuration()));
buffer.putInt(0);
buffer.putInt((int) duration);
} else {
buffer.putInt(-1);
buffer.putInt(0);
buffer.putInt(-1);
}
buffer.putLong(ownerId);
buffer.putInt(1); // Unknown
buffer.flip();
return buffer.array();
}
public float getDuration() {
return duration;
}
public void setDuration(float duration) {
this.duration = duration;
}
public String getBuffName() {
return buffName;
}
public void setBuffName(String buffName) {
this.buffName = buffName;
}
public long getOwnerId() {
return ownerId;
}
public void setOwnerId(long ownerId) {
this.ownerId = ownerId;
}
public String getEffect1Name() {
return effect1Name;
}
public void setEffect1Name(String effect1Name) {
this.effect1Name = effect1Name;
}
public String getEffect2Name() {
return effect2Name;
}
public void setEffect2Name(String effect2Name) {
this.effect2Name = effect2Name;
}
public String getEffect3Name() {
return effect3Name;
}
public void setEffect3Name(String effect3Name) {
this.effect3Name = effect3Name;
}
public String getEffect4Name() {
return effect4Name;
}
public void setEffect4Name(String effect4Name) {
this.effect4Name = effect4Name;
}
public String getEffect5Name() {
return effect5Name;
}
public void setEffect5Name(String effect5Name) {
this.effect5Name = effect5Name;
}
public float getEffect1Value() {
return effect1Value;
}
public void setEffect1Value(float effect1Value) {
this.effect1Value = effect1Value;
}
public float getEffect2Value() {
return effect2Value;
}
public void setEffect2Value(float effect2Value) {
this.effect2Value = effect2Value;
}
public float getEffect3Value() {
return effect3Value;
}
public void setEffect3Value(float effect3Value) {
this.effect3Value = effect3Value;
}
public float getEffect4Value() {
return effect4Value;
}
public void setEffect4Value(float effect4Value) {
this.effect4Value = effect4Value;
}
public float getEffect5Value() {
return effect5Value;
}
public void setEffect5Value(float effect5Value) {
this.effect5Value = effect5Value;
}
public String getParticleEffect() {
return particleEffect;
}
public void setParticleEffect(String particleEffect) {
this.particleEffect = particleEffect;
}
public boolean isDebuff() {
return isDebuff;
}
public void setDebuff(boolean isDebuff) {
this.isDebuff = isDebuff;
}
public boolean isRemoveOnDeath() {
return removeOnDeath;
}
public void setRemoveOnDeath(boolean removeOnDeath) {
this.removeOnDeath = removeOnDeath;
}
public boolean isRemovableByPlayer() {
return isRemovableByPlayer;
}
public void setRemovableByPlayer(boolean isRemovableByPlayer) {
this.isRemovableByPlayer = isRemovableByPlayer;
}
public int getMaxStacks() {
return maxStacks;
}
public void setMaxStacks(int maxStacks) {
this.maxStacks = maxStacks;
}
public boolean isPersistent() {
return isPersistent;
}
public void setPersistent(boolean isPersistent) {
this.isPersistent = isPersistent;
}
public boolean isRemoveOnRespec() {
return removeOnRespec;
}
public void setRemoveOnRespec(boolean removeOnRespec) {
this.removeOnRespec = removeOnRespec;
}
public boolean isAiRemoveOnEndCombat() {
return aiRemoveOnEndCombat;
}
public void setAiRemoveOnEndCombat(boolean aiRemoveOnEndCombat) {
this.aiRemoveOnEndCombat = aiRemoveOnEndCombat;
}
public boolean isDecayOnPvPDeath() {
return decayOnPvPDeath;
}
public void setDecayOnPvPDeath(boolean decayOnPvPDeath) {
this.decayOnPvPDeath = decayOnPvPDeath;
}
public void setStartTime() {
this.startTime = System.currentTimeMillis();
}
public int getRemainingDuration() {
long currentTime = System.currentTimeMillis();
long timeDiff = (currentTime - startTime) / 1000;
int remaining = (int) (duration - timeDiff);
System.out.println("Buff remaining: " + remaining);
return remaining;
}
public int getTotalPlayTime() {
return totalPlayTime;
}
public void setTotalPlayTime(int totalPlayTime) {
this.totalPlayTime = totalPlayTime;
}
}
@@ -0,0 +1,88 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.craft;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public class DraftSchematic extends Delta {
private int serverSchematicCrc = 0;
private int schematicCrc = 0;
private int amount = 1;
public DraftSchematic(int serverSchematicCrc, int schematicCrc, int amount) {
this.serverSchematicCrc = serverSchematicCrc;
this.schematicCrc = schematicCrc;
this.amount = amount;
}
public DraftSchematic(int serverSchematicCrc, int schematicCrc) {
this.serverSchematicCrc = serverSchematicCrc;
this.schematicCrc = schematicCrc;
}
public DraftSchematic() {
}
public int getServerSchematicCrc() {
synchronized(objectMutex) {
return serverSchematicCrc;
}
}
public int getSchematicCrc() {
synchronized(objectMutex) {
return schematicCrc;
}
}
public int getAmount() {
synchronized(objectMutex) {
return amount;
}
}
public void setAmount(int amount) {
synchronized(objectMutex) {
this.amount = amount;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(12, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(serverSchematicCrc);
buffer.putInt(schematicCrc);
buffer.putInt(amount);
return buffer.array();
}
}
}
@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.equipment;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import engine.resources.common.CRC;
import engine.resources.objects.SWGObject;
import resources.objects.Delta;
import resources.z.exp.objects.tangible.TangibleObject;
import resources.z.exp.objects.weapon.WeaponObject;
@Persistent
public class Equipment extends Delta {
private TangibleObject object;
public Equipment(SWGObject object) {
this.object = ((object instanceof TangibleObject) ? (TangibleObject) object : null);
}
public Equipment() {
}
public SWGObject getObject() {
synchronized(objectMutex) {
return object;
}
}
public long getObjectId() {
synchronized(objectMutex) {
return object.getObjectId();
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
int size = 18 + object.getCustomization().length;
IoBuffer buffer = bufferPool.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.setAutoExpand(true);
buffer.putShort((short) object.getCustomization().length);
buffer.put(object.getCustomization());
buffer.putInt(object.getArrangementId());
buffer.putLong(object.getObjectID());
buffer.putInt(CRC.StringtoCRC(object.getTemplate()));
buffer.put(getBoolean((object instanceof WeaponObject)));
if (object instanceof WeaponObject) {
buffer.put(((WeaponObject) object).getBaseline3().getBaseline());
buffer.put(((WeaponObject) object).getBaseline6().getBaseline());
}
buffer.flip();
return buffer.array();
}
}
}
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.gcw;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public class CurrentServerGCWZoneHistory extends Delta implements Cloneable {
private int lastUpdateTime;
private int percent;
public CurrentServerGCWZoneHistory(CurrentServerGCWZonePercent zone) {
this.percent = zone.getPercent().intValue();
this.lastUpdateTime = zone.getLastUpdateTime();
}
public CurrentServerGCWZoneHistory() {
}
public int getLastUpdateTime() {
synchronized(objectMutex) {
return lastUpdateTime;
}
}
public int getPercent() {
synchronized(objectMutex) {
return percent;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate((8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(lastUpdateTime);
buffer.putInt(percent);
return buffer.array();
}
}
public CurrentServerGCWZoneHistory clone() {
try {
return (CurrentServerGCWZoneHistory) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
}
@@ -0,0 +1,173 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.gcw;
import java.math.BigDecimal;
import java.math.MathContext;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import engine.resources.scene.Point2D;
import resources.objects.Delta;
@Persistent
public class CurrentServerGCWZonePercent extends Delta implements Cloneable {
private Point2D position;
private float radius = 0;
private BigDecimal weight;
private int type = 0;
private BigDecimal percent;
private int gcwPoints = 1;
private long lastUpdateTime = (System.currentTimeMillis() / ((long) 1000));
public CurrentServerGCWZonePercent(Point2D position, float radius, int weight, int type) {
this.position = position;
this.radius = radius;
this.weight = new BigDecimal(weight, MathContext.DECIMAL128);
this.weight = this.weight.divide(new BigDecimal("10000000.0", MathContext.DECIMAL128), MathContext.DECIMAL128);
this.type = type;
this.percent = new BigDecimal("50.0", MathContext.DECIMAL128);
}
public CurrentServerGCWZonePercent() {
}
public Point2D getPosition() {
synchronized(objectMutex) {
return position.clone();
}
}
public void setPosition(Point2D position) {
synchronized(objectMutex) {
this.position = position;
}
}
public float getRadius() {
synchronized(objectMutex) {
return radius;
}
}
public void setRadius(float radius) {
synchronized(objectMutex) {
this.radius = radius;
}
}
public int getGroup() {
synchronized(objectMutex) {
return weight.unscaledValue().intValue();
}
}
public BigDecimal getWeight() {
synchronized(objectMutex) {
return weight;
}
}
public void setWeight(int weight) {
synchronized(objectMutex) {
this.weight = new BigDecimal(weight, MathContext.DECIMAL128);
this.weight = this.weight.divide(new BigDecimal("10000000.0", MathContext.DECIMAL128), MathContext.DECIMAL128);
}
}
public int getType() {
synchronized(objectMutex) {
return type;
}
}
public void setType(int type) {
synchronized(objectMutex) {
this.type = type;
}
}
public BigDecimal getPercent() {
synchronized(objectMutex) {
return percent;
}
}
public CurrentServerGCWZonePercent setPercent(BigDecimal percent) {
synchronized(objectMutex) {
this.percent = percent;
this.lastUpdateTime = (System.currentTimeMillis() / ((long) 1000));
return this;
}
}
public int getGCWPoints() {
synchronized(objectMutex) {
return gcwPoints;
}
}
public void addGCWPoints(int gcwPoints) {
synchronized(objectMutex) {
this.gcwPoints += gcwPoints;
}
}
public void removeGCWPoints(int gcwPoints) {
synchronized(objectMutex) {
this.gcwPoints = (((this.gcwPoints - gcwPoints) < 1) ? 1 : this.gcwPoints - gcwPoints);
}
}
public int getLastUpdateTime() {
synchronized(objectMutex) {
return ((int) lastUpdateTime);
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(percent.intValue());
return buffer.array();
}
}
@Override
public CurrentServerGCWZonePercent clone() {
try {
CurrentServerGCWZonePercent object = (CurrentServerGCWZonePercent) super.clone();
object.setPosition(getPosition());
return object;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
}
@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.gcw;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public class OtherServerGCWZonePercent extends Delta implements Cloneable {
private String zone = "";
private int percent = 50;
public OtherServerGCWZonePercent(String zone) {
this.zone = zone;
}
public OtherServerGCWZonePercent() {
}
public String getZone() {
synchronized(objectMutex) {
return zone;
}
}
public int getPercent() {
synchronized(objectMutex) {
return percent;
}
}
public OtherServerGCWZonePercent setPercent(double percent) {
synchronized(objectMutex) {
this.percent = (int) percent;
return this;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate((2 + zone.length() + 4), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(getAsciiString(zone));
buffer.putInt(percent);
return buffer.array();
}
}
@Override
public OtherServerGCWZonePercent clone() {
try {
return (OtherServerGCWZonePercent) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
}
@@ -0,0 +1,99 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.gcw;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.common.AString;
import resources.z.exp.objects.Baseline;
import resources.objects.Delta;
@Persistent
public class RegionDefender extends Delta {
private AString region;
private byte byte1 = 0;
private byte byte2 = 0;
public RegionDefender(String region, byte byte1, byte byte2) {
this.region = new AString(region);
this.byte1 = byte1;
this.byte2 = byte2;
}
public RegionDefender(String region) {
this.region = new AString(region);
}
public RegionDefender() {
this.region = new AString();
}
public String getRegion() {
synchronized(objectMutex) {
return region.get();
}
}
public void setRegion(String region) {
synchronized(objectMutex) {
this.region = new AString(region);
}
}
public byte getByte1() {
synchronized(objectMutex) {
return byte1;
}
}
public void setByte1(byte byte1) {
synchronized(objectMutex) {
this.byte1 = byte1;
}
}
public byte getByte2() {
synchronized(objectMutex) {
return byte2;
}
}
public void setByte2(byte byte2) {
synchronized(objectMutex) {
this.byte2 = byte2;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = Baseline.createBuffer(region.getBytes().length + 2);
buffer.put(region.getBytes());
buffer.put(byte1);
buffer.put(byte2);
return buffer.array();
}
}
}
@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.group;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.common.AString;
import resources.z.exp.objects.Baseline;
import resources.objects.Delta;
@Persistent
public class GroupInviteInfo extends Delta {
private long senderId;
private AString senderName;
private long inviteCounter;
public GroupInviteInfo(long senderId, String senderName) {
this.senderId = senderId;
this.senderName = new AString(senderName);
inviteCounter = 1;
}
public GroupInviteInfo() {
}
public long getSenderId() {
synchronized(objectMutex) {
return senderId;
}
}
public String getSenderName() {
synchronized(objectMutex) {
return senderName.get();
}
}
public void setSender(long senderId, String senderName) {
synchronized(objectMutex) {
this.senderId = senderId;
this.senderName = new AString(senderName);
inviteCounter++;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = Baseline.createBuffer(16 + senderName.getBytes().length);
buffer.putLong(senderId);
buffer.put(senderName.getBytes());
buffer.putLong(inviteCounter);
return buffer.array();
}
}
}
+70
View File
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.group;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import engine.resources.objects.SWGObject;
import resources.objects.Delta;
@Persistent
public class Member extends Delta {
private SWGObject member;
public Member(SWGObject member) {
this.member = member;
}
public Member() {
}
public SWGObject getMember() {
synchronized(objectMutex) {
return member;
}
}
public long getObjectId() {
return member.getObjectID();
}
public String getCustomName() {
return member.getCustomName();
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(8 + getAsciiString(getCustomName()).length, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putLong(getObjectId());
buffer.put(getAsciiString(getCustomName()));
return buffer.array();
}
}
}
+82
View File
@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.group;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public class MemberInfo extends Delta {
private long info;
private int memberId;
public MemberInfo(long info, int memberId) {
this.info = info;
this.memberId = memberId;
}
public MemberInfo() {
}
public long getInfo() {
synchronized(objectMutex) {
return info;
}
}
public MemberInfo setInfo(long info) {
synchronized(objectMutex) {
this.info = info;
return this;
}
}
public int getMemberId() {
synchronized(objectMutex) {
return memberId;
}
}
public MemberInfo setMemberId(int memberId) {
synchronized(objectMutex) {
this.memberId = memberId;
return this;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(12, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putLong(info);
buffer.putInt(memberId);
return buffer.array();
}
}
}
+120
View File
@@ -0,0 +1,120 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.guild;
import java.nio.ByteOrder;
import java.util.List;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
import engine.resources.objects.SWGObject;
@Persistent
public class Guild extends Delta {
private int id;
private String abbreviation;
private String name;
private SWGObject leader;
private List<SWGObject> members;
public Guild(int id, String abbreviation, String name, SWGObject leader) {
this.id = id;
this.abbreviation = abbreviation;
this.name = name;
this.leader = leader;
this.members.add(leader);
}
public Guild() {
}
public int getId() {
synchronized(objectMutex) {
return id;
}
}
public void setId(int id) {
synchronized(objectMutex) {
this.id = id;
}
}
public String getAbbreviation() {
synchronized(objectMutex) {
return abbreviation;
}
}
public void setAbbreviation(String abbreviation) {
synchronized(objectMutex) {
this.abbreviation = abbreviation;
}
}
public String getName() {
synchronized(objectMutex) {
return name;
}
}
public void setName(String name) {
synchronized(objectMutex) {
this.name = name;
}
}
public String getString() {
return (Integer.toString(getId()) + ":" + getAbbreviation());
}
public SWGObject getLeader() {
synchronized(objectMutex) {
return leader;
}
}
public void setLeader(SWGObject leader) {
synchronized(objectMutex) {
this.leader = leader;
}
}
public List<SWGObject> getMembers() {
return members;
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate((getString().length() + 2), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(getAsciiString(getString()));
return buffer.array();
}
}
}
@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.manufacture;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public class Property extends Delta {
private int unused = 0;
private String key = "";
private float value = 0;
public Property(String key, float value) {
this.key = key;
this.value = value;
}
public Property() {
}
public String getKey() {
synchronized(objectMutex) {
return key;
}
}
public Property setKey(String key) {
synchronized(objectMutex) {
this.key = key;
return this;
}
}
public float getValue() {
synchronized(objectMutex) {
return value;
}
}
public Property setValue(float value) {
synchronized(objectMutex) {
this.value = value;
return this;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(8 + getAsciiString(key).length, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(unused);
buffer.put(getAsciiString(key));
buffer.putFloat(value);
return buffer.array();
}
}
}
@@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.manufacture;
import java.nio.ByteOrder;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
import resources.z.exp.objects.Baseline;
@Persistent
public class SubList<o> extends Delta {
private List<o> list = new CopyOnWriteArrayList<o>();
public SubList() {
}
public List<o> getList() {
return list;
}
public byte[] getBytes() {
synchronized(objectMutex) {
int size = 4;
for (o object : list) size += Baseline.toBytes(object).length;
IoBuffer buffer = bufferPool.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(list.size());
for (o object : list) {
buffer.put(Baseline.toBytes(object));
}
return buffer.array();
}
}
}
@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.manufacture;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
@Persistent
public class TableAndKey extends Delta {
private String table = "";
private int unused = 0;
private String key = "";
public TableAndKey(String table, String key) {
this.table = table;
this.table = key;
}
public TableAndKey() {
}
public String getTable() {
synchronized(objectMutex) {
return table;
}
}
public TableAndKey setTable(String table) {
synchronized(objectMutex) {
this.table = table;
return this;
}
}
public String getKey() {
synchronized(objectMutex) {
return key;
}
}
public TableAndKey setKey(String key) {
synchronized(objectMutex) {
this.key = key;
return this;
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(4 + getAsciiString(table).length + getAsciiString(key).length, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(getAsciiString(table));
buffer.putInt(unused);
buffer.put(getAsciiString(key));
return buffer.array();
}
}
}
@@ -0,0 +1,47 @@
package resources.z.exp.mission;
import com.sleepycat.persist.model.Persistent;
import engine.resources.common.CRC;
import engine.resources.scene.Point3D;
@Persistent
public class MissionLocation {
private float x, y, z;
private long objectId;
private String planet;
public MissionLocation(Point3D position, long objectId, String planet) {
this.x = position.x;
this.y = position.y;
this.z = position.z;
this.objectId = objectId;
this.planet = planet;
}
public MissionLocation() {
}
public Point3D getPosition() {
return new Point3D(x, y, z);
}
public long getObjectId() {
return objectId;
}
public String getPlanet() {
return planet;
}
public int getPlanetCRC() {
if (planet != null) {
return CRC.StringtoCRC(planet);
} else {
return 0;
}
}
}
+747
View File
@@ -0,0 +1,747 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
import java.io.UnsupportedEncodingException;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.buffer.SimpleBufferAllocator;
import resources.common.AString;
import resources.common.Opcodes;
import resources.common.UString;
import resources.objects.IDelta;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.resources.objects.SWGObject;
@Persistent
public class Baseline implements List<Object> {
private List<Object> list = new CopyOnWriteArrayList<Object>();
private Map<String, Integer> definition = new TreeMap<String, Integer>();
private BaseObject object;
private byte viewType;
@NotPersistent
protected final Object objectMutex = new Object();
@NotPersistent
private static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
@NotPersistent
private Map<Integer, Builder> baselineBuilders;
@NotPersistent
private Map<Integer, Builder> deltaBuilders;
public Baseline() { }
public Baseline(BaseObject object, int viewType) {
this.viewType = (byte) viewType;
this.object = object;
}
public boolean add(Object e) {
synchronized(objectMutex) {
if (list.add(e)) {
definition.put(Integer.toString(list.size() - 1), list.size() - 1);
return true;
} else {
return false;
}
}
}
public void add(int index, Object element) {
synchronized(objectMutex) {
return;
}
}
public boolean addAll(Collection<? extends Object> c) {
synchronized(objectMutex) {
return false;
}
}
public boolean addAll(int index, Collection<? extends Object> c) {
synchronized(objectMutex) {
return false;
}
}
public void clear() {
synchronized(objectMutex) {
list.clear();
definition.clear();
}
}
public boolean contains(Object o) {
synchronized(objectMutex) {
return list.contains(o);
}
}
public boolean containsAll(Collection<?> c) {
synchronized(objectMutex) {
return list.containsAll(c);
}
}
private boolean compareTypes(Object o1, Object o2) {
if ((o1 instanceof IDelta && o2 instanceof IDelta) ||
(o1 instanceof AString && o2 instanceof AString) ||
(o1 instanceof UString && o2 instanceof UString) ||
(o1 instanceof Byte[] && o2 instanceof Byte[]) ||
(o1 instanceof Byte && o2 instanceof Byte) ||
(o1 instanceof Boolean && o2 instanceof Boolean) ||
(o1 instanceof Short && o2 instanceof Short) ||
(o1 instanceof Integer && o2 instanceof Integer) ||
(o1 instanceof Float && o2 instanceof Float) ||
(o1 instanceof Long && o2 instanceof Long) ||
(o1 instanceof SWGObject && o2 instanceof SWGObject) ||
(o1 instanceof SWGList && o2 instanceof SWGList) ||
(o1 instanceof SWGSet && o2 instanceof SWGSet) ||
(o1 instanceof SWGMap && o2 instanceof SWGMap) ||
(o1 instanceof SWGMultiMap && o2 instanceof SWGMultiMap) ||
(o1 instanceof ArrayList && o2 instanceof ArrayList)) {
return true;
}
return false;
}
public IoBuffer createBaseline() {
byte[] objects = { };
int size = 0;
for (Object o : list) {
byte[] object;
if (baselineBuilders != null && baselineBuilders.containsKey(o)) {
object = baselineBuilders.get(o).build();
} else {
object = toBytes(o);
}
size += object.length;
IoBuffer buffer = createBuffer(size);
buffer.put(objects);
buffer.put(object);
buffer.flip();
objects = buffer.array();
}
IoBuffer buffer = createBuffer(25 + size);
buffer.putShort((short) 5);
buffer.putInt(Opcodes.BaselinesMessage);
buffer.putLong(object.getObjectID());
try {
buffer.put(reverse(getShortTemplate()).getBytes("US-ASCII"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
buffer.put(viewType);
buffer.putInt(size);
buffer.putShort((short) list.size());
buffer.put(objects);
buffer.flip();
return buffer;
}
public static IoBuffer createBuffer(int size) {
return bufferPool.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
}
public IoBuffer createDelta() {
List<Integer> objectQueue = new ArrayList<Integer>();
synchronized(objectMutex) {
for (int i = 0; i < list.size(); i++) {
objectQueue.add(i);
}
}
return createDelta(objectQueue, null);
}
public IoBuffer createDelta(int object) {
List<Integer> objectQueue = new ArrayList<Integer>();
objectQueue.add(object);
return createDelta(objectQueue, null);
}
public IoBuffer createDelta(int object, byte[] data) {
List<Integer> objectQueue = new ArrayList<Integer>();
objectQueue.add(object);
return createDelta(objectQueue, data);
}
public IoBuffer createDelta(List<Integer> objectQueue, byte[] data) {
byte[] objects = { };
int size = 0;
for (Integer o : objectQueue) {
byte[] object;
if (deltaBuilders != null && deltaBuilders.containsKey(o)) {
object = deltaBuilders.get(o).build();
} else if (data != null) {
object = data;
} else {
object = toBytes(get(o));
}
size += 2 + object.length;
IoBuffer buffer = createBuffer(size);
buffer.put(objects);
buffer.putShort(o.shortValue());
buffer.put(object);
buffer.flip();
objects = buffer.array();
}
IoBuffer buffer = createBuffer(27 + size);
buffer.putShort((short) 5);
buffer.putInt(Opcodes.DeltasMessage);
buffer.putLong(object.getObjectID());
try {
buffer.put(reverse(getShortTemplate()).getBytes("US-ASCII"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
buffer.put(viewType);
buffer.putInt(size);
buffer.putShort((short) objectQueue.size());
buffer.put(objects);
buffer.flip();
return buffer;
}
public Object get(int index) {
synchronized(objectMutex) {
return list.get(index);
}
}
public Object get(String name) {
synchronized(objectMutex) {
return list.get(definition.get(name));
}
}
public IoBuffer getBaseline() {
return createBaseline();
}
public Map<Integer, Builder> getBaselineBuilders() {
synchronized(objectMutex) {
return baselineBuilders;
}
}
public static byte getBoolean(boolean condition) {
return ((byte) ((condition) ? 1 : 0));
}
public byte[] getBytes() {
synchronized(objectMutex) {
int size = 0;
for (Object o : list) {
size += toBytes(o).length;
}
IoBuffer buffer = createBuffer(size);
for (Object o : list) {
buffer.put(toBytes(o));
}
buffer.flip();
return buffer.array();
}
}
public byte[] getBytes(int index) {
synchronized(objectMutex) {
return toBytes(list.get(index));
}
}
public byte[] getBytes(String name) {
synchronized(objectMutex) {
return toBytes(list.get(definition.get(name)));
}
}
private String getDefinition(int index) {
for (Entry<String, Integer> entry : definition.entrySet()) {
if (entry.getValue() == index) {
return entry.getKey();
}
}
return null;
}
public Map<String, Integer> getDefinitions() {
synchronized(objectMutex) {
return definition;
}
}
public IoBuffer getDelta(int index) {
return createDelta(index);
}
public IoBuffer getDelta(String name) {
return createDelta(definition.get(name));
}
public Map<Integer, Builder> getDeltaBuilders() {
synchronized(objectMutex) {
return deltaBuilders;
}
}
public Object getMutex() {
return objectMutex;
}
public String getShortTemplate() throws Exception {
String Template = object.getTemplate();
if (Template.startsWith("object/battlefield_marker")) {
return "BMRK";
} else if(Template.startsWith("object/building")){
return "BUIO";
} else if(Template.startsWith("object/cell")) {
return "SCLT";
} else if (Template.startsWith("object/construction_contract")) {
throw new Exception();
} else if (Template.startsWith("object/counting")) {
throw new Exception();
} else if (Template.startsWith("object/creature")) {
return "CREO";
} else if (Template.startsWith("object/draft_schematic")) {
throw new Exception();
} else if (Template.startsWith("object/factory")) {
return "FCYT";
} else if(Template.startsWith("object/group")) {
return "GRUP";
} else if(Template.startsWith("object/guild")) {
return "GILD";
} else if (Template.startsWith("object/installation")) {
return "INSO";
} else if (Template.startsWith("object/installation/battlefield")) {
throw new Exception();
} else if (Template.startsWith("object/installation/faction_perk/covert_detector")) {
throw new Exception();
} else if (Template.startsWith("object/installation/faction_perk/minefield")) {
throw new Exception();
} else if (Template.startsWith("object/installation/faction_perk/turret")) {
throw new Exception();
} else if (Template.startsWith("object/installation/generators")) {
return "HINO";
} else if (Template.startsWith("object/installation/manufacture")) {
return "MINO";
} else if (Template.startsWith("object/installation/mining_gas")) {
throw new Exception();
} else if (Template.startsWith("object/installation/mining_liquid")) {
throw new Exception();
} else if (Template.startsWith("object/installation/mining_gas")) {
throw new Exception();
} else if (Template.startsWith("object/installation/mining_ore")) {
throw new Exception();
} else if (Template.startsWith("object/installation/mining_organic")) {
throw new Exception();
} else if (Template.startsWith("object/installation/turret")) {
throw new Exception();
} else if (Template.startsWith("object/intangible")) {
return "ITNO";
} else if (Template.startsWith("object/jedi_manager")) {
throw new Exception();
} else if (Template.startsWith("object/manufacture_schematic")) {
return "MSCO";
} else if (Template.startsWith("object/mission")) {
return "MISO";
} else if (Template.startsWith("object/mobile")) {
throw new Exception();
} else if (Template.startsWith("object/object")) {
throw new Exception();
} else if (Template.startsWith("object/path_waypoint")) {
throw new Exception();
} else if (Template.startsWith("object/player")) {
return "PLAY";
} else if (Template.startsWith("object/player_quest")) {
return "PQOS";
} else if (Template.startsWith("object/resource_container")) {
return "RCNO";
} else if (Template.startsWith("object/ship")) {
return "SHIP";
} else if (Template.startsWith("object/soundobject")) {
throw new Exception();
} else if(Template.startsWith("object/static")) {
return "STAO";
} else if (Template.startsWith("object/tangible")) {
return "TANO";
} else if (Template.startsWith("object/token")) {
throw new Exception();
} else if (Template.startsWith("object/universe")) {
throw new Exception();
} else if(Template.startsWith("object/waypoint")) {
return "WAYP";
} else if (Template.startsWith("object/weapon")) {
return "WEAO";
} else {
throw new Exception();
}
}
public int indexOf(Object o) {
synchronized(objectMutex) {
return list.indexOf(o);
}
}
public boolean isEmpty() {
synchronized(objectMutex) {
return list.isEmpty();
}
}
public Iterator<Object> iterator() {
synchronized(objectMutex) {
return list.iterator();
}
}
public int lastIndexOf(Object o) {
synchronized(objectMutex) {
return lastIndexOf(o);
}
}
public ListIterator<Object> listIterator() {
synchronized(objectMutex) {
return list.listIterator();
}
}
public ListIterator<Object> listIterator(int index) {
synchronized(objectMutex) {
return listIterator(index);
}
}
public void put(String name, Object o) {
synchronized(objectMutex) {
definition.put(name, list.size());
list.add(o);
}
}
public boolean remove(Object o) {
return false;
}
public Object remove(int index) {
return null;
}
public boolean removeAll(Collection<?> c) {
return false;
}
public boolean retainAll(Collection<?> c) {
return false;
}
private String reverse(String reverseString) {
if (reverseString.length() <= 1) {
return reverseString;
}
return reverse(reverseString.substring(1, reverseString.length())) + reverseString.charAt(0);
}
public Object set(int index, Object element) {
return null;
}
public IoBuffer set(String name, Object o) {
synchronized(objectMutex) {
int index = definition.get(name);
if (compareTypes(o, list.get(index)) && list.set(index, o) != null) {
return createDelta(index);
} else {
return null;
}
}
}
public void setBaselineBuilders(Map<Integer, Builder> baselineBuilders) {
synchronized(objectMutex) {
this.baselineBuilders = baselineBuilders;
}
}
public void setDeltaBuilders(Map<Integer, Builder> deltaBuilders) {
synchronized(objectMutex) {
this.deltaBuilders = deltaBuilders;
}
}
public int size() {
synchronized(objectMutex) {
return list.size();
}
}
public List<Object> subList(int fromIndex, int toIndex) {
synchronized(objectMutex) {
return list.subList(fromIndex, toIndex);
}
}
public Object[] toArray() {
synchronized(objectMutex) {
return list.toArray();
}
}
public <T> T[] toArray(T[] a) {
synchronized(objectMutex) {
return list.toArray(a);
}
}
public static byte[] toBytes(Object o) {
try {
if (o != null) {
if (o instanceof IDelta) {
return ((IDelta) o).getBytes();
} else if (o instanceof String) {
return (new AString((String) o)).getBytes();
} else if (o instanceof AString) {
return ((AString) o).getBytes();
} else if (o instanceof UString) {
return ((UString) o).getBytes();
} else if (o instanceof Byte[]) {
IoBuffer buffer = createBuffer(2 + ((Byte[]) o).length);
buffer.putShort((short) ((Byte[]) o).length);
for (Byte b : (Byte[]) o) buffer.put(b);
return buffer.array();
} else if (o instanceof Byte) {
return createBuffer(1).put((Byte) o).array();
} else if (o instanceof Boolean) {
return createBuffer(1).put(((((Boolean) o)) ? (byte) 1 : (byte) 0)).array();
} else if (o instanceof Short) {
return createBuffer(2).putShort((Short) o).array();
} else if (o instanceof Integer) {
return createBuffer(4).putInt((Integer) o).array();
} else if (o instanceof Float) {
return createBuffer(4).putFloat((Float) o).array();
} else if (o instanceof Long) {
return createBuffer(8).putLong((Long) o).array();
} else if (o instanceof SWGObject) {
long objectId = ((((SWGObject) o) == null) ? (long) 0 : ((SWGObject) o).getObjectID());
return createBuffer(8).putLong(objectId).array();
} else if (o instanceof SWGList) {
return ((SWGList<?>) o).getBytes();
} else if (o instanceof SWGSet) {
return ((SWGSet<?>) o).getBytes();
} else if (o instanceof SWGMap) {
return ((SWGMap<?, ?>) o).getBytes();
} else if (o instanceof SWGMultiMap) {
return ((SWGMultiMap<?, ?>) o).getBytes();
} else if (o instanceof ArrayList) {
ArrayList<?> list = ((ArrayList<?>) o);
int size = 0;
byte[] objects = { };
for (int i = 0; i < list.size(); i++) {
byte[] object = toBytes(list.get(i));
size += object.length;
IoBuffer buffer = createBuffer(size);
buffer.put(objects);
buffer.put(object);
buffer.flip();
objects = buffer.array();
}
return createBuffer(size + 4).putInt(list.size()).array();
} else {
System.out.println("ERROR: Unsupported type used in Baseline: " + (o.getClass()).getSimpleName());
throw new Exception();
//return new byte[] { };
}
} else {
if (o instanceof IDelta) {
System.out.println("ERROR: a baseline object that implements IDelta is null. This could cause crashes! Make it at least a new instance with all fields set to 0.");
return new byte[] { };
} else if (o instanceof String) {
return new byte[] { 0x00, 0x00 };
} else if (o instanceof AString) {
return new byte[] { 0x00, 0x00 };
} else if (o instanceof UString) {
return new byte[] { 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof Byte[]) {
return new byte[] { 0x00, 0x00 };
} else if (o instanceof Byte) {
return new byte[] { 0x00 };
} else if (o instanceof Boolean) {
return new byte[] { 0x00 };
} else if (o instanceof Short) {
return new byte[] { 0x00, 0x00 };
} else if (o instanceof Integer) {
return new byte[] { 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof Float) {
return new byte[] { 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof Long) {
return new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof SWGObject) {
return null;
} else if (o instanceof SWGList) {
return new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof SWGSet) {
return new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof SWGMap) {
return new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof SWGMultiMap) {
return new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
} else if (o instanceof ArrayList) {
return new byte[] { 0x00, 0x00, 0x00, 0x00 };
} else {
System.out.println("ERROR: Unsupported type used in Baseline.");
System.out.println("~additionally, the type was null, which is dangerous.");
return new byte[] { };
}
}
} catch (Exception e) {
e.printStackTrace();
return new byte[] { };
}
}
public void transformStructure(Baseline defaults) {
synchronized(objectMutex) {
List<Object> oldStruct = list;
Baseline newStruct = defaults;
for (int i = 0; i < newStruct.size(); i++) {
if (definition.containsKey(newStruct.getDefinition(i))) {
int oldIndex = definition.get(newStruct.getDefinition(i));
Object newObject = newStruct.get(i);
Object oldObject = oldStruct.get(oldIndex);
if (compareTypes(newObject, oldObject)) {
newStruct.set(i, oldObject);
} else {
if (newObject instanceof String) {
if (oldObject instanceof AString) {
newStruct.set(i, ((AString) oldObject).get());
} else if (oldObject instanceof UString) {
newStruct.set(i, ((UString) oldObject).get());
}
} else if (newObject instanceof AString) {
if (oldObject instanceof String) {
newStruct.set(i, new AString((String) oldObject));
} else if (oldObject instanceof UString) {
newStruct.set(i, new AString(((UString) oldObject).get()));
}
} else if (newObject instanceof UString) {
if (oldObject instanceof String) {
newStruct.set(i, new UString((String) oldObject));
} else if (oldObject instanceof AString) {
newStruct.set(i, new UString(((AString) oldObject).get()));
}
} else if (newObject instanceof Byte) {
if (oldObject instanceof Short && (Short) oldObject < 0xFF) {
newStruct.set(i, ((Short) oldObject).byteValue());
} else if (oldObject instanceof Integer && (Integer) oldObject < 0xFF) {
newStruct.set(i, ((Integer) oldObject).byteValue());
} else if (oldObject instanceof Long && (Long) oldObject < 0xFF) {
newStruct.set(i, ((Long) oldObject).byteValue());
}
} else if (newObject instanceof Short) {
if (oldObject instanceof Byte) {
newStruct.set(i, ((Byte) oldObject).shortValue());
} else if (oldObject instanceof Integer && (Integer) oldObject < 0xFFFF) {
newStruct.set(i, ((Integer) oldObject).shortValue());
} else if (oldObject instanceof Long && (Long) oldObject < 0xFFFF) {
newStruct.set(i, ((Long) oldObject).shortValue());
}
} else if (newObject instanceof Integer) {
if (oldObject instanceof Byte) {
newStruct.set(i, ((Byte) oldObject).intValue());
} else if (oldObject instanceof Short) {
newStruct.set(i, ((Short) oldObject).intValue());
} else if (oldObject instanceof Long && (Long) oldObject < 0xFFFFFFFF) {
newStruct.set(i, ((Long) oldObject).intValue());
}
} else if (newObject instanceof Long) {
if (oldObject instanceof Byte) {
newStruct.set(i, ((Byte) oldObject).longValue());
} else if (oldObject instanceof Short) {
newStruct.set(i, ((Short) oldObject).longValue());
} else if (oldObject instanceof Integer) {
newStruct.set(i, ((Integer) oldObject).longValue());
} else if (oldObject instanceof SWGObject) {
newStruct.set(i, ((SWGObject) oldObject).getObjectID());
}
}
}
}
}
list = newStruct.list;
}
}
}
+28
View File
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
public interface Builder {
public byte[] build();
}
@@ -0,0 +1,127 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
import java.nio.ByteBuffer;
import java.util.Map;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.common.StringUtilities;
import resources.z.exp.objects.object.BaseObject;
@Persistent
public class ObjectMessageBuilder {
protected BaseObject object;
public ObjectMessageBuilder(BaseObject object) {
setObject(object);
}
public ObjectMessageBuilder() {
}
public void buildBaseline1(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
/*
baselineBuilders.put(5, new Builder {
public byte[] build() {
IoBuffer = Baseline.createBuffer(2);
buffer.putShort((short) 27);
return buffer.array();
}
});
deltaBuilders.put(7, new Builder {
public byte[] build() {
IoBuffer = Baseline.createBuffer(4);
buffer.putInt(27);
return buffer.array();
}
});
*/
}
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
}
public void buildBaseline4(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
}
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
}
public void buildBaseline7(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
}
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
}
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
}
public IoBuffer createBuffer(int size, boolean autoSize) {
return createBuffer(size).setAutoExpand(autoSize);
}
public IoBuffer createBuffer(int size) {
return Baseline.createBuffer(size);
}
public BaseObject getObject() {
return object;
}
public void setObject(BaseObject object) {
this.object = object;
}
protected byte getBoolean(boolean variable) {
return Baseline.getBoolean(variable);
}
protected String getAsciiString(ByteBuffer buffer) {
return StringUtilities.getAsciiString(buffer);
}
protected String getUnicodeString(ByteBuffer buffer) {
return StringUtilities.getUnicodeString(buffer);
}
protected byte[] getAsciiString(String string) {
return StringUtilities.getAsciiString(string);
}
protected byte[] getUnicodeString(String string) {
return StringUtilities.getUnicodeString(string);
}
}
+410
View File
@@ -0,0 +1,410 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.mina.core.buffer.IoBuffer;
import resources.objects.IDelta;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
/* A SWGList element should extend Delta or implement IDelta */
@Persistent
public class SWGList<E> implements List<E> {
private List<E> list = new CopyOnWriteArrayList<E>();
@NotPersistent
private int updateCounter = 0;
private BaseObject object;
private byte viewType;
private short updateType;
private boolean addByte;
@NotPersistent
protected final Object objectMutex = new Object();
public SWGList() { }
public SWGList(BaseObject object, int viewType, int updateType, boolean addByte) {
this.object = object;
this.viewType = (byte) viewType;
this.updateType = (short) updateType;
this.addByte = addByte;
}
public boolean add(E e) {
synchronized(objectMutex) {
if (valid(e) && list.add(e)) {
queue(item(1, list.lastIndexOf(e), Baseline.toBytes(e), true, true));
return true;
}
return false;
}
}
public void add(int index, E element) {
synchronized(objectMutex) {
if (valid(element)) {
list.add(index, element);
queue(item(1, index, Baseline.toBytes(element), true, true));
}
}
}
public boolean addAll(Collection<? extends E> c) {
synchronized(objectMutex) {
if (!c.isEmpty()) {
List<byte[]> buffer = new ArrayList<byte[]>();
boolean success = false;
for (E element : c) {
if (valid(element)) {
if (list.add(element)) {
buffer.add(item(1, list.lastIndexOf(element), Baseline.toBytes(element), true, true));
success = true;
}
} else {
return false;
}
}
if (success == true) {
queue(buffer);
} else {
return false;
}
}
return false;
}
}
public boolean addAll(int index, Collection<? extends E> c) {
synchronized(objectMutex) {
if (!c.isEmpty()) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (E element : c) {
if (valid(element)) {
list.add(index, element);
buffer.add(item(1, index, Baseline.toBytes(element), true, true));
index++;
} else {
return false;
}
}
queue(buffer);
return true;
}
return false;
}
}
public void clear() {
synchronized(objectMutex) {
list.clear();
queue(item(4, 0, null, false, false));
}
}
public boolean contains(Object o) {
synchronized(objectMutex) {
return list.contains(o);
}
}
public boolean containsAll(Collection<?> c) {
synchronized(objectMutex) {
return list.containsAll(c);
}
}
public E get(int index) {
synchronized(objectMutex) {
return list.get(index);
}
}
public List<E> get() {
return list;
}
public int indexOf(Object o) {
synchronized(objectMutex) {
return list.indexOf(o);
}
}
public boolean isEmpty() {
synchronized(objectMutex) {
return list.isEmpty();
}
}
public Iterator<E> iterator() {
synchronized(objectMutex) {
return list.iterator();
}
}
public int lastIndexOf(Object o) {
synchronized(objectMutex) {
return list.lastIndexOf(o);
}
}
public ListIterator<E> listIterator() {
synchronized(objectMutex) {
return list.listIterator();
}
}
public ListIterator<E> listIterator(int index) {
synchronized(objectMutex) {
return listIterator(index);
}
}
public boolean remove(Object o) {
synchronized(objectMutex) {
int index = list.indexOf(o);
if (list.remove(o)) {
queue(item(1, index, null, true, false));
return true;
} else {
return false;
}
}
}
public E remove(int index) {
synchronized(objectMutex) {
E element = list.remove(index);
queue(item(1, index, null, true, false));
return (E) element;
}
}
public boolean removeAll(Collection<?> c) {
synchronized(objectMutex) {
if (!c.isEmpty()) {
List<byte[]> buffer = new ArrayList<byte[]>();
int index;
boolean success = false;
for (Object element : c) {
index = list.indexOf(element);
if (list.remove(element)) {
buffer.add(item(0, index, null, true, false));
success = true;
}
}
if (success) {
queue(buffer);
}
return success;
}
return false;
}
}
public boolean retainAll(Collection<?> c) {
synchronized(objectMutex) {
return list.retainAll(c);
}
}
public E set(int index, E element) {
synchronized(objectMutex) {
if (valid(element)) {
E previousElement = list.set(index, element);
queue(item(2, index, Baseline.toBytes(element), true, true));
return previousElement;
}
return null;
}
}
public boolean set(List<E> list) {
synchronized(objectMutex) {
byte[] newListData = { 0x03 };
if (!list.isEmpty()) {
for (E element : list) {
if (valid(element)) {
IoBuffer buffer = IoBuffer.allocate((newListData.length + Baseline.toBytes(element).length), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(newListData);
buffer.put(Baseline.toBytes(element));
newListData = buffer.array();
} else {
return false;
}
}
this.list = list;
updateCounter++;
queue(newListData);
return true;
}
return false;
}
}
public int size() {
synchronized(objectMutex) {
return list.size();
}
}
public List<E> subList(int fromIndex, int toIndex) {
synchronized(objectMutex) {
return list.subList(fromIndex, toIndex);
}
}
public Object[] toArray() {
synchronized(objectMutex) {
return list.toArray();
}
}
public <T> T[] toArray(T[] a) {
synchronized(objectMutex) {
return list.toArray(a);
}
}
public int getUpdateCounter() {
synchronized(objectMutex) {
return updateCounter;
}
}
public Object getMutex() {
return objectMutex;
}
public byte[] getBytes() {
synchronized(objectMutex) {
byte[] objects = { };
int size = 0;
for (Object o : list) {
byte[] object = Baseline.toBytes(o);
size += object.length;
IoBuffer buffer = Baseline.createBuffer(size);
buffer.put(objects);
if (addByte) buffer.put((byte) 0);
buffer.put(object);
buffer.flip();
objects = buffer.array();
}
IoBuffer buffer = Baseline.createBuffer(8 + size);
buffer.putInt(list.size());
buffer.putInt(updateCounter);
buffer.put(objects);
buffer.flip();
return buffer.array();
}
}
private boolean valid(Object o) {
if (o instanceof String || o instanceof Byte || o instanceof Short ||
o instanceof Integer || o instanceof Float || o instanceof Long ||
o instanceof IDelta) {
return true;
} else {
return false;
}
}
private byte[] item(int type, int index, byte[] data, boolean useIndex, boolean useData) {
int size = 1 + ((useIndex) ? 2 : 0) + ((useData) ? data.length : 0);
IoBuffer buffer = IoBuffer.allocate((size), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put((byte) type);
if (useIndex) buffer.putShort((short) index);
if (useData) buffer.put(data);
buffer.flip();
updateCounter++;
return buffer.array();
}
private void queue(byte[] data) {
IoBuffer buffer = IoBuffer.allocate((data.length + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(1);
buffer.putInt(updateCounter);
buffer.put(data);
buffer.flip();
object.sendListDelta(viewType, updateType, buffer);
}
private void queue(List<byte[]> data) {
int size = 0;
for (byte[] queued : data) {
size += queued.length;
}
IoBuffer buffer = IoBuffer.allocate((size + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(data.size());
buffer.putInt(updateCounter);
for (byte[] queued : data) buffer.put(queued);
buffer.flip();
object.sendListDelta(viewType, updateType, buffer);
}
}
+279
View File
@@ -0,0 +1,279 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.mina.core.buffer.IoBuffer;
import resources.objects.IDelta;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
/* A SWGMap element should extend Delta or implement IDelta */
@Persistent
public class SWGMap<K, V> implements Map<K, V> {
private Map<K, V> map = new TreeMap<K, V>();
@NotPersistent
private int updateCounter = 0;
private BaseObject object;
private byte viewType;
private short updateType;
private boolean addByte;
@NotPersistent
protected final Object objectMutex = new Object();
public SWGMap() { }
public SWGMap(BaseObject object, int viewType, int updateType, boolean addByte) {
this.object = object;
this.viewType = (byte) viewType;
this.updateType = (short) updateType;
this.addByte = addByte;
}
public SWGMap(Map<K, V> m) {
if (m instanceof SWGMap) {
this.object = ((SWGMap<K, V>) m).object;
this.viewType = ((SWGMap<K, V>) m).viewType;
this.updateType = ((SWGMap<K, V>) m).updateType;
map.putAll(m);
}
}
public void clear() {
throw new UnsupportedOperationException();
}
public boolean containsKey(Object key) {
synchronized(objectMutex) {
return map.containsKey(key);
}
}
public boolean containsValue(Object value) {
synchronized(objectMutex) {
return map.containsValue(value);
}
}
public Set<java.util.Map.Entry<K, V>> entrySet() {
synchronized(objectMutex) {
return map.entrySet();
}
}
public V get(Object key) {
return map.get(key);
}
public boolean isEmpty() {
synchronized(objectMutex) {
return map.isEmpty();
}
}
public Set<K> keySet() {
synchronized(objectMutex) {
return map.keySet();
}
}
public V put(K key, V value) {
synchronized(objectMutex) {
if (valid(key) && valid(value)) {
if (map.containsKey(key)) {
V oldValue = map.put(key, value);
queue(item(2, key, Baseline.toBytes(value), true, true));
return oldValue;
} else {
V oldValue = map.put(key, value);
queue(item(0, key, Baseline.toBytes(value), true, true));
return oldValue;
}
}
return null;
}
}
public void putAll(Map<? extends K, ? extends V> m) {
synchronized(objectMutex) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (Entry<? extends K, ? extends V> entry : m.entrySet()) {
K key = entry.getKey();
V value = entry.getValue();
if (valid(key) && valid(value)) {
if (map.containsKey(key)) {
if (map.put(key, value) != null) {
buffer.add(item(2, key, Baseline.toBytes(value), true, true));
}
} else {
if (map.put(key, value) != null) {
buffer.add(item(0, key, Baseline.toBytes(value), true, true));
}
}
}
}
if (buffer.size() > 0) {
queue(buffer);
}
}
}
public V remove(Object key) {
synchronized(objectMutex) {
if (valid(key)) {
V value = map.remove(key);
queue(item(1, key, Baseline.toBytes(map.get(key)), true, true));
return value;
}
return null;
}
}
public int size() {
synchronized(objectMutex) {
return map.size();
}
}
public Collection<V> values() {
synchronized(objectMutex) {
return map.values();
}
}
public int getUpdateCounter() {
synchronized(objectMutex) {
return updateCounter;
}
}
public Object getMutex() {
return objectMutex;
}
public byte[] getBytes() {
synchronized(objectMutex) {
byte[] objects = { };
int size = 0;
for (Entry<?, ?> entry : map.entrySet()) {
byte[] key = Baseline.toBytes(entry.getKey());
byte[] value = Baseline.toBytes(entry.getValue());
size += ((addByte) ? 1 : 0) + key.length + value.length;
IoBuffer buffer = Baseline.createBuffer(size);
buffer.put(objects);
if (addByte) buffer.put((byte) 0);
buffer.put(key);
buffer.put(value);
buffer.flip();
objects = buffer.array();
}
IoBuffer buffer = Baseline.createBuffer(8 + size);
buffer.putInt(map.size());
buffer.putInt(updateCounter);
buffer.put(objects);
buffer.flip();
return buffer.array();
}
}
private boolean valid(Object o) {
if (o instanceof String || o instanceof Byte || o instanceof Short ||
o instanceof Integer || o instanceof Float || o instanceof Long ||
o instanceof IDelta) {
return true;
} else {
return false;
}
}
private byte[] item(int type, Object index, byte[] data, boolean useIndex, boolean useData) {
if (useIndex && ((index instanceof IDelta) || !valid(index))) {
throw new IllegalArgumentException();
}
int size = 1 + ((useIndex) ? (2 + Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0);
IoBuffer buffer = IoBuffer.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put((byte) type);
if (useIndex) buffer.put(Baseline.toBytes(index));
if (useData) buffer.put(data);
buffer.flip();
updateCounter++;
return buffer.array();
}
private void queue(byte[] data) {
IoBuffer buffer = IoBuffer.allocate(data.length + 8, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(1);
buffer.putInt(updateCounter);
buffer.put(data);
buffer.flip();
object.sendListDelta(viewType, updateType, buffer);
}
private void queue(List<byte[]> data) {
int size = 0;
for (byte[] queued : data) {
size += queued.length;
}
IoBuffer buffer = IoBuffer.allocate((size + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(data.size());
buffer.putInt(updateCounter);
for (byte[] queued : data) buffer.put(queued);
buffer.flip();
object.sendListDelta(viewType, updateType, buffer);
}
}
@@ -0,0 +1,382 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import org.apache.mina.core.buffer.IoBuffer;
import org.python.google.common.collect.ArrayListMultimap;
import org.python.google.common.collect.Multimap;
import org.python.google.common.collect.Multiset;
import org.python.google.common.collect.Ordering;
import org.python.google.common.collect.TreeMultimap;
import resources.common.StringUtilities;
import resources.objects.IDelta;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
@SuppressWarnings("unused")
@Persistent
public class SWGMultiMap<K, V> implements Multimap<K, V> {
private Multimap<K, V> map = ArrayListMultimap.create();
@NotPersistent
private int updateCounter = 0;
private BaseObject object;
private byte viewType;
private short updateType;
private boolean addByte;
@NotPersistent
protected final Object objectMutex = new Object();
public SWGMultiMap() { }
public SWGMultiMap(BaseObject object, int viewType, int updateType, boolean addByte) {
this.object = object;
this.viewType = (byte) viewType;
this.updateType = (short) updateType;
this.addByte = addByte;
}
public SWGMultiMap(Multimap<K, V> m) {
if (m instanceof SWGMultiMap) {
this.object = ((SWGMultiMap<K, V>) m).object;
this.viewType = ((SWGMultiMap<K, V>) m).viewType;
this.updateType = ((SWGMultiMap<K, V>) m).updateType;
map.putAll(m);
}
}
public Map<K, Collection<V>> asMap() {
synchronized(objectMutex) {
return map.asMap();
}
}
public void clear() {
throw new UnsupportedOperationException();
}
public boolean containsEntry(Object key, Object value) {
synchronized(objectMutex) {
return map.containsEntry(key, value);
}
}
public boolean containsKey(Object key) {
synchronized(objectMutex) {
return map.containsKey(key);
}
}
public boolean containsValue(Object value) {
synchronized(objectMutex) {
return map.containsValue(value);
}
}
public Collection<Entry<K, V>> entries() {
synchronized(objectMutex) {
return map.entries();
}
}
public Collection<V> get(K key) {
synchronized(objectMutex) {
return map.get(key);
}
}
public boolean isEmpty() {
synchronized(objectMutex) {
return map.isEmpty();
}
}
public Multiset<K> keys() {
synchronized(objectMutex) {
return map.keys();
}
}
public Set<K> keySet() {
synchronized(objectMutex) {
return map.keySet();
}
}
public boolean put(K key, V value) {
synchronized(objectMutex) {
if (key instanceof String || key instanceof Byte || key instanceof Short ||
key instanceof Integer || key instanceof Float || key instanceof Long ||
value instanceof IDelta) {
if (map.put(key, value)) {
queue(item(0, (String) key, ((IDelta) value).getBytes(), true, true));
return true;
}
}
return false;
}
}
public boolean putAll(K key, Iterable<? extends V> values) {
synchronized(objectMutex) {
if (key instanceof String || key instanceof Byte || key instanceof Short ||
key instanceof Integer || key instanceof Float || key instanceof Long) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (V value : values) {
if (value instanceof IDelta) {
if (map.put(key, value)) {
buffer.add(item(0, (String) key, ((IDelta) value).getBytes(), true, true));
}
}
}
if (buffer.size() > 0) {
queue(buffer);
return true;
}
}
return false;
}
}
public boolean putAll(Multimap<? extends K, ? extends V> map) {
synchronized(objectMutex) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (Entry<? extends K, ? extends V> entry : map.entries()) {
K key = entry.getKey();
V value = entry.getValue();
if (key instanceof String || key instanceof Byte || key instanceof Short ||
key instanceof Integer || key instanceof Float || key instanceof Long ||
value instanceof IDelta) {
if (this.map.put(key, value)) {
buffer.add(item(0, (String) key, ((IDelta) value).getBytes(), true, true));
}
}
}
if (buffer.size() > 0) {
queue(buffer);
return true;
}
return false;
}
}
@SuppressWarnings("unchecked")
public boolean remove(Object key, Object value) {
synchronized(objectMutex) {
if (key instanceof String || key instanceof Byte || key instanceof Short ||
key instanceof Integer || key instanceof Float || key instanceof Long) {
if (map.remove(key, value)) {
queue(item(1, (String) key, ((IDelta) map.get((K) key)).getBytes(), true, true));
return true;
}
}
return false;
}
}
@SuppressWarnings("unchecked")
public Collection<V> removeAll(Object key) {
synchronized(objectMutex) {
if (key instanceof String || key instanceof Byte || key instanceof Short ||
key instanceof Integer || key instanceof Float || key instanceof Long) {
Collection<V> collection = map.get((K) key);
List<byte[]> buffer = new ArrayList<byte[]>();
for (V value : map.get((K) key)) {
if (map.remove(key, value)) {
buffer.add(item(1, (String) key, ((IDelta) map.get((K) key)).getBytes(), true, true));
}
}
if (buffer.size() > 0) {
queue(buffer);
return collection;
}
}
return null;
}
}
public Collection<V> replaceValues(K key, Iterable<? extends V> values) {
synchronized(objectMutex) {
if (key instanceof String || key instanceof Byte || key instanceof Short ||
key instanceof Integer || key instanceof Float || key instanceof Long) {
if (map.containsKey(key)) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (V value : values) {
if (value instanceof IDelta) {
if (!map.get(key).contains(value)) {
buffer.add(item(2, (String) key, ((IDelta) value).getBytes(), true, true));
}
} else {
return null;
}
}
if (buffer.size() > 0) {
queue(buffer);
return map.replaceValues(key, values);
}
}
}
return null;
}
}
public int size() {
synchronized(objectMutex) {
return map.size();
}
}
public Collection<V> values() {
synchronized(objectMutex) {
return map.values();
}
}
public int getUpdateCounter() {
synchronized(objectMutex) {
return updateCounter;
}
}
public Object getMutex() {
return objectMutex;
}
public byte[] getBytes() {
synchronized(objectMutex) {
byte[] objects = { };
int size = 0;
for (Entry<?, ?> entry : map.entries()) {
byte[] key = Baseline.toBytes(entry.getKey());
byte[] value = Baseline.toBytes(entry.getValue());
size += ((addByte) ? 1 : 0) + key.length + value.length;
IoBuffer buffer = Baseline.createBuffer(size);
buffer.put(objects);
if (addByte) buffer.put((byte) 0);
buffer.put(key);
buffer.put(value);
buffer.flip();
objects = buffer.array();
}
IoBuffer buffer = Baseline.createBuffer(8 + size);
buffer.putInt(map.size());
buffer.putInt(updateCounter);
buffer.put(objects);
buffer.flip();
return buffer.array();
}
}
private byte[] item(int type, Object index, byte[] data, boolean useIndex, boolean useData) {
if (useIndex && !(index instanceof Byte) && !(index instanceof Short)
&& !(index instanceof Integer) && !(index instanceof Float)
&& !(index instanceof Long) && !(index instanceof String)) {
throw new IllegalArgumentException();
}
int size = 1 + ((useIndex) ? (2 + index.toString().getBytes().length) : 0) + ((useData) ? data.length : 0);
IoBuffer buffer = IoBuffer.allocate((size), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put((byte) type);
if (useIndex) {
if (index instanceof String) {
buffer.put(StringUtilities.getAsciiString((String) index));
} else if (index instanceof Byte) {
buffer.put(((Byte) index).byteValue());
} else if (index instanceof Short) {
buffer.putShort(((Short) index).shortValue());
} else if (index instanceof Integer) {
buffer.putInt(((Integer) index).intValue());
} else if (index instanceof Float) {
buffer.putFloat(((Float) index).floatValue());
} else if (index instanceof Long) {
buffer.putLong(((Long) index).longValue());
} else {
throw new IllegalArgumentException();
}
}
if (useData) buffer.put(data);
updateCounter++;
return buffer.array();
}
private void queue(byte[] data) {
IoBuffer buffer = IoBuffer.allocate((data.length + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(1);
buffer.putInt(updateCounter);
buffer.put(data);
object.sendListDelta(viewType, updateType, buffer);
}
private void queue(List<byte[]> data) {
int size = 0;
for (byte[] queued : data) {
size += queued.length;
}
IoBuffer buffer = IoBuffer.allocate((size + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(data.size());
buffer.putInt(updateCounter);
for (byte[] queued : data) buffer.put(queued);
object.sendListDelta(viewType, updateType, buffer);
}
}
+280
View File
@@ -0,0 +1,280 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.apache.mina.core.buffer.IoBuffer;
import resources.objects.IDelta;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
/* A SWGSet element should extend Delta or implement IDelta */
@Persistent
public class SWGSet<E> implements Set<E> {
private TreeSet<E> set = new TreeSet<E>();
@NotPersistent
private int updateCounter = 0;
private BaseObject object;
private byte viewType;
private short updateType;
private boolean addByte;
@NotPersistent
protected final Object objectMutex = new Object();
public SWGSet() { }
public SWGSet(BaseObject object, int viewType, int updateType, boolean addByte) {
this.object = object;
this.viewType = (byte) viewType;
this.updateType = (short) updateType;
this.addByte = addByte;
}
public SWGSet(Set<E> s) {
if (s instanceof SWGSet) {
this.object = ((SWGSet<E>) s).object;
this.viewType = ((SWGSet<E>) s).viewType;
this.updateType = ((SWGSet<E>) s).updateType;
set.addAll(s);
}
}
public boolean add(E e) {
synchronized(objectMutex) {
if (valid(e)) {
if (set.add(e)) {
queue(item(1, e, null, true, false));
return true;
}
}
return false;
}
}
public boolean addAll(Collection<? extends E> c) {
synchronized(objectMutex) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (E e : c) {
if (valid(e) && set.add(e)) {
buffer.add(item(1, e, null, true, false));
}
}
if (buffer.size() > 0) {
queue(buffer);
return true;
} else {
return false;
}
}
}
public void clear() {
synchronized(objectMutex) {
queue(item(2, null, null, false, false));
}
}
public boolean contains(Object o) {
synchronized(objectMutex) {
return set.contains(o);
}
}
public boolean containsAll(Collection<?> c) {
synchronized(objectMutex) {
return set.containsAll(c);
}
}
public boolean isEmpty() {
synchronized(objectMutex) {
return set.isEmpty();
}
}
public Iterator<E> iterator() {
synchronized(objectMutex) {
return set.iterator();
}
}
public boolean remove(Object e) {
synchronized(objectMutex) {
if (valid(e) && set.remove(e)) {
queue(item(0, e, null, true, false));
return true;
}
return false;
}
}
public boolean removeAll(Collection<?> c) {
synchronized(objectMutex) {
List<byte[]> buffer = new ArrayList<byte[]>();
for (Object o : c) {
if (valid(o) && set.remove(o)) {
buffer.add(item(0, o, null, true, false));
}
}
if (buffer.size() > 0) {
queue(buffer);
return true;
} else {
return false;
}
}
}
public boolean retainAll(Collection<?> c) {
synchronized(objectMutex) {
return set.retainAll(c);
}
}
public int size() {
synchronized(objectMutex) {
return set.size();
}
}
public Object[] toArray() {
synchronized(objectMutex) {
return set.toArray();
}
}
public <T> T[] toArray(T[] a) {
synchronized(objectMutex) {
return set.toArray(a);
}
}
public int getUpdateCounter() {
synchronized(objectMutex) {
return updateCounter;
}
}
public Object getMutex() {
return objectMutex;
}
public byte[] getBytes() {
synchronized(objectMutex) {
byte[] objects = { };
int size = 0;
for (Object o : set) {
byte[] object = Baseline.toBytes(o);
size += object.length;
IoBuffer buffer = Baseline.createBuffer(size);
buffer.put(objects);
if (addByte) buffer.put((byte) 0);
buffer.put(object);
buffer.flip();
objects = buffer.array();
}
IoBuffer buffer = Baseline.createBuffer(8 + size);
buffer.putInt(set.size());
buffer.putInt(updateCounter);
buffer.put(objects);
buffer.flip();
return buffer.array();
}
}
private boolean valid(Object o) {
if (o instanceof String || o instanceof Byte || o instanceof Short ||
o instanceof Integer || o instanceof Float || o instanceof Long ||
o instanceof IDelta) {
return true;
} else {
return false;
}
}
private byte[] item(int type, Object index, byte[] data, boolean useIndex, boolean useData) {
if (useIndex && ((index instanceof IDelta) || !valid(index))) {
throw new IllegalArgumentException();
}
int size = 1 + ((useIndex) ? (2 + Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0);
IoBuffer buffer = IoBuffer.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
buffer.put((byte) type);
if (useIndex) buffer.put(Baseline.toBytes(index));
if (useData) buffer.put(data);
buffer.flip();
updateCounter++;
return buffer.array();
}
private void queue(byte[] data) {
IoBuffer buffer = IoBuffer.allocate((data.length + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(1);
buffer.putInt(updateCounter);
buffer.put(data);
buffer.flip();
object.sendListDelta(viewType, updateType, buffer);
}
private void queue(List<byte[]> data) {
int size = 0;
for (byte[] queued : data) {
size += queued.length;
}
IoBuffer buffer = IoBuffer.allocate((size + 8), false).order(ByteOrder.LITTLE_ENDIAN);
buffer.putInt(data.size());
buffer.putInt(updateCounter);
for (byte[] queued : data) buffer.put(queued);
buffer.flip();
object.sendListDelta(viewType, updateType, buffer);
}
}
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.building;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.tangible.TangibleMessageBuilder;
public class BuildingMessageBuilder extends TangibleMessageBuilder {
public BuildingMessageBuilder(BuildingObject object) {
super(object);
}
public BuildingMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(deltaBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(deltaBuilders, deltaBuilders);
}
}
@@ -0,0 +1,102 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.building;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.tangible.TangibleObject;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.NotPersistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Entity
public class BuildingObject extends TangibleObject {
@NotPersistent
private BuildingMessageBuilder messageBuilder;
public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
setVolume(255);
setOptionsBitmask(256);
setMaximumCondition(4320);
toggleStatic();
}
public BuildingObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
return baseline;
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, false);
}
@Override
public BuildingMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new BuildingMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
}
}
}
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.cell;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.ObjectMessageBuilder;
public class CellMessageBuilder extends ObjectMessageBuilder {
public CellMessageBuilder(CellObject object) {
super(object);
}
public CellMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,137 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.cell;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class CellObject extends BaseObject {
@NotPersistent
CellMessageBuilder messageBuilder;
public CellObject(long objectID, Planet planet, int cellNumber) {
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/cell/shared_cell.iff");
setCellNumber(cellNumber);
}
public CellObject(long objectID, Planet planet) {
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/cell/shared_cell.iff");
}
public CellObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
initializeBaseline(8);
initializeBaseline(9);
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("4", (byte) 1); // Unknown
baseline.put("cellNumber", 0);
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("2", (long) 0); // Unknown
baseline.put("3", (long) 0); // Unknown
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
return baseline;
}
public int getCellNumber() {
return (int) baseline3.get("cellNumber");
}
public void setCellNumber(int cellNumber) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("cellNumber", cellNumber);
}
getContainer().notifyObservers(buffer, false);
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
getContainer().notifyObservers(buffer, false);
}
@Override
public CellMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new CellMessageBuilder();
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
//destination.getSession().write(baseline8.getBaseline());
//destination.getSession().write(baseline9.getBaseline());
}
}
}
@@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.creature;
import java.util.Map;
import com.sleepycat.persist.model.Persistent;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.tangible.TangibleMessageBuilder;
@Persistent
public class CreatureMessageBuilder extends TangibleMessageBuilder {
public CreatureMessageBuilder(CreatureObject creatureObject) {
super(creatureObject);
}
public CreatureMessageBuilder() {
super();
}
@Override
public void buildBaseline1(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline1(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline4(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline4(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.factorycrate;
public class FactoryCrateMessageBuilder {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.factorycrate;
public class FactoryCrateObject {
}
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.group;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.universe.UniverseMessageBuilder;
public class GroupMessageBuilder extends UniverseMessageBuilder {
public GroupMessageBuilder(GroupObject groupObject) {
super(groupObject);
}
public GroupMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,256 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.group;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.NotPersistent;
import resources.z.exp.group.Member;
import resources.z.exp.group.MemberInfo;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.SWGList;
import resources.z.exp.objects.creature.CreatureObject;
import resources.z.exp.objects.universe.UniverseObject;
import engine.clients.Client;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
public class GroupObject extends UniverseObject {
@NotPersistent
private GroupMessageBuilder messageBuilder;
public GroupObject(long objectId) {
super(objectId, null, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/group/shared_group_object.iff");
}
public GroupObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("memberList", new SWGList<Member>(this, 6, 2, false));
baseline.put("memberInfoList", new SWGList<MemberInfo>(this, 6, 3, false));
baseline.put("4", "");
baseline.put("groupLevel", (short) 0);
baseline.put("6", 0);
baseline.put("groupLeader", null);
baseline.put("lootMaster", null);
baseline.put("lootMode", 0);
return baseline;
}
@SuppressWarnings("unchecked")
public SWGList<Member> getMemberList() {
return (SWGList<Member>) baseline6.get("memberList");
}
@SuppressWarnings("unchecked")
public SWGList<MemberInfo> getMemberInfoList() {
return (SWGList<MemberInfo>) baseline6.get("memberInfoList");
}
public void addMember(SWGObject member) {
if (member instanceof CreatureObject && member.getClient() != null) {
SWGList<Member> memberList = getMemberList();
SWGList<MemberInfo> memberInfoList = getMemberInfoList();
if (memberList.size() >= 8) {
((CreatureObject) member).sendSystemMessage("@group:join_full", (byte) 0);
} else {
Member newMember = new Member(member);
if (memberList.add(newMember)) {
memberInfoList.add(new MemberInfo(memberList.indexOf(newMember), 0));
if (((CreatureObject) member).getLevel() > getGroupLevel()) {
setGroupLevel(((CreatureObject) member).getLevel());
}
}
}
}
}
public void removeMember(SWGObject member) {
if (member instanceof CreatureObject && member.getClient() != null) {
SWGList<Member> memberList = getMemberList();
SWGList<MemberInfo> memberInfoList = getMemberInfoList();
if (!(memberList.size() <= 0)) {
int index = memberList.indexOf(member);
if (memberList.remove(member)) {
memberInfoList.remove(index);
synchronized(objectMutex) {
for (int i = 0; i < memberInfoList.size(); i++) {
if (memberInfoList.get(i).getMemberId() != i) {
memberInfoList.set(i, memberInfoList.get(i).setMemberId(i));
}
}
}
}
short maxLevel = 0;
for (Member memberObject : getMemberList()) {
if (memberObject.getMember() instanceof CreatureObject) {
CreatureObject creature = (CreatureObject) memberObject.getMember();
if (creature.getLevel() > maxLevel) {
maxLevel = creature.getLevel();
}
}
}
if (maxLevel != getGroupLevel()) {
setGroupLevel(maxLevel);
}
}
}
}
public boolean setMemberInfo(SWGObject object, long info) {
if (object instanceof CreatureObject && object.getClient() != null) {
for (Member member : getMemberList()) {
if (member.getMember().equals(member)) {
int id = getMemberList().indexOf(member);
getMemberInfoList().set(id, new MemberInfo(info, id));
return true;
}
}
}
return false;
}
public short getGroupLevel() {
synchronized(objectMutex) {
return (short) baseline6.get("groupLevel");
}
}
public void setGroupLevel(short groupLevel) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("groupLevel", groupLevel);
}
notifyObservers(buffer, false);
}
public SWGObject getGroupLeader() {
synchronized(objectMutex) {
return (SWGObject) baseline6.get("groupLeader");
}
}
public void setGroupLeader(SWGObject groupLeader) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("groupLeader", groupLeader);
}
notifyObservers(buffer, false);
}
public SWGObject getLootMaster() {
synchronized(objectMutex) {
return (SWGObject) baseline6.get("lootMaster");
}
}
public void setLootMaster(SWGObject lootMaster) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("lootMaster", lootMaster);
}
notifyObservers(buffer, false);
}
public int getLootMode() {
synchronized(objectMutex) {
return (int) baseline6.get("lootMode");
}
}
public void setLootMode(int lootMode) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("lootMode", lootMode);
}
notifyObservers(buffer, false);
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, false);
}
@Override
public GroupMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new GroupMessageBuilder();
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
destination.getSession().write(baseline3.getBaseline());
destination.getSession().write(baseline6.getBaseline());
}
}
}
@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.guild;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.universe.UniverseMessageBuilder;
public class GuildMessageBuilder extends UniverseMessageBuilder {
public GuildMessageBuilder(GuildObject guildObject) {
super(guildObject);
}
public GuildMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,192 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.guild;
import java.util.Map;
import java.util.TreeMap;
import org.apache.mina.core.buffer.IoBuffer;
import resources.gcw.CurrentServerGCWZoneHistory;
import resources.gcw.CurrentServerGCWZonePercent;
import resources.gcw.OtherServerGCWZonePercent;
import resources.z.exp.guild.Guild;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.SWGList;
import resources.z.exp.objects.SWGMap;
import resources.z.exp.objects.SWGMultiMap;
import resources.z.exp.objects.universe.UniverseObject;
import com.sleepycat.je.Environment;
import com.sleepycat.je.Transaction;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.NotPersistent;
import engine.clients.Client;
import engine.resources.objects.IPersistent;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Entity
public class GuildObject extends UniverseObject implements IPersistent {
@NotPersistent
private GuildMessageBuilder messageBuilder = new GuildMessageBuilder(this);
private Map<String, Map<String, CurrentServerGCWZonePercent>> zoneMap = new TreeMap<String, Map<String, CurrentServerGCWZonePercent>>();
@NotPersistent
private Transaction txn;
public GuildObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
}
public GuildObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
baseline.put("nextUpdateTime", 1321383613);
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("guildList", new SWGList<Guild>(this, 3, 4, false));
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("currentServerGCWZonePercentMap", new SWGMap<String, CurrentServerGCWZonePercent>(this, 6, 2, true));
baseline.put("currentServerGCWTotalPercentMap", new SWGMap<String, CurrentServerGCWZonePercent>(this, 6, 3, true));
baseline.put("currentServerGCWZoneHistoryMap", new SWGMultiMap<String, CurrentServerGCWZoneHistory>(this, 6, 4, true));
baseline.put("currentServerGCWTotalHistoryMap", new SWGMultiMap<String, CurrentServerGCWZoneHistory>(this, 6, 5, true));
baseline.put("otherServerGCWZonePercentMap", new SWGMultiMap<String, OtherServerGCWZonePercent>(this, 6, 6, true));
baseline.put("otherServerGCWTotalPercentMap", new SWGMultiMap<String, OtherServerGCWZonePercent>(this, 6, 7, true));
baseline.put("8", 5);
return baseline;
}
@SuppressWarnings("unchecked")
public SWGList<Guild> getGuildList() {
return (SWGList<Guild>) baseline3.get("guildList");
}
@SuppressWarnings("unchecked")
public SWGMap<String, CurrentServerGCWZonePercent> getCurrentServerGCWZonePercentMap() {
return (SWGMap<String, CurrentServerGCWZonePercent>) baseline6.get("currentServerGCWZonePercentMap");
}
@SuppressWarnings("unchecked")
public SWGMap<String, CurrentServerGCWZonePercent> getCurrentServerGCWTotalPercentMap() {
return (SWGMap<String, CurrentServerGCWZonePercent>) baseline6.get("currentServerGCWTotalPercentMap");
}
@SuppressWarnings("unchecked")
public SWGMultiMap<String, CurrentServerGCWZoneHistory> getCurrentServerGCWZoneHistoryMap() {
return (SWGMultiMap<String, CurrentServerGCWZoneHistory>) baseline6.get("currentServerGCWZoneHistoryMap");
}
@SuppressWarnings("unchecked")
public SWGMultiMap<String, CurrentServerGCWZoneHistory> getCurrentServerGCWTotalHistoryMap() {
return (SWGMultiMap<String, CurrentServerGCWZoneHistory>) baseline6.get("currentServerGCWTotalHistoryMap");
}
@SuppressWarnings("unchecked")
public SWGMultiMap<String, OtherServerGCWZonePercent> getOtherServerGCWZonePercentMap() {
return (SWGMultiMap<String, OtherServerGCWZonePercent>) baseline6.get("otherServerGCWZonePercentMap");
}
@SuppressWarnings("unchecked")
public SWGMultiMap<String, OtherServerGCWZonePercent> getOtherServerGCWTotalPercentMap() {
return (SWGMultiMap<String, OtherServerGCWZonePercent>) baseline6.get("otherServerGCWTotalPercentMap");
}
public Map<String, Map<String, CurrentServerGCWZonePercent>> getZoneMap() {
synchronized(objectMutex) {
return zoneMap;
}
}
public int getNextUpdateTime() {
synchronized(objectMutex) {
return (int) otherVariables.get("nextUpdateTime");
}
}
public int setNextUpdateTime(long nextUpdateTime) {
synchronized(objectMutex) {
otherVariables.set("nextUpdateTime", (int) nextUpdateTime);
return getNextUpdateTime();
}
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, false);
}
@Override
public GuildMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new GuildMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
}
}
@Override
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
notifyClients(baseline6.createDelta(updateType, buffer.array()), false);
}
public Transaction getTransaction() {
return txn;
}
public void createTransaction(Environment env) {
txn = env.beginTransaction(null, null);
}
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.harvester;
public class HarvesterMessageBuilder {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.harvester;
public class HarvesterObject {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.installation;
public class InstallationMessageBuilder {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.installation;
public class InstallationObject {
}
@@ -0,0 +1,62 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.intangible;
import java.util.Map;
import com.sleepycat.persist.model.Persistent;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.ObjectMessageBuilder;
@Persistent
public class IntangibleMessageBuilder extends ObjectMessageBuilder {
public IntangibleMessageBuilder(IntangibleObject object) {
super(object);
}
public IntangibleMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,139 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.intangible;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class IntangibleObject extends BaseObject {
@NotPersistent
private IntangibleMessageBuilder messageBuilder;
public IntangibleObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
}
public IntangibleObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
initializeBaseline(8);
initializeBaseline(9);
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("genericInt", 0);
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
return baseline;
}
public int getGenericInt() {
synchronized(objectMutex) {
return (int) baseline3.get("genericInt");
}
}
public void setGenericInt(int genericInt) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("genericInt", genericInt);
}
notifyClients(buffer, true);
}
public void incrementGenericInt(int increase) {
setGenericInt((getGenericInt() + increase));
}
public void decrementGenericInt(int decrease) {
setGenericInt((((getGenericInt() - decrease) < 1) ? 0 : (getGenericInt() - decrease)));
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, notifySelf);
}
@Override
public IntangibleMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new IntangibleMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
//destination.getSession().write(baseline8.getBaseline());
//destination.getSession().write(baseline9.getBaseline());
}
}
}
@@ -0,0 +1,64 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.manufacture;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.intangible.IntangibleMessageBuilder;
public class ManufactureSchematicMessageBuilder extends IntangibleMessageBuilder {
public ManufactureSchematicMessageBuilder(ManufactureSchematicObject object) {
super(object);
}
public ManufactureSchematicMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline7(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline7(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,603 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.manufacture;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
import resources.z.exp.manufacture.Property;
import resources.z.exp.manufacture.SubList;
import resources.z.exp.manufacture.TableAndKey;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.SWGList;
import resources.z.exp.objects.SWGMultiMap;
import resources.z.exp.objects.intangible.IntangibleObject;
@Persistent
public class ManufactureSchematicObject extends IntangibleObject {
@NotPersistent
private ManufactureSchematicMessageBuilder messageBuilder;
public ManufactureSchematicObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
initializeBaseline(7);
}
public ManufactureSchematicObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
baseline.put("totalSlots", (byte) 0);
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("properties", new SWGMultiMap<String, Property>(this, 3, 5, true));
baseline.put("schematicComplexity", 0);
baseline.put("schematicDataSize", (float) 1);
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("schematicCustomization", new byte[] { });
baseline.put("customizationTemplate", "");
baseline.put("schematicPrototype", "");
baseline.put("inUse", false);
baseline.put("filledSlots", (byte) 0);
return baseline;
}
@Override
public Baseline getBaseline7() {
Baseline baseline = super.getBaseline7();
baseline.put("slotNameList", new SWGList<TableAndKey>(this, 7, 0, false));
baseline.put("slotContentsList", new SWGList<Integer>(this, 7, 1, false));
baseline.put("ingredientList", new SWGList<SubList<Long>>(this, 7, 2, false));
baseline.put("quantityList", new SWGList<SubList<Integer>>(this, 7, 3, false));
baseline.put("qualityList", new SWGList<Float>(this, 7, 4, false));
baseline.put("cleanSlotList", new SWGList<Integer>(this, 7, 5, false));
baseline.put("slotIndexList", new SWGList<Integer>(this, 7, 6, false));
baseline.put("ingredientsCounter", (byte) 0);
baseline.put("experimentationNameList", new SWGList<TableAndKey>(this, 7, 8, false));
baseline.put("currentExperimentationValueList", new SWGList<Float>(this, 7, 9, false));
baseline.put("experimentationOffsetList", new SWGList<Float>(this, 7, 10, false));
baseline.put("bluebarList", new SWGList<Float>(this, 7, 11, false));
baseline.put("maxExperimentationList", new SWGList<Float>(this, 7, 12, false));
baseline.put("customizationNameList", new SWGList<String>(this, 7, 13, false));
baseline.put("palleteSelectionList", new SWGList<Integer>(this, 7, 14, false));
baseline.put("palleteStartIndexList", new SWGList<Integer>(this, 7, 15, false));
baseline.put("palleteEndIndexList", new SWGList<Integer>(this, 7, 16, false));
baseline.put("customizationCounter", (byte) 0);
baseline.put("riskFactor", (float) 0);
baseline.put("objectTemplateCustomizationList", new SWGList<String>(this, 7, 19, false));
baseline.put("ready", true);
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
return baseline;
}
public void setQuantity(int quantity) {
setGenericInt(quantity);
}
public void incrementQuantity(int increase) {
incrementGenericInt(increase);
}
public void decrementQuantity(int decrease) {
decrementGenericInt(decrease);
}
@SuppressWarnings("unchecked")
public SWGMultiMap<String, Property> getPropertiesMap() {
return (SWGMultiMap<String, Property>) baseline3.get("properties");
}
public Collection<Property> getPropertiesForFile(String stfFile) {
synchronized(objectMutex) {
if (getPropertiesMap().containsKey(stfFile)) {
return getPropertiesMap().get(stfFile);
} else {
return new ArrayList<Property>();
}
}
}
public Collection<Property> getAllProperties() {
synchronized(objectMutex) {
return getPropertiesMap().values();
}
}
public boolean containsKey(String stfFile, String key) {
synchronized(objectMutex) {
for (Property property : getPropertiesMap().get(stfFile)) {
if (property.getKey().equals(key)) {
return true;
}
}
return false;
}
}
public boolean containsKey(String key) {
synchronized(objectMutex) {
for (Property property : getPropertiesMap().values()) {
if (property.getKey().equals(key)) {
return true;
}
}
return false;
}
}
public Property getProperty(String stfFile, String key) {
synchronized(objectMutex) {
for (Property property: getPropertiesMap().get(stfFile)) {
if (property.getKey().equals(key)) {
return property;
}
}
return null;
}
}
public Property getProperty(String key) {
synchronized(objectMutex) {
for (Property property: getPropertiesMap().values()) {
if (property.getKey().equals(key)) {
return property;
}
}
return null;
}
}
public void addProperty(String stfFile, String key, float value) {
if (!containsKey(stfFile, key)) {
getPropertiesMap().put(stfFile, new Property(key, value));
}
}
public void setProperty(String stfFile, String key, float value) {
if (getPropertiesMap().containsKey(stfFile)) {
for (Property property : getPropertiesMap().get(stfFile)) {
if (property.getKey().equals(key)) {
property.setValue(value);
getPropertiesMap().replaceValues(stfFile, getPropertiesMap().get(stfFile));
return;
}
}
}
}
public void removeProperty(String stfFile, String key) {
if (containsKey(stfFile, key)) {
getPropertiesMap().remove(stfFile, getProperty(key));
}
}
public void removeFile(String stfFile) {
getPropertiesMap().removeAll(stfFile);
}
public int getSchematicComplexity() {
synchronized(objectMutex) {
return (int) baseline3.get("schematicComplexity");
}
}
public void setSchematicComplexity(int schematicComplexity) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("schematicComplexity", schematicComplexity);
}
notifyClients(buffer, false);
}
public float getSchematicDataSize() {
synchronized(objectMutex) {
return (float) baseline3.get("schematicDataSize");
}
}
public void setSchematicDataSize(float schematicDataSize) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("schematicDataSize", schematicDataSize);
}
notifyClients(buffer, false);
}
public byte[] getSchematicCustomization() {
synchronized(objectMutex) {
return (byte[]) baseline6.get("schematicCustomization");
}
}
public void setSchematicCustomization(byte[] schematicCustomization) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("schematicCustomization", schematicCustomization);
}
notifyClients(buffer, false);
}
public String getCustomizationTemplate() {
synchronized(objectMutex) {
return (String) baseline6.get("customizationTemplate");
}
}
public void setCustomizationTemplate(String customizationTemplate) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("customizationTemplate", customizationTemplate);
}
notifyClients(buffer, false);
}
public String getSchematicTemplate() {
synchronized(objectMutex) {
return (String) baseline6.get("schematicTemplate");
}
}
public void setSchematicTemplate(String schematicTemplate) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("schematicTemplate", schematicTemplate);
}
notifyClients(buffer, false);
}
public boolean inUse() {
synchronized(objectMutex) {
return (boolean) baseline6.get("inUse");
}
}
public void setInUse(boolean inUse) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("inUse", inUse);
}
notifyClients(buffer, false);
}
public void toggleInUse() {
setInUse(!inUse());
}
public byte getTotalSlots() {
synchronized(objectMutex) {
return (byte) otherVariables.get("totalSlots");
}
}
public void setTotalSlots(byte totalSlots) {
synchronized(objectMutex) {
otherVariables.set("totalSlots", totalSlots);
}
}
public byte getFilledSlots() {
synchronized(objectMutex) {
return (byte) baseline6.get("filledSlots");
}
}
public void setFilledSlots(byte filledSlots) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("filledSlots", filledSlots);
}
notifyClients(buffer, false);
}
public void incrementFilledSlots(int increase) {
setFilledSlots(((byte) (getFilledSlots() + ((byte) increase))));
}
public void decrementFilledSlots(int decrease) {
setFilledSlots(((byte) (((getFilledSlots() - ((byte) decrease)) < 0) ? ((byte) 0) : (getFilledSlots() - ((byte) decrease)))));
}
@SuppressWarnings("unchecked")
public SWGList<TableAndKey> getSlotNameList() {
return (SWGList<TableAndKey>) baseline7.get("slotNameList");
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getSlotContentsList() {
return (SWGList<Integer>) baseline7.get("slotContentsList");
}
@SuppressWarnings("unchecked")
public SWGList<SubList<Long>> getIngredientList() {
return (SWGList<SubList<Long>>) baseline7.get("ingredientList");
}
@SuppressWarnings("unchecked")
public SWGList<SubList<Integer>> getQuantityList() {
return (SWGList<SubList<Integer>>) baseline7.get("quantityList");
}
@SuppressWarnings("unchecked")
public SWGList<Float> getQualityList() {
return (SWGList<Float>) baseline7.get("quantityList");
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getCleanSlotList() {
return (SWGList<Integer>) baseline7.get("cleanSlotList");
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getSlotIndexList() {
return (SWGList<Integer>) baseline7.get("slotIndexList");
}
public byte getIngredientsCounter() {
return (byte) baseline7.get("ingredientsCounter");
}
public void setIngredientsCounter(byte ingredientsCounter) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline7.set("ingredientsCounter", ingredientsCounter);
}
if (getGrandparent().getClient() != null) {
getGrandparent().getClient().getSession().write(buffer);
}
}
public void incrementIngredientsCounter(int increase) {
setIngredientsCounter((byte) (getIngredientsCounter() + ((byte) increase)));
}
public void decrementIngredientsCoutner(int decrease) {
byte ingredientsCounter = getIngredientsCounter();
setIngredientsCounter(((ingredientsCounter < 0) ? 0 : ((byte) (ingredientsCounter - ((byte) decrease)))));
}
@SuppressWarnings("unchecked")
public SWGList<TableAndKey> getExperimentationNameList() {
return (SWGList<TableAndKey>) baseline7.get("experimentationNameList");
}
@SuppressWarnings("unchecked")
public SWGList<Float> getCurrentExperimentationValueList() {
return (SWGList<Float>) baseline7.get("currentExperimentationValueList");
}
@SuppressWarnings("unchecked")
public SWGList<Float> getExperimentationOffsetList() {
return (SWGList<Float>) baseline7.get("experimentationOffsetList");
}
@SuppressWarnings("unchecked")
public SWGList<Float> getBlueBarList() {
return (SWGList<Float>) baseline7.get("blueBarList");
}
@SuppressWarnings("unchecked")
public SWGList<Float> getMaxExperimentationList() {
return (SWGList<Float>) baseline7.get("maxExperimentationList");
}
@SuppressWarnings("unchecked")
public SWGList<String> getCustomizationNameList() {
return (SWGList<String>) baseline7.get("customizationNameList");
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getPalleteSelectionList() {
return (SWGList<Integer>) baseline7.get("palleteSelectionList");
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getPalleteStartIndexList() {
return (SWGList<Integer>) baseline7.get("palleteStartIndexList");
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getPalleteEndIndexList() {
return (SWGList<Integer>) baseline7.get("palleteEndIndexList");
}
public byte getCustomizationCounter() {
synchronized(objectMutex) {
return (byte) baseline7.get("customizationCounter");
}
}
public void setCustomizationCounter(byte customizationCounter) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline7.set("customizationCounter", customizationCounter);
}
if (getGrandparent().getClient() != null) {
getGrandparent().getClient().getSession().write(buffer);
}
}
public void incrementCustomizationCounter(int increase) {
}
public void decrementCustomizationCounter(int decrease) {
}
public float getRiskFactor() {
synchronized(objectMutex) {
return (float) baseline7.get("riskFactor");
}
}
public void setRiskFactor(float riskFactor) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline7.set("riskFactor", riskFactor);
}
if (getGrandparent().getClient() != null) {
getGrandparent().getClient().getSession().write(buffer);
}
}
@SuppressWarnings("unchecked")
public SWGList<String> getObjectTemplateCustomizationList() {
return (SWGList<String>) baseline7.get("objectTemplateCustomizationList");
}
public boolean isReady() {
synchronized(objectMutex) {
return (boolean) baseline7.get("isReady");
}
}
public void setReady(boolean ready) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline7.set("ready", ready);
}
if (getGrandparent().getClient() != null) {
getGrandparent().getClient().getSession().write(buffer);
}
}
public void toggleReady() {
setReady(!isReady());
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, notifySelf);
}
@Override
public ManufactureSchematicMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new ManufactureSchematicMessageBuilder(this);
}
return messageBuilder;
}
}
public void sendBaseline7(Client destination) {
destination.getSession().write(baseline7.getBaseline());
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
destination.getSession().write(baseline3.getBaseline());
destination.getSession().write(baseline6.getBaseline());
destination.getSession().write(baseline8.getBaseline());
destination.getSession().write(baseline9.getBaseline());
}
}
@Override
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
switch (viewType) {
case 1:
case 4:
case 7:
if (getGrandparent().getClient() != null) {
buffer = getBaseline(viewType).createDelta(updateType, buffer.array());
getGrandparent().getClient().getSession().write(buffer);
}
return;
case 3:
case 6:
case 8:
case 9:
notifyObservers(getBaseline(viewType).createDelta(updateType, buffer.array()), true);
default:
return;
}
}
}
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.mission;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.intangible.IntangibleMessageBuilder;
public class MissionMessageBuilder extends IntangibleMessageBuilder {
public MissionMessageBuilder(MissionObject object) {
super(object);
}
public MissionMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,329 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.mission;
import org.apache.mina.core.buffer.IoBuffer;
import main.NGECore;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
import resources.common.Stf;
import resources.common.UString;
import resources.z.exp.mission.MissionLocation;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.intangible.IntangibleObject;
import resources.z.exp.objects.waypoint.WaypointObject;
@Persistent
public class MissionObject extends IntangibleObject {
@NotPersistent
private MissionMessageBuilder messageBuilder;
public MissionObject(NGECore core, long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
baseline3.set("waypoint", (WaypointObject) core.objectService.createObject("object/waypoint/base/shared_base_waypoint.iff", planet));
}
public MissionObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("difficultyLevel", 0);
baseline.put("startLocation", new MissionLocation(new Point3D(0, 0, 0), 0, ""));
baseline.put("creator", new UString());
baseline.put("creditReward", 0);
baseline.put("targetObject", 0);
baseline.put("description", new Stf());
baseline.put("title", new Stf());
baseline.put("repeatCounter", 0);
baseline.put("missionType", "");
baseline.put("targetName", "");
baseline.put("waypoint", new WaypointObject());
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
return baseline;
}
public int getDifficultyLevel() {
synchronized(objectMutex) {
return (int) baseline3.get("difficultyLevel");
}
}
public void setDifficultyLevel(int difficultyLevel) {
synchronized(objectMutex) {
baseline3.set("difficultyLevel", difficultyLevel);
}
}
public MissionLocation getStartLocation() {
synchronized(objectMutex) {
return (MissionLocation) baseline3.get("startLocation");
}
}
public void setStartLocation(Point3D position, SWGObject object, Planet planet) {
setStartLocation(position, object, planet.getName());
}
public void setStartLocation(Point3D position, SWGObject object, String planet) {
synchronized(objectMutex) {
MissionLocation startLocation = new MissionLocation(position.clone(), object.getObjectID(), planet);
baseline3.set("startLocation", startLocation);
}
}
public String getCreator() {
synchronized(objectMutex) {
return (String) baseline3.get("creator");
}
}
public void setCreator(String creator) {
synchronized(objectMutex) {
baseline3.set("creator", creator);
}
}
public int getCreditReward() {
synchronized(objectMutex) {
return (int) baseline3.get("creditReward");
}
}
public void setCreditReward(int creditReward) {
synchronized(objectMutex) {
baseline3.set("creditReward", creditReward);
}
}
public MissionLocation getDestination() {
synchronized(objectMutex) {
return (MissionLocation) baseline3.get("destination");
}
}
public void setDestination(Point3D position, SWGObject object, Planet planet) {
setDestination(position, object, planet.getName());
}
public void setDestination(Point3D position, SWGObject object, String planet) {
synchronized(objectMutex) {
MissionLocation destination = new MissionLocation(position.clone(), object.getObjectID(), planet);
baseline3.set("destination", destination);
}
}
public int getTargetObject() {
synchronized(objectMutex) {
return (int) baseline3.get("targetObject");
}
}
public void setTargetObject(int targetObject) {
synchronized(objectMutex) {
baseline3.set("targetObject", targetObject);
}
}
public Stf getDescription() {
synchronized(objectMutex) {
return (Stf) baseline3.get("description");
}
}
public void setDescription(String stfFilename, String string) {
synchronized(objectMutex) {
Stf description = new Stf(stfFilename, 0, string);
baseline3.set("description", description);
}
}
public Stf getTitle() {
synchronized(objectMutex) {
return (Stf) baseline3.get("title");
}
}
public void setTitle(String stfFilename, String string) {
synchronized(objectMutex) {
Stf title = new Stf(stfFilename, 0, string);
baseline3.set("title", title);
}
}
public int getRepeatCounter() {
synchronized(objectMutex) {
return (int) baseline3.get("repeatCounter");
}
}
public void setRepeatCounter(int repeatCounter) {
synchronized(objectMutex) {
baseline3.set("repeatCounter", repeatCounter);
}
}
public void incrementRepeatCounter(int increase) {
setRepeatCounter(getRepeatCounter() + 1);
}
public void decrementRepeatCounter(int decrease) {
int repeatCounter = getRepeatCounter() + 1;
setRepeatCounter((repeatCounter < 0) ? 0 : repeatCounter);
}
public String getMissionType() {
synchronized(objectMutex) {
return (String) baseline3.get("missionType");
}
}
public void setMissionType(String missionType) {
synchronized(objectMutex) {
baseline3.set("missionType", missionType);
}
}
public String getTargetName() {
synchronized(objectMutex) {
return (String) baseline3.get("targetName");
}
}
public void setTargetName(String targetName) {
synchronized(objectMutex) {
baseline3.set("targetName", targetName);
}
}
public WaypointObject getWaypoint() {
synchronized(objectMutex) {
return (WaypointObject) baseline3.get("waypoint");
}
}
public void setWaypoint(WaypointObject waypoint) {
synchronized(objectMutex) {
baseline3.set("waypoint", waypoint);
}
}
// A new mission listing is just one big delta to one of the player's
// empty, pre-existing MissionObjects
public void updateMission() {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.createDelta();
}
if (getGrandparent().getClient() != null) {
getGrandparent().getClient().getSession().write(buffer);
}
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
getGrandparent().getClient().getSession().write(buffer);
}
@Override
public MissionMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new MissionMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
destination.getSession().write(baseline3.getBaseline());
destination.getSession().write(baseline6.getBaseline());
destination.getSession().write(baseline8.getBaseline());
destination.getSession().write(baseline9.getBaseline());
}
}
@Override
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
switch (viewType) {
case 1:
case 4:
case 3:
case 6:
case 7:
case 8:
case 9:
if (getGrandparent().getClient() != null) {
buffer = getBaseline(viewType).createDelta(updateType, buffer.array());
getGrandparent().getClient().getSession().write(buffer);
}
default:
return;
}
}
}
@@ -0,0 +1,543 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.object;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.mina.core.buffer.IoBuffer;
import resources.common.Stf;
import resources.common.UString;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.ObjectMessageBuilder;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class BaseObject extends SWGObject {
@NotPersistent
private ObjectMessageBuilder messageBuilder;
protected Baseline baseline1;
protected Baseline baseline3;
protected Baseline baseline4;
protected Baseline baseline6;
protected Baseline baseline7;
protected Baseline baseline8;
protected Baseline baseline9;
protected Baseline otherVariables;
@NotPersistent
private ScheduledExecutorService scheduler;
private boolean ready = false;
public BaseObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
super.setCustomName("");
if (super.getDetailFilename() == null) super.setDetailFilename("");
if (super.getDetailName() == null) super.setDetailName("");
initializeBaselines();
otherVariables = getOtherVariables();
ready = true;
}
public BaseObject() {
super();
scheduler = Executors.newScheduledThreadPool(2);
// Makes sure this runs after the baselines have been restored from DB
scheduler.schedule(new Runnable() {
public void run() {
while (!ready);
initializeBaselines();
}
}, 0, TimeUnit.NANOSECONDS);
}
public void initializeBaselines() {
// Transform the structures of any baselines incase they've been altered
if (otherVariables != null) {
otherVariables.transformStructure(getOtherVariables());
}
if (baseline1 != null) {
baseline1.transformStructure(getBaseline1());
addBuilders(1);
}
if (baseline3 != null) {
baseline3.transformStructure(getBaseline3());
addBuilders(3);
}
if (baseline4 != null) {
baseline4.transformStructure(getBaseline4());
addBuilders(4);
}
if (baseline6 != null) {
baseline6.transformStructure(getBaseline6());
addBuilders(6);
}
if (baseline7 != null) {
baseline7.transformStructure(getBaseline7());
addBuilders(7);
}
if (baseline8 != null) {
baseline8.transformStructure(getBaseline8());
addBuilders(8);
}
if (baseline9 != null) {
baseline9.transformStructure(getBaseline9());
addBuilders(9);
}
// Inheriting objects initialize these only if needed, for efficiency
initializeBaseline(3);
initializeBaseline(6);
}
public void initializeBaseline(int viewType) {
// Won't initialize any baselines if they've already been initialized
switch (viewType) {
case 1:
if (baseline1 == null) {
baseline1 = getBaseline1();
addBuilders(viewType);
getMessageBuilder().buildBaseline1(baseline1.getBaselineBuilders(), baseline1.getDeltaBuilders());
}
return;
case 3:
if (baseline3 == null) {
baseline3 = getBaseline3();
addBuilders(viewType);
getMessageBuilder().buildBaseline3(baseline3.getBaselineBuilders(), baseline3.getDeltaBuilders());
}
return;
case 4:
if (baseline4 == null) {
baseline4 = getBaseline4();
addBuilders(viewType);
getMessageBuilder().buildBaseline4(baseline4.getBaselineBuilders(), baseline4.getDeltaBuilders());
}
return;
case 6:
if (baseline6 == null) {
baseline6 = getBaseline6();
addBuilders(viewType);
getMessageBuilder().buildBaseline6(baseline6.getBaselineBuilders(), baseline6.getDeltaBuilders());
}
return;
case 7:
if (baseline7 == null) {
baseline7 = getBaseline7();
addBuilders(viewType);
getMessageBuilder().buildBaseline7(baseline7.getBaselineBuilders(), baseline7.getDeltaBuilders());
}
return;
case 8:
if (baseline8 == null) {
baseline8 = getBaseline8();
addBuilders(viewType);
getMessageBuilder().buildBaseline8(baseline8.getBaselineBuilders(), baseline8.getDeltaBuilders());
}
return;
case 9:
if (baseline9 == null) {
baseline9 = getBaseline9();
addBuilders(viewType);
getMessageBuilder().buildBaseline9(baseline9.getBaselineBuilders(), baseline9.getDeltaBuilders());
}
default:
return;
}
}
public void addBuilders(int viewType) {
Baseline baseline = getBaseline(viewType);
Map<Integer, Builder> baselineBuilders = new HashMap<Integer, Builder>();
Map<Integer, Builder> deltaBuilders = new HashMap<Integer, Builder>();
switch (viewType) {
case 1:
getMessageBuilder().buildBaseline1(baselineBuilders, deltaBuilders);
break;
case 3:
getMessageBuilder().buildBaseline3(baselineBuilders, deltaBuilders);
break;
case 4:
getMessageBuilder().buildBaseline4(baselineBuilders, deltaBuilders);
break;
case 6:
getMessageBuilder().buildBaseline6(baselineBuilders, deltaBuilders);
break;
case 7:
getMessageBuilder().buildBaseline7(baselineBuilders, deltaBuilders);
break;
case 8:
getMessageBuilder().buildBaseline8(baselineBuilders, deltaBuilders);
break;
case 9:
getMessageBuilder().buildBaseline9(baselineBuilders, deltaBuilders);
break;
}
if (baselineBuilders.size() > 0) {
baseline.setBaselineBuilders(baselineBuilders);
}
if (deltaBuilders.size() > 0) {
baseline.setDeltaBuilders(deltaBuilders);
}
}
public Baseline getOtherVariables() {
Baseline baseline = new Baseline(this, 0);
return baseline;
}
public Baseline getBaseline1() {
Baseline baseline = new Baseline(this, 1);
return baseline;
}
public Baseline getBaseline3() {
Baseline baseline = new Baseline(this, 3);
baseline.put("complexity", (float) 1);
baseline.put("stf", new Stf(getStfFilename(), 0, getStfName()));
baseline.put("customName", new UString(""));
baseline.put("volume", 1);
return baseline;
}
public Baseline getBaseline4() {
Baseline baseline = new Baseline(this, 4);
return baseline;
}
public Baseline getBaseline6() {
Baseline baseline = new Baseline(this, 6);
baseline.put("serverId", 0);
baseline.put("detail", new Stf(getDetailFilename(), 0, getDetailName()));
return baseline;
}
public Baseline getBaseline7() {
Baseline baseline = new Baseline(this, 7);
return baseline;
}
public Baseline getBaseline8() {
Baseline baseline = new Baseline(this, 8);
return baseline;
}
public Baseline getBaseline9() {
Baseline baseline = new Baseline(this, 9);
return baseline;
}
public float getComplexity() {
synchronized(objectMutex) {
return (float) baseline3.get("complexity");
}
}
public void setComplexity(float complexity) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("complexity", complexity);
}
if (baseline3 != null) {
notifyClients(buffer, true);
}
}
public Stf getStf() {
return (Stf) baseline3.get("stf");
}
public void setStfFilename(String stfFilename) {
super.setStfFilename(stfFilename);
if (baseline3 != null) {
IoBuffer buffer;
getStf().setStfFilename(stfFilename);
synchronized(objectMutex) {
buffer = baseline3.set("stf", getStf());
}
if (baseline3 != null) {
notifyClients(buffer, true);
}
}
}
public int getStfSpacer() {
synchronized(objectMutex) {
return ((Stf) baseline3.get("stf")).getSpacer();
}
}
public void setStfSpacer(int stfSpacer) {
IoBuffer buffer;
getStf().setSpacer(stfSpacer);
synchronized(objectMutex) {
buffer = baseline3.set("stf", getStf());
}
if (baseline3 != null) {
notifyClients(buffer, true);
}
}
public void setStfName(String stfName) {
super.setStfName(stfName);
if (baseline3 != null) {
IoBuffer buffer;
getStf().setStfName(stfName);
synchronized(objectMutex) {
buffer = baseline3.set("stf", getStf());
}
if (baseline3 != null) {
notifyClients(buffer, true);
}
}
}
public void setCustomName(String customName) {
super.setCustomName(customName);
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("customName", customName);
}
if (baseline3 != null) {
notifyClients(buffer, true);
}
}
public void setVolume(int volume) {
super.setVolume(volume);
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("volume", volume);
}
if (baseline3 != null) {
notifyClients(buffer, true);
}
}
public void incrementVolume(int increase) {
setVolume((getVolume() + increase));
}
public void decrementVolume(int decrease) {
setVolume((((getVolume() - decrease) < 1) ? 0 : (getVolume() - decrease)));
}
public int getServerId() {
synchronized(objectMutex) {
return (int) baseline6.get("serverId");
}
}
public void setServerId(int serverId) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("serverId", serverId);
}
if (baseline6 != null) {
notifyClients(buffer, true);
}
}
public Stf getDetail() {
return (Stf) baseline3.get("detail");
}
public void setDetailFilename(String detailFilename) {
super.setDetailFilename(detailFilename);
if (baseline6 != null) {
IoBuffer buffer;
getDetail().setStfFilename(detailFilename);
synchronized(objectMutex) {
buffer = baseline6.set("detail", getDetail());
}
if (baseline6 != null) {
notifyClients(buffer, true);
}
}
}
public int getDetailSpacer() {
synchronized(objectMutex) {
return ((Stf) baseline6.get("detail")).getSpacer();
}
}
public void setDetailSpacer(int detailSpacer) {
IoBuffer buffer;
getDetail().setSpacer(detailSpacer);
synchronized(objectMutex) {
buffer = baseline6.set("detail", getDetail());
}
if (baseline6 != null) {
notifyClients(buffer, true);
}
}
public void setDetailName(String detailName) {
super.setDetailName(detailName);
if (baseline6 != null) {
IoBuffer buffer;
getDetail().setStfName(detailName);
synchronized(objectMutex) {
buffer = baseline6.set("detail", getDetail());
}
if (baseline6 != null) {
notifyClients(buffer, true);
}
}
}
protected Baseline getBaseline(int viewType) {
switch (viewType) {
case 1: return baseline1;
case 3: return baseline3;
case 4: return baseline4;
case 6: return baseline6;
case 7: return baseline7;
case 8: return baseline8;
case 9: return baseline9;
default: return null;
}
}
/*
This should contain the method of notifying observers, as
it tends to vary depending on the type of object, which is
a problem for inheritance when the master object uses a
different method (ie. ITNO and PLAY).
*/
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, notifySelf);
}
public ObjectMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new ObjectMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
destination.getSession().write(baseline3.getBaseline());
destination.getSession().write(baseline6.getBaseline());
}
}
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
switch (viewType) {
case 1:
case 4:
case 7:
if (getClient() != null) {
buffer = getBaseline(viewType).createDelta(updateType, buffer.array());
getClient().getSession().write(buffer);
}
return;
case 3:
case 6:
case 8:
case 9:
notifyClients(getBaseline(viewType).createDelta(updateType, buffer.array()), true);
default:
return;
}
}
}
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.player;
import java.util.Map;
import com.sleepycat.persist.model.Persistent;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.intangible.IntangibleMessageBuilder;
@Persistent
public class PlayerMessageBuilder extends IntangibleMessageBuilder {
public PlayerMessageBuilder(PlayerObject playerObject) {
super(playerObject);
}
public PlayerMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,999 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.player;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import org.apache.mina.core.buffer.IoBuffer;
import resources.datatables.Professions;
import resources.z.exp.gcw.RegionDefender;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.SWGList;
import resources.z.exp.objects.SWGMap;
import resources.z.exp.objects.intangible.IntangibleObject;
import resources.z.exp.objects.waypoint.WaypointObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import resources.z.exp.craft.DraftSchematic;
import resources.z.exp.quest.Quest;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class PlayerObject extends IntangibleObject {
@NotPersistent
private PlayerMessageBuilder messageBuilder;
@NotPersistent
private long lastPlayTimeUpdate = System.currentTimeMillis();
public PlayerObject(long objectID, Planet planet) {
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/player/shared_player.iff");
setServerId(0x8A);
}
public PlayerObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
List<Integer> flagsList = new ArrayList<Integer>();
flagsList.add(0);
flagsList.add(0);
flagsList.add(0);
flagsList.add(0);
baseline.put("flagsList", flagsList);
List<Integer> profileFlagsList = new ArrayList<Integer>();
profileFlagsList.add(0);
profileFlagsList.add(0);
profileFlagsList.add(0);
profileFlagsList.add(0);
baseline.put("profileFlagsList", profileFlagsList);
baseline.put("title", "");
baseline.put("bornDate", Integer.parseInt(new SimpleDateFormat("yyyymmdd", Locale.ENGLISH).format(Calendar.getInstance().getTime())));
baseline.put("totalPlayTime", 0);
baseline.put("professionIcon", 0);
baseline.put("profession", "trader_1a");
baseline.put("gcwPoints", 0);
baseline.put("pvpKills", 0);
baseline.put("lifetimeGcwPoints", (long) 0);
baseline.put("lifetimePvpKills", 0);
baseline.put("16", new SWGList<Byte>(this, 3, 16, false)); // Misc data size (varies, 0 in tutorial) <- collections?) <- this isn't a SWGList, but it'll work until we need it
baseline.put("17", new SWGList<Byte>(this, 3, 17, false)); // Misc ints (2 ints in tutorial, 5 bytes other times...)
baseline.put("18", (byte) 0); // Unknown Flag (regularly changed in tutorial)
baseline.put("19", (byte) 0); // Unknown Flag (regularly changed in tutorial)
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("adminFlags", (byte) 0);
baseline.put("currentRank", 0);
baseline.put("rankProgress", (float) 0);
baseline.put("highestRebelRank", 0);
baseline.put("highestImperialRank", 0);
baseline.put("nextUpdateTime", 0); // TODO set correctly
baseline.put("home", "");
baseline.put("citizenship", (byte) 0); // Homeless/Citizen/Militia/Mayor?
baseline.put("cityRegionDefender", new RegionDefender());
baseline.put("guildRegionDefender", new RegionDefender());
baseline.put("12", 0); // General?
baseline.put("13", 0); // Guild Rank Title?
baseline.put("14", 0); // Citizen Rank Title?
baseline.put("15", 0); // All random guesses, always seem to be 0
baseline.put("16", 0);
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
baseline.put("xpList", new SWGMap<String, Integer>(this, 8, 0, true));
baseline.put("waypoints", new SWGMap<Long, WaypointObject>(this, 8, 1, true));
baseline.put("currentForcePower", 100);
baseline.put("maxForcePower", 100);
baseline.put("currentFSQuestList", new SWGList<Byte>(this, 8, 4, false));
baseline.put("completedFSQuestList", new SWGList<Byte>(this, 8, 5, false));
baseline.put("questJournal", new SWGList<Quest>(this, 8, 6, false));
baseline.put("professionWheelPosition", "");
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
baseline.put("experimentationFlag", 0);
baseline.put("craftingStage", 0);
baseline.put("nearestCraftingStation", 0);
baseline.put("draftSchematicList", new SWGList<DraftSchematic>(this, 9, 3, true));
baseline.put("4", new SWGList<Byte>(this, 9, 4, false)); // Might or might not be a list, but at the very least it's two 0 ints that are part of the same delta.
baseline.put("experimentationPoints", 0);
baseline.put("accomplishmentCounter", 0);
baseline.put("friendList", new SWGList<String>(this, 9, 7, false));
baseline.put("ignoreList", new SWGList<String>(this, 9, 8, false));
baseline.put("languageId", 0);
baseline.put("currentStomach", 0);
baseline.put("maxStomach", 100);
baseline.put("currentDrink", 0);
baseline.put("maxDrink", 100);
baseline.put("currentConsumable", 0);
baseline.put("maxConsumable", 100);
// The others are unknown, commented below.
// it won't send the rest and won't have to by using a lower object count.
// If we figure all these structs out all we have to do is add them the
// same way as above
/*
buffer.putInt(0); // Related to stomach in CU
buffer.putInt(0); // Related to stomach in CU
buffer.putInt(0); // Been seen as 0x0A
buffer.putInt(3); // Also been seen as 0x0A and 0x02 and 0x18
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0); // Unused Waypoint List?
buffer.putInt(0); // Update Counter?
buffer.putInt(2); // Unknown, sometimes a number and sometimes 0
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(0);
buffer.putInt(object.getJediState());
buffer.putShort((short) 0);
*/
return baseline;
}
@SuppressWarnings("unchecked")
public List<Integer> getFlagsList() {
return (List<Integer>) baseline3.get("flagsList");
}
public void setFlagsList(int flag1, int flag2, int flag3, int flag4) {
IoBuffer buffer;
synchronized(objectMutex) {
List<Integer> flagsList = getFlagsList();
flagsList.set(0, flag1);
flagsList.set(1, flag2);
flagsList.set(2, flag3);
flagsList.set(3, flag4);
buffer = baseline3.set("flagsList", flagsList);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
@SuppressWarnings("unchecked")
public List<Integer> getProfileFlagsList() {
return (List<Integer>) baseline3.get("profileFlagsList");
}
public void setProfileFlagsList(int flag1, int flag2, int flag3, int flag4) {
IoBuffer buffer;
synchronized(objectMutex) {
List<Integer> profileFlagsList = getProfileFlagsList();
profileFlagsList.set(0, flag1);
profileFlagsList.set(1, flag2);
profileFlagsList.set(2, flag3);
profileFlagsList.set(3, flag4);
buffer = baseline3.set("profileFlagsList", profileFlagsList);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public String getTitle() {
synchronized(objectMutex) {
return (String) baseline3.get("title");
}
}
public void setTitle(String title) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("title", title);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getBornDate() {
synchronized(objectMutex) {
return (int) baseline3.get("bornDate");
}
}
public long getLastPlayTimeUpdate() {
synchronized(objectMutex) {
return (long) baseline3.get("lastPlayTimeUpdate");
}
}
public void setLastPlayTimeUpdate(long lastPlayTimeUpdate) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("lastPlayTimeUpdate", lastPlayTimeUpdate);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getTotalPlayTime() {
synchronized(objectMutex) {
return (int) baseline3.get("totalPlayTime");
}
}
public void setTotalPlayTime(int totalPlayTime) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("totalPlayTime", totalPlayTime);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getProfessionIcon() {
synchronized(objectMutex) {
return (int) baseline3.get("professionIcon");
}
}
public void setProfessionIcon(int professionIcon) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("professionIcon", professionIcon);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public String getProfession() {
synchronized(objectMutex) {
return (String) baseline3.get("profession");
}
}
public void setProfession(String profession) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("profession", profession);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
setProfessionIcon(Professions.get(profession));
}
public int getGcwPoints() {
synchronized(objectMutex) {
return (int) baseline3.get("gcwPoints");
}
}
public void addGcwPoints(int gcwPoints) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("gcwPoints", (((int) baseline3.get("gcwPoints")) + gcwPoints));
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public void resetGcwPoints() {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("gcwPoints", 0);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getPvpKills() {
synchronized(objectMutex) {
return (int) baseline3.get("pvpKills");
}
}
public void addPvpKill() {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("pvpKills", (((int) baseline3.get("pvpKills")) + 1));
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public void resetPvpKills() {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("pvpKills", 0);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public long getLifetimeGcwPoints() {
synchronized(objectMutex) {
return (long) baseline3.get("lifetimeGcwPoints");
}
}
public void addLifetimeGcwPoints(long gcwPoints) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("lifetimeGcwPoints", (((long) baseline3.get("lifetimeGcwPoints")) + gcwPoints));
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getLifetimePvpKills() {
synchronized(objectMutex) {
return (int) baseline3.get("lifetimePvpKills");
}
}
public void addLifetimePvpKills(int pvpKills) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("lifetimePvpKills", (((int) baseline3.get("lifetimePvpKills")) + pvpKills));
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public byte getAdminFlag() {
synchronized(objectMutex) {
return (byte) baseline6.get("adminFlag");
}
}
public void setAdminFlag(byte adminFlag) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("adminFlag", adminFlag);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getCurrentRank() {
synchronized(objectMutex) {
return (int) baseline6.get("currentRank");
}
}
public void setCurrentRank(int currentRank) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("currentRank", currentRank);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public float getRankProgress() {
synchronized(objectMutex) {
return (float) baseline6.get("rankProgress");
}
}
public void setRankProgress(float rankProgress) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("rankProgress", rankProgress);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getHighestRebelRank() {
synchronized(objectMutex) {
return (int) baseline6.get("highestRebelRank");
}
}
public void setHighestIRank(int highestRebelRank) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("highestRebelRank", highestRebelRank);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getHighestImperialRank() {
synchronized(objectMutex) {
return (int) baseline6.get("highestImperialRank");
}
}
public void setHighestImperialRank(int highestImperialRank) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("highestImperialRank", highestImperialRank);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getNextUpdateTime() {
synchronized(objectMutex) {
return (int) baseline6.get("nextUpdateTime");
}
}
public void setNextUpdateTime(int nextUpdateTime) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("nextUpdateTime", nextUpdateTime);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public String getHome() {
synchronized(objectMutex) {
return (String) baseline6.get("home");
}
}
public void setHome(String home) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("home", home);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public byte getCitizenship() {
synchronized(objectMutex) {
return (byte) baseline6.get("citizenship");
}
}
public void setCitizenship(byte citizenship) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("citizenship", citizenship);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public RegionDefender getCityRegionDefender() {
synchronized(objectMutex) {
return (RegionDefender) baseline6.get("cityRegionDefender");
}
}
public void setCityRegionDefender(RegionDefender cityRegionDefender) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("cityRegionDefender", cityRegionDefender);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public RegionDefender getGuildRegionDefender() {
synchronized(objectMutex) {
return (RegionDefender) baseline6.get("guildRegionDefender");
}
}
public void setGuildRegionDefender(RegionDefender guildRegionDefender) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("guildRegionDefender", guildRegionDefender);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
@SuppressWarnings("unchecked")
public SWGMap<String, Integer> getXpList() {
return (SWGMap<String, Integer>) baseline8.get("xpList");
}
@SuppressWarnings("unchecked")
public SWGMap<Long, WaypointObject> getWaypoints() {
return (SWGMap<Long, WaypointObject>) baseline8.get("waypoints");
}
public void waypointUpdate(WaypointObject waypoint) {
getWaypoints().put(waypoint.getObjectID(), waypoint);
}
public void waypointRemove(WaypointObject waypoint) {
getWaypoints().remove(waypoint.getObjectID());
}
public void waypointAdd(WaypointObject waypoint) {
getWaypoints().put(waypoint.getObjectID(), waypoint);
}
public WaypointObject getWaypointFromList(WaypointObject waypoint) {
synchronized(objectMutex) {
if (getWaypoints().containsKey(waypoint.getObjectID())) {
return getWaypoints().get(waypoint.getObjectID());
}
}
return null;
}
public int getCurrentForcePower() {
synchronized(objectMutex) {
return (int) baseline8.get("currentForcePower");
}
}
public void setCurrentForcePower(int currentForcePower) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline8.set("currentForcePower", currentForcePower);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getMaxForcePower() {
synchronized(objectMutex) {
return (int) baseline8.get("maxForcePower");
}
}
public void setMaxForcePower(int maxForcePower) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline8.set("maxForcePower", maxForcePower);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
@SuppressWarnings("unchecked")
public SWGList<Byte> getCurrentFSQuestList() {
return (SWGList<Byte>) baseline8.get("currentFSQuestList");
}
@SuppressWarnings("unchecked")
public SWGList<Byte> getCompletedFSQuestList() {
return (SWGList<Byte>) baseline8.get("completedFSQuestList");
}
@SuppressWarnings("unchecked")
public SWGList<Quest> getQuestJournal() {
return (SWGList<Quest>) baseline8.get("questJournal");
}
public String getProfessionWheelPosition() {
synchronized(objectMutex) {
return (String) baseline8.get("professionWheelPosition");
}
}
public void setProfessionWheelPosition(String professionWheelPosition) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline8.set("professionWheelPosition", professionWheelPosition);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getExperimentationFlag() {
synchronized(objectMutex) {
return (int) baseline9.get("experimentationFlag");
}
}
public void setExperimentationFlag(int experimentationFlag) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("experimentationFlag", experimentationFlag);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getCraftingStage() {
synchronized(objectMutex) {
return (int) baseline9.get("craftingStage");
}
}
public void setCraftingStage(int craftingStage) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("craftingStage", craftingStage);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public long getNearestCraftingStation() {
synchronized(objectMutex) {
return (long) baseline9.get("nearestCraftingStation");
}
}
public void setNearestCraftingStation(long nearestCraftingStation) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("nearestCraftingStation", nearestCraftingStation);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
@SuppressWarnings("unchecked")
public SWGList<DraftSchematic> getDraftSchematicList() {
return (SWGList<DraftSchematic>) baseline9.get("draftSchematicList");
}
public int getExperimentationPoints() {
synchronized(objectMutex) {
return (int) baseline9.get("experimentationPoints");
}
}
public void setExperimentationPoints(int experimentationPoints) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("experimentationPoints", experimentationPoints);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getAccomplishmentCounter() {
synchronized(objectMutex) {
return (int) baseline9.get("accomplishmentCounter");
}
}
public void setAccomplishmentCounter(int accomplishmentCounter) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("accomplishmentCounter", accomplishmentCounter);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
@SuppressWarnings("unchecked")
public SWGList<String> getFriendList() {
return (SWGList<String>) baseline9.get("friendList");
}
public void friendAdd(String friend) {
getFriendList().add(friend);
}
public void friendRemove(String friend) {
getFriendList().remove(friend);
}
@SuppressWarnings("unchecked")
public SWGList<String> getIgnoreList() {
return (SWGList<String>) baseline9.get("ignoreList");
}
public void ignoreAdd(String name) {
getIgnoreList().add(name);
}
public void ignoreRemove(String name) {
getIgnoreList().remove(name);
}
public int getLanguageId() {
synchronized(objectMutex) {
return (int) baseline9.get("languageId");
}
}
public void setLanguageId(int languageId) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("languageId", languageId);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getCurrentStomach() {
synchronized(objectMutex) {
return (int) baseline9.get("currentStomach");
}
}
public void setCurrentStomach(int currentStomach) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("currentStomach", currentStomach);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getMaxStomach() {
synchronized(objectMutex) {
return (int) baseline9.get("maxStomach");
}
}
public void setMaxStomach(int maxStomach) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("maxStomach", maxStomach);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getCurrentDrink() {
synchronized(objectMutex) {
return (int) baseline9.get("currentDrink");
}
}
public void setCurrentDrink(int currentDrink) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("currentDrink", currentDrink);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getMaxDrink() {
synchronized(objectMutex) {
return (int) baseline9.get("maxDrink");
}
}
public void setMaxDrink(int maxDrink) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("maxDrink", maxDrink);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getCurrentConsumable() {
synchronized(objectMutex) {
return (int) baseline9.get("currentConsumable");
}
}
public void setCurrentConsumable(int currentConsumable) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("currentConsumable", currentConsumable);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
public int getMaxConsumable() {
synchronized(objectMutex) {
return (int) baseline9.get("maxConsumable");
}
}
public void setMaxConsumable(int maxConsumable) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline9.set("maxConsumable", maxConsumable);
}
if (getContainer() != null) {
getContainer().notifyObservers(buffer, true);
}
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
if (getContainer() != null) {
getContainer().notifyObservers(buffer, notifySelf);
}
}
@Override
public PlayerMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new PlayerMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//if(destination.getParent().getObjectID() == getParentId()) { // only send to self
//destination.getSession().write(getBaseline(3).getBaseline());
//destination.getSession().write(getBaseline(6).getBaseline());
//destination.getSession().write(getBaseline(8).getBaseline());
//destination.getSession().write(getBaseline(9).getBaseline());
//}
}
}
@Override
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
if (getContainer() != null) {
getContainer().notifyObservers(getBaseline(viewType).createDelta(updateType, buffer.array()), true);
}
}
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.resource;
public class ResourceContainerMessageBuilder {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.resource;
public class ResourceContainerObject {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.ship;
public class ShipMessageBuilder {
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.ship;
public class ShipObject {
}
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.staticobject;
import java.util.Map;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.ObjectMessageBuilder;
public class StaticMessageBuilder extends ObjectMessageBuilder {
public StaticMessageBuilder(StaticObject object) {
super(object);
}
public StaticMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,93 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.staticobject;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class StaticObject extends BaseObject {
@NotPersistent
private StaticMessageBuilder messageBuilder;
public StaticObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
}
public StaticObject() {
super();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
return baseline;
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, false);
}
@Override
public StaticMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new StaticMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
}
}
}
@@ -0,0 +1,62 @@
/*******************************************************************************
` * Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.tangible;
import java.util.Map;
import com.sleepycat.persist.model.Persistent;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.ObjectMessageBuilder;
@Persistent
public class TangibleMessageBuilder extends ObjectMessageBuilder {
public TangibleMessageBuilder(TangibleObject object) {
super(object);
}
public TangibleMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,400 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.tangible;
import java.util.ArrayList;
import java.util.List;
import org.apache.mina.core.buffer.IoBuffer;
import resources.datatables.FactionStatus;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.SWGList;
import resources.z.exp.objects.creature.CreatureObject;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.common.CRC;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class TangibleObject extends BaseObject {
@NotPersistent
private TangibleMessageBuilder messageBuilder;
@NotPersistent
private List<TangibleObject> defendersList = new ArrayList<TangibleObject>();
public TangibleObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String template) {
super(objectID, planet, position, orientation, template);
}
public TangibleObject(long objectID, Planet planet, String template) {
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0), template);
}
public TangibleObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
initializeBaseline(8);
initializeBaseline(9);
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
baseline.put("faction", "");
baseline.put("pvpBitmask", 0);
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("faction", 0);
baseline.put("factionStatus", 0);
baseline.put("customization", new Byte[] { 0x00, 0x00 });
baseline.put("componentCustomizationList", new SWGList<Integer>(this, 3, 7, false));
baseline.put("optionsBitmask", 0);
baseline.put("incapacityTimer", 0);
baseline.put("conditionDamage", 0);
baseline.put("maximumCondition", 0);
baseline.put("isStatic", false);
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("inCombat", false);
baseline.put("3", (long) 0); // Unknown
baseline.put("4", (long) 0); // Unknown
baseline.put("5", (long) 0); // Unknown
baseline.put("6", (long) 0); // Unknown
baseline.put("7", 0); // Unknown
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
return baseline;
}
public String getFaction() {
synchronized(objectMutex) {
return (String) otherVariables.get("faction");
}
}
public void setFaction(String faction) {
IoBuffer buffer;
synchronized(objectMutex) {
otherVariables.set("faction", faction);
buffer = baseline3.set("faction", CRC.StringtoCRC(faction));
}
notifyClients(buffer, true);
}
public int getFactionStatus() {
synchronized(objectMutex) {
return (int) baseline3.get("factionStatus");
}
}
public void setFactionStatus(int factionStatus) {
switch (factionStatus) {
case FactionStatus.OnLeave:
case FactionStatus.Combatant:
case FactionStatus.SpecialForces:
break;
default:
factionStatus = 0;
}
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("factionStatus", factionStatus);
}
notifyClients(buffer, true);
}
public byte[] getCustomization() {
synchronized(objectMutex) {
return (byte[]) baseline3.get("customization");
}
}
public void setCustomization(byte[] customization) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("customization", customization);
}
notifyClients(buffer, true);
}
@SuppressWarnings("unchecked")
public SWGList<Integer> getComponentCustomizationList() {
return (SWGList<Integer>) baseline3.get("componentCustomizationList");
}
public int getOptionsBitmask() {
synchronized(objectMutex) {
return (int) baseline3.get("optionsBitmask");
}
}
public void setOptionsBitmask(int optionsBitmask) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("optionsBitmask", optionsBitmask);
}
notifyClients(buffer, true);
}
public int getIncapacityTimer() {
synchronized(objectMutex) {
return (int) baseline3.get("incapacityTimer");
}
}
public void setIncapacityTimer(int incapacityTimer) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("incapacityTimer", incapacityTimer);
}
notifyClients(buffer, true);
}
public int getConditionDamage() {
synchronized(objectMutex) {
return (int) baseline3.get("conditionDamage");
}
}
public void setConditionDamage(int conditionDamage) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("conditionDamage", conditionDamage);
}
notifyClients(buffer, true);
}
public int getMaximumCondition() {
synchronized(objectMutex) {
return (int) baseline3.get("maximumCondition");
}
}
public void setMaximumCondition(int maximumCondition) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("maximumCondition", maximumCondition);
}
notifyClients(buffer, true);
}
public boolean isStatic() {
synchronized(objectMutex) {
return (boolean) baseline3.get("isStatic");
}
}
public void setStatic(boolean isStatic) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("isStatic", isStatic);
}
notifyClients(buffer, true);
}
public void toggleStatic() {
setStatic(!isStatic());
}
public boolean inCombat() {
synchronized(objectMutex) {
return (boolean) baseline6.get("inCombat");
}
}
public void setInCombat(boolean inCombat) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline6.set("inCombat", inCombat);
}
notifyClients(buffer, true);
}
public void toggleCombat() {
setInCombat(!inCombat());
}
public List<TangibleObject> getDefendersList() {
return defendersList;
}
// All objects can be in combat (terminal mission flag bases, tutorial target box)
public void addDefender(TangibleObject defender) {
defendersList.add(defender);
if (!inCombat()) {
setInCombat(true);
}
}
public void removeDefender(TangibleObject defender) {
defendersList.remove(defender);
if (defendersList.isEmpty() && inCombat()) {
setInCombat(false);
}
}
public int getPvPBitmask() {
synchronized(objectMutex) {
return (int) otherVariables.get("pvpBitmask");
}
}
public void setPvPBitmask(int pvpBitmask) {
synchronized(objectMutex) {
otherVariables.set("pvpBitmask", pvpBitmask);
}
}
public boolean isAttackableBy(CreatureObject attacker) {
CreatureObject creature;
if (this instanceof CreatureObject) {
creature = (CreatureObject) this;
if (creature.getDuelList().contains(attacker) && attacker.getDuelList().contains(this)) {
return true;
}
}
if (getFaction().equals("rebel") && attacker.getFaction().equals("rebel")) {
return false;
} else if (getFaction().equals("imperial") && attacker.getFaction().equals("imperial")) {
return false;
} else if(attacker.getSlottedObject("ghost") != null) {
if (this instanceof CreatureObject && getSlottedObject("ghost") != null) {
creature = (CreatureObject) this;
if (creature.getFactionStatus() == 2 && attacker.getFactionStatus() == 2) {
return true;
} else {
return false;
}
}
if ((getFaction().equals("rebel") || getFaction().equals("imperial")) && attacker.getFactionStatus() >= 1) {
return true;
} else if ((getFaction().equals("rebel") || getFaction().equals("imperial")) && attacker.getFactionStatus() == 0) {
return false;
}
return getPvPBitmask() == 1 || getPvPBitmask() == 2;
}
return getPvPBitmask() == 1 || getPvPBitmask() == 2;
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, false);
}
@Override
public TangibleMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new TangibleMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
//destination.getSession().write(baseline8.getBaseline());
//destination.getSession().write(baseline9.getBaseline());
}
}
@Override
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
switch (viewType) {
case 3:
{
switch (updateType) {
case 7:
{
buffer = baseline3.createDelta(7, buffer.array());
notifyClients(buffer, true);
break;
}
}
}
}
}
}
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.universe;
import resources.z.exp.objects.ObjectMessageBuilder;
public class UniverseMessageBuilder extends ObjectMessageBuilder {
public UniverseMessageBuilder(UniverseObject object) {
super(object);
}
public UniverseMessageBuilder() {
super();
}
}
@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.universe;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.object.BaseObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class UniverseObject extends BaseObject {
@NotPersistent
private UniverseMessageBuilder messageBuilder;
public UniverseObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
}
public UniverseObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
return baseline;
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, false);
}
@Override
public UniverseMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new UniverseMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
}
}
@@ -0,0 +1,172 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.waypoint;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import resources.common.StringUtilities;
import resources.objects.IDelta;
import resources.z.exp.objects.intangible.IntangibleObject;
import resources.z.exp.objects.Baseline;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class WaypointObject extends IntangibleObject implements IDelta {
public static final byte BLUE, GREEN, ORANGE, YELLOW, PURPLE, WHITE, MULTICOLOR;
static {
BLUE = 1;
GREEN = 2;
ORANGE = 3;
YELLOW = 4;
PURPLE = 5;
WHITE = 6;
MULTICOLOR = 7;
};
// WAYP 3
private int cellId;
//private Point3D position = new Point3D(0, 0, 0);
private long targetId = 0;
private int planetCrc = 0;
private String name = "Waypoint";
//private long waypointId = 0;
private byte color = 1;
private boolean isActive = false;
public WaypointObject(long objectID, Planet planet, Point3D position) {
super(objectID, planet, position, new Quaternion(0, 0, 0, 1), "object/waypoint/shared_waypoint.iff");
}
public WaypointObject() {
super();
}
public int getCellId() {
synchronized(objectMutex) {
return cellId;
}
}
public void setCellId(int cellId) {
synchronized(objectMutex) {
this.cellId = cellId;
}
}
public long getTargetId() {
synchronized(objectMutex) {
return targetId;
}
}
public void setTargetId(long targetId) {
synchronized(objectMutex) {
this.targetId = targetId;
}
}
public int getPlanetCrc() {
synchronized(objectMutex) {
return planetCrc;
}
}
public void setPlanetCrc(int planetCrc) {
synchronized(objectMutex) {
this.planetCrc = planetCrc;
}
}
public String getName() {
synchronized(objectMutex) {
return name;
}
}
public void setName(String name) {
synchronized(objectMutex) {
this.name = name;
}
}
public byte getColor() {
synchronized(objectMutex) {
return color;
}
}
public void setColor(byte color) {
synchronized(objectMutex) {
this.color = color;
}
}
public boolean isActive() {
synchronized(objectMutex) {
return isActive;
}
}
public void setActive(boolean isActive) {
synchronized(objectMutex) {
this.isActive = isActive;
}
}
public void toggleActive() {
setActive(!isActive());
}
@Override
public void sendBaselines(Client destination) {
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = IoBuffer.allocate(42, false).order(ByteOrder.LITTLE_ENDIAN).setAutoExpand(true);
buffer.putInt(cellId);
buffer.putFloat(getPosition().x);
buffer.putFloat(getPosition().y);
buffer.putFloat(getPosition().z);
buffer.putLong(targetId);
buffer.putInt(planetCrc);
buffer.put(StringUtilities.getUnicodeString(name));
buffer.putLong(getObjectID());
buffer.put(color);
buffer.put(Baseline.getBoolean(isActive));
buffer.flip();
return buffer.array();
}
}
}
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.weapon;
import java.util.Map;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.Builder;
import resources.z.exp.objects.tangible.TangibleMessageBuilder;
public class WeaponMessageBuilder extends TangibleMessageBuilder {
public WeaponMessageBuilder(WeaponObject weaponObject) {
super(weaponObject);
}
public WeaponMessageBuilder() {
super();
}
@Override
public void buildBaseline3(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline3(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline6(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline6(baselineBuilders, deltaBuilders);
baselineBuilders.put(13, new Builder() {
public byte[] build() {
return Baseline.createBuffer(4).putInt(((WeaponObject) object).getWeaponType()).array();
}
});
deltaBuilders.put(13, new Builder() {
public byte[] build() {
return Baseline.createBuffer(4).putInt(((WeaponObject) object).getWeaponType()).array();
}
});
}
@Override
public void buildBaseline8(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline8(baselineBuilders, deltaBuilders);
}
@Override
public void buildBaseline9(Map<Integer, Builder> baselineBuilders, Map<Integer, Builder> deltaBuilders) {
super.buildBaseline9(baselineBuilders, deltaBuilders);
}
}
@@ -0,0 +1,246 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.objects.weapon;
import org.apache.mina.core.buffer.IoBuffer;
import resources.z.exp.objects.Baseline;
import resources.z.exp.objects.tangible.TangibleObject;
import com.sleepycat.persist.model.NotPersistent;
import com.sleepycat.persist.model.Persistent;
import engine.clients.Client;
import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
@Persistent
public class WeaponObject extends TangibleObject {
@NotPersistent
private WeaponMessageBuilder messageBuilder;
public WeaponObject(long objectID, Planet planet, String template) {
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0), template);
}
public WeaponObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String template) {
super(objectID, planet, position, orientation, template);
}
public WeaponObject() {
super();
}
@Override
public void initializeBaselines() {
super.initializeBaselines();
initializeBaseline(8);
initializeBaseline(9);
}
@Override
public Baseline getOtherVariables() {
Baseline baseline = super.getOtherVariables();
baseline.put("maxDamage", 0);
return baseline;
}
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
baseline.put("attackSpeed", (float) 1);
baseline.put("14", 0);
baseline.put("15", 0);
baseline.put("maxRange", calculateRange());
baseline.put("17", 0); // Could be lightsaber color? Seen as 2 on a saber
baseline.put("18", 0); // something to do with particle color
baseline.put("19", 0); // something to do with particle color
return baseline;
}
@Override
public Baseline getBaseline6() {
Baseline baseline = super.getBaseline6();
baseline.put("weaponType", 0);
return baseline;
}
@Override
public Baseline getBaseline8() {
Baseline baseline = super.getBaseline8();
return baseline;
}
@Override
public Baseline getBaseline9() {
Baseline baseline = super.getBaseline9();
return baseline;
}
public float getAttackSpeed() {
synchronized(objectMutex) {
return (float) baseline3.get("attackSpeed");
}
}
public void setAttackSpeed(float attackSpeed) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("attackSpeed", attackSpeed);
}
notifyClients(buffer, false);
}
private float calculateRange() {
int weaponType = getWeaponType();
switch (weaponType) {
case 4:
case 5:
case 6:
case 7:
case 9:
case 10:
case 11:
return 5;
case 2:
return 35;
case 1:
return 50;
case 0:
case 3:
case 8:
return 64;
default:
return 0;
}
}
public float getMaxRange() {
synchronized(objectMutex) {
return (float) baseline3.get("maxRange");
}
}
public void setMaxRange(float maxRange) {
IoBuffer buffer;
synchronized(objectMutex) {
buffer = baseline3.set("maxRange", maxRange);
}
notifyClients(buffer, false);
}
public int getWeaponType() {
String template = getTemplate();
int weaponType = -1;
synchronized(objectMutex) {
if (template == null) {
return weaponType;
}
if (template.contains("rifle")) weaponType = 0;
if (template.contains("carbine")) weaponType = 1;
if (template.contains("pistol")) weaponType = 2;
if (template.contains("heavy")) weaponType = 3;
if (template.contains("sword") || template.contains("baton")) weaponType = 4;
if (template.contains("2h_sword") || template.contains("axe")) weaponType = 5;
if (template.contains("unarmed")) weaponType = 6;
if (template.contains("polearm") || template.contains("lance")) weaponType = 7;
if (template.contains("thrown")) weaponType = 8;
if (template.contains("lightsaber_one_handed")) weaponType = 9;
if (template.contains("lightsaber_two_handed")) weaponType = 10;
if (template.contains("lightsaber_polearm")) weaponType = 11;
if (weaponType == -1) {
weaponType = 6;
}
return weaponType;
}
}
public int getMaxDamage() {
synchronized(objectMutex) {
return (int) otherVariables.get("maxDamage");
}
}
public void setMaxDamage(int maxDamage) {
synchronized(objectMutex) {
otherVariables.set("maxDamage", maxDamage);
}
}
public boolean isMelee() {
int weaponType = getWeaponType();
if ((weaponType > 4 && weaponType < 8) || (weaponType > 8 && weaponType < 12)) {
return true;
}
return false;
}
public boolean isRanged() {
int weaponType = getWeaponType();
if (weaponType == 0 || weaponType == 1 || weaponType == 2 || weaponType == 3) {
return true;
}
return false;
}
@Override
public void notifyClients(IoBuffer buffer, boolean notifySelf) {
notifyObservers(buffer, notifySelf);
}
@Override
public WeaponMessageBuilder getMessageBuilder() {
synchronized(objectMutex) {
if (messageBuilder == null) {
messageBuilder = new WeaponMessageBuilder(this);
}
return messageBuilder;
}
}
@Override
public void sendBaselines(Client destination) {
if (destination != null && destination.getSession() != null) {
//destination.getSession().write(baseline3.getBaseline());
//destination.getSession().write(baseline6.getBaseline());
//destination.getSession().write(baseline8.getBaseline());
//destination.getSession().write(baseline9.getBaseline());
}
}
}
+36
View File
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.quest;
import resources.objects.Delta;
public class Quest extends Delta {
public Quest() {
}
public byte[] getBytes() {
return new byte[] { };
}
}
+102
View File
@@ -0,0 +1,102 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* This File is part of NGECore2.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
package resources.z.exp.skills;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
import com.sleepycat.persist.model.Persistent;
import resources.objects.Delta;
// Proxy for engine.resources.objects.SkillMod so it uses Delta
@Persistent
public class SkillMod extends Delta {
private int base = 0;
private int modifier = 0;
public SkillMod(int base, int modifier) {
engine.resources.objects.SkillMod skillMod = new engine.resources.objects.SkillMod();
skillMod.setBase(base);
skillMod.setModifier(modifier);
this.base = skillMod.getBase();
this.modifier = skillMod.getModifier();
}
public SkillMod() {
}
public int getBase() {
synchronized(objectMutex) {
engine.resources.objects.SkillMod skillMod = new engine.resources.objects.SkillMod();
skillMod.setBase(base);
skillMod.setModifier(modifier);
return skillMod.getBase();
}
}
public void setBase(int base) {
synchronized(objectMutex) {
engine.resources.objects.SkillMod skillMod = new engine.resources.objects.SkillMod();
skillMod.setBase(this.base);
skillMod.setModifier(modifier);
skillMod.setBase(base);
this.base = skillMod.getBase();
}
}
public int getModifier() {
synchronized(objectMutex) {
engine.resources.objects.SkillMod skillMod = new engine.resources.objects.SkillMod();
skillMod.setBase(base);
skillMod.setModifier(modifier);
return skillMod.getModifier();
}
}
public void setModifier(int modifier) {
synchronized(objectMutex) {
engine.resources.objects.SkillMod skillMod = new engine.resources.objects.SkillMod();
skillMod.setBase(base);
skillMod.setModifier(this.modifier);
skillMod.setModifier(modifier);
this.modifier = skillMod.getModifier();
}
}
public byte[] getBytes() {
synchronized(objectMutex) {
IoBuffer buffer = bufferPool.allocate(8, false).order(ByteOrder.LITTLE_ENDIAN);
engine.resources.objects.SkillMod skillMod = new engine.resources.objects.SkillMod();
skillMod.setBase(base);
skillMod.setModifier(modifier);
buffer.putInt(skillMod.getBase());
buffer.putInt(skillMod.getModifier());
return buffer.array();
}
}
}
+1 -1
View File
@@ -361,7 +361,7 @@ public class CharacterService implements INetworkDispatch {
PreparedStatement ps2 = databaseConnection.preparedStatement("SELECT \"accountId\" FROM temp_reserved_char_names WHERE \"accountId\"!=? AND LOWER(\"firstName\")=?");
ps2.setLong(1, accountId);
ps2.setString(2, firstName);
ps2.setString(2, firstName.toLowerCase());
ResultSet resultSet2 = ps2.executeQuery();
boolean isReserved = resultSet2.next();
resultSet2.getStatement().close();
+1
View File
@@ -100,6 +100,7 @@ public class LoginService implements INetworkDispatch{
String user = clientID.getAccountName();
String pass = clientID.getPassword();
int id = LoginProvider.getAccountId(user, pass, session.getRemoteAddress().toString());
System.out.println("LOGIN: " + user + " login attempt "+session.getRemoteAddress().toString()+" returned " + id);
if (id < 0) {
+5 -1
View File
@@ -68,6 +68,7 @@ import engine.resources.common.CRC;
import engine.resources.objects.DraftSchematic;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
import engine.resources.service.INetworkDispatch;
import engine.resources.service.INetworkRemoteEvent;
@@ -475,12 +476,15 @@ public class PlayerService implements INetworkDispatch {
}
try {
String customServerTemplate = null;
if (!item.contains("/")) {
customServerTemplate = item;
item = core.scriptService.callScript("scripts/roadmap/", "roadmap_rewards", "get", item).asString();
}
if (item != null && item != "") {
creature.getSlottedObject("inventory").add(core.objectService.createObject(item, creature.getPlanet()));
creature.getSlottedObject("inventory").add(core.objectService.createObject(item, 0, creature.getPlanet(), new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), customServerTemplate));
} else {
//System.out.println("Can't find template: " + item);
}
+9 -1
View File
@@ -191,10 +191,18 @@ public class TerrainService {
public void run() {
Config config = new Config();
config.setFilePath("options.cfg");
boolean loaded = config.loadConfigFile();
if (config.loadConfigFile() && config.getInt("LOAD.SNAPSHOT_OBJECTS") > 0) {
if (loaded && config.getInt("LOAD.SNAPSHOT_OBJECTS") > 0) {
try {
core.objectService.loadSnapshotObjects(planet);
} catch (Exception e) {
e.printStackTrace();
}
}
if (loaded && config.getInt("LOAD.BUILDOUT_OBJECTS") > 0) {
try {
core.objectService.loadBuildoutObjects(planet);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
+2 -2
View File
@@ -225,7 +225,7 @@ public class ObjectService implements INetworkDispatch {
object.setPlanetId(planet.getID());
object.setAttachment("serverTemplate", ((customServerTemplate != null) ? customServerTemplate : object.getTemplate()));
object.setAttachment("customServerTemplate", customServerTemplate);
object.setisInSnapshot(isSnapshot);
loadServerTemplate(object);
@@ -268,7 +268,7 @@ public class ObjectService implements INetworkDispatch {
public void loadServerTemplate(SWGObject object) {
String template = ((object.getAttachment("serverTemplate") == null) ? object.getTemplate() : ((String) object.getAttachment("serverTemplate")));
String template = ((object.getAttachment("customServerTemplate") == null) ? object.getTemplate() : (object.getTemplate().split("shared_")[0] + "shared_" + ((String) object.getAttachment("customServerTemplate")) + ".iff"));
String serverTemplate = template.replace(".iff", "");
// check if template is empty(4 default lines) to reduce RAM usage(saves about 500 MB of RAM)
try {