Merge pull request #12 from ProjectSWGCore/master

pull
This commit is contained in:
Zing
2014-09-05 08:02:05 -07:00
11 changed files with 82 additions and 215 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ def handleSelection(core, owner, target, option):
if owner.getCombatFlag() == 1:
owner.sendSystemMessage('You can\'t use that while in combat.', 0)
return
tpm = EnterTicketPurchaseModeMessage(owner.getPlanet().getName(), core.mapService.getClosestCityName(owner), owner)
tpm = EnterTicketPurchaseModeMessage(owner.getPlanet().getName(), core.mapService.getClosestCityName(owner), False)
owner.getClient().getSession().write(tpm.serialize())
return
return
@@ -14,7 +14,7 @@ def handleSelection(core, owner, target, option):
if owner.getCombatFlag() == 1:
owner.sendSystemMessage('You can\'t use that while in combat.', 0)
return
tpm = EnterTicketPurchaseModeMessage(owner.getPlanet().getName(), core.mapService.getClosestCityName(owner), owner, True)
tpm = EnterTicketPurchaseModeMessage(owner.getPlanet().getName(), core.mapService.getClosestCityName(owner), True)
owner.getClient().getSession().write(tpm.serialize())
return
return
@@ -23,32 +23,21 @@ package protocol.swg;
import java.nio.ByteOrder;
import main.NGECore;
import org.apache.mina.core.buffer.IoBuffer;
import services.travel.TravelPoint;
import engine.resources.objects.SWGObject;
import resources.common.Opcodes;
import engine.resources.common.StringUtilities;
@SuppressWarnings("unused")
public class EnterTicketPurchaseModeMessage extends SWGMessage {
private String planetName;
private String cityName;
private SWGObject player;
private boolean isItv = false;
private String nearestPointName;
private boolean isInstant = false;
public EnterTicketPurchaseModeMessage(String planetName, String cityName, SWGObject player, boolean isItv) {
public EnterTicketPurchaseModeMessage(String planetName, String nearestPointName, boolean isInstant) {
this.planetName = planetName;
this.cityName = cityName;
this.player = player;
this.isItv = true;
}
public EnterTicketPurchaseModeMessage(String planetName, String cityName, SWGObject player) {
this.planetName = planetName;
this.cityName = cityName;
this.player = player;
this.nearestPointName = nearestPointName;
this.isInstant = isInstant;
}
@Override
@@ -58,22 +47,13 @@ public class EnterTicketPurchaseModeMessage extends SWGMessage {
@Override
public IoBuffer serialize() {
final NGECore core = NGECore.getInstance();
TravelPoint nearestPoint = null;
if (!isItv) nearestPoint = core.travelService.getNearestTravelPoint(player);
else nearestPoint = core.travelService.getNearestTravelPoint(player, 5120);
IoBuffer result = IoBuffer.allocate(11 + planetName.length() + nearestPoint.getName().length()).order(ByteOrder.LITTLE_ENDIAN);
IoBuffer result = IoBuffer.allocate(11 + planetName.length() + nearestPointName.length()).order(ByteOrder.LITTLE_ENDIAN);
result.putShort((short) 3);
result.putInt(0x904DAE1A);
result.put(getAsciiString(planetName));
result.put(getAsciiString(nearestPoint.getName()));
result.put((byte) 0);
result.putInt(Opcodes.EnterTicketPurchaseModeMessage);
result.put(StringUtilities.getAsciiString(planetName));
result.put(StringUtilities.getAsciiString(nearestPointName));
result.put(isInstant ? (byte) 1 : (byte) 0);
return result.flip();
}
@@ -21,8 +21,8 @@
******************************************************************************/
package protocol.swg.auctionManagerClientListener;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import org.apache.mina.core.buffer.IoBuffer;
@@ -35,6 +35,7 @@ public class AuctionQueryHeadersMessage extends SWGMessage {
private int screen;
private int category;
private int itemTypeCRC;
private byte unk;
private String searchString;
private int unkInt;
private int minPrice;
@@ -47,28 +48,26 @@ public class AuctionQueryHeadersMessage extends SWGMessage {
@Override
public void deserialize(IoBuffer data) {
data.skip(6);
setRange(data.getInt());
setCounter(data.getInt());
setScreen(data.getInt());
setCategory(data.getInt());
setItemTypeCRC(data.getInt());
data.get(); // unk
this.range = data.getInt();
this.counter = data.getInt();
this.screen = data.getInt();
this.category = data.getInt();
this.itemTypeCRC = data.getInt();
this.unk = data.get();
int size = data.getInt();
try {
setSearchString(new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), "UTF-16LE"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
this.searchString = new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), StandardCharsets.UTF_16LE);
data.position(data.position() + size * 2);
setUnkInt(data.getInt());
setMinPrice(data.getInt());
setMaxPrice(data.getInt());
setIncludeEntranceFee(data.get());
this.unkInt = data.getInt();
this.minPrice = data.getInt();
this.maxPrice = data.getInt();
this.includeEntranceFee = data.get(); // Ziggy - boolean?
data.skip(5); // unk
setVendorId(data.getLong());
setVendorFlag(data.get());
setOffset(data.getShort());
this.vendorId = data.getLong();
this.vendorFlag = data.get();
this.offset = data.getShort();
}
@@ -82,104 +81,56 @@ public class AuctionQueryHeadersMessage extends SWGMessage {
return range;
}
public void setRange(int range) {
this.range = range;
}
public int getCounter() {
return counter;
}
public void setCounter(int counter) {
this.counter = counter;
}
public int getScreen() {
return screen;
}
public void setScreen(int screen) {
this.screen = screen;
}
public int getCategory() {
return category;
}
public void setCategory(int category) {
this.category = category;
}
public int getItemTypeCRC() {
return itemTypeCRC;
}
public void setItemTypeCRC(int itemTypeCRC) {
this.itemTypeCRC = itemTypeCRC;
}
public String getSearchString() {
return searchString;
}
public void setSearchString(String searchString) {
this.searchString = searchString;
}
public int getUnkInt() {
return unkInt;
}
public void setUnkInt(int unkInt) {
this.unkInt = unkInt;
}
public int getMinPrice() {
return minPrice;
}
public void setMinPrice(int minPrice) {
this.minPrice = minPrice;
}
public int getMaxPrice() {
return maxPrice;
}
public void setMaxPrice(int maxPrice) {
this.maxPrice = maxPrice;
}
public byte getIncludeEntranceFee() {
return includeEntranceFee;
}
public void setIncludeEntranceFee(byte includeEntranceFee) {
this.includeEntranceFee = includeEntranceFee;
}
public long getVendorId() {
return vendorId;
}
public void setVendorId(long vendorId) {
this.vendorId = vendorId;
}
public byte getVendorFlag() {
return vendorFlag;
}
public void setVendorFlag(byte vendorFlag) {
this.vendorFlag = vendorFlag;
}
public short getOffset() {
return offset;
}
public void setOffset(short offset) {
this.offset = offset;
public byte getUnk() {
return unk;
}
}
@@ -21,8 +21,8 @@
******************************************************************************/
package protocol.swg.auctionManagerClientListener;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import org.apache.mina.core.buffer.IoBuffer;
@@ -35,24 +35,21 @@ public class CreateAuctionMessage extends SWGMessage {
private int price;
private int duration;
private String description;
private byte premium;
private boolean isPremium;
@Override
public void deserialize(IoBuffer data) {
data.skip(6);
setObjectId(data.getLong());
this.objectId = data.getLong();
int size = data.getInt();
try {
setDescription(new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), "UTF-16LE"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
data.position(data.position() + size * 2);
this.description = new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), StandardCharsets.UTF_16LE);
setVendorId(data.getLong());
setPrice(data.getInt());
setDuration(data.getInt()); // in minutes
setPremium(data.get());
data.position(data.position() + size * 2);
this.vendorId = data.getLong();
this.price = data.getInt();
this.duration = data.getInt(); // in minutes
this.isPremium = (data.get() == 0 ? false : true);
}
@Override
@@ -65,50 +62,24 @@ public class CreateAuctionMessage extends SWGMessage {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public long getVendorId() {
return vendorId;
}
public void setVendorId(long vendorId) {
this.vendorId = vendorId;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean getPremium() {
if(premium == 1)
return true;
return false;
}
public void setPremium(byte premium) {
this.premium = premium;
public boolean isPremium() {
return isPremium;
}
}
@@ -21,8 +21,8 @@
******************************************************************************/
package protocol.swg.auctionManagerClientListener;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import org.apache.mina.core.buffer.IoBuffer;
@@ -35,23 +35,21 @@ public class CreateImmediateAuctionMessage extends SWGMessage {
private int price;
private int duration;
private String description;
private byte premium;
private boolean isPremium;
@Override
public void deserialize(IoBuffer data) {
data.skip(6);
setObjectId(data.getLong());
setVendorId(data.getLong());
setPrice(data.getInt());
setDuration(data.getInt()); // in minutes
this.objectId = data.getLong();
this.vendorId = data.getLong();
this.price = data.getInt();
this.duration = data.getInt();
int size = data.getInt();
try {
setDescription(new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), "UTF-16LE"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
this.description = new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), StandardCharsets.UTF_16LE);
data.position(data.position() + size * 2);
setPremium(data.get());
this.isPremium = (data.get() == 0 ? false : true);
}
@Override
@@ -64,50 +62,27 @@ public class CreateImmediateAuctionMessage extends SWGMessage {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public long getVendorId() {
return vendorId;
}
public void setVendorId(long vendorId) {
this.vendorId = vendorId;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
/*
* @return Duration in minutes
*/
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean getPremium() {
if(premium == 1)
return true;
return false;
}
public void setPremium(byte premium) {
this.premium = premium;
public boolean isPremium() {
return isPremium;
}
}
@@ -21,7 +21,6 @@
******************************************************************************/
package protocol.swg.chat;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -21,13 +21,11 @@
******************************************************************************/
package protocol.swg.objectControllerObjects;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import org.apache.mina.core.buffer.IoBuffer;
@SuppressWarnings("unused")
public class CommandEnqueue extends ObjControllerObject {
public static final int SOCIAL_INTERNAL = 0x32CF1BEE;
@@ -48,7 +46,7 @@ public class CommandEnqueue extends ObjControllerObject {
public static final int FLO = 0x3B159B76;
public static final int BANDFLOURISH = 0xF4C60EC3;
public static final int BANDFLO = 0xDD3FB008;
private int actionCounter;
private int commandCRC;
private long targetId;
@@ -56,31 +54,22 @@ public class CommandEnqueue extends ObjControllerObject {
private final int commandObjectIndex = 20;
private long objectId;
private String commandArguments;
public CommandEnqueue() {
}
public CommandEnqueue(int actionCounter, ObjControllerObject commandObject) {
this.actionCounter = actionCounter;
this.commandObject = commandObject;
}
public void deserialize(IoBuffer buffer) {
objectId = buffer.getLong();
buffer.getInt();
actionCounter = buffer.getInt();
int size;
this.objectId = buffer.getLong();
buffer.getInt(); // Ziggy - related to commandObjectIndex?
this.actionCounter = buffer.getInt();
this.commandCRC = buffer.getInt();
this.targetId = buffer.getLong();
size = buffer.getInt();
commandCRC = buffer.getInt();
targetId = buffer.getLong();
int size = buffer.getInt();
try {
commandArguments = new String(ByteBuffer.allocate(size * 2).put(buffer.array(), buffer.position(), size * 2).array(), "UTF-16LE");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//commandArguments = getNextUnicodeString(buffer);
//commandObject = getCommandObject(commandCRC);
commandArguments = new String(ByteBuffer.allocate(size * 2).put(buffer.array(), buffer.position(), size * 2).array(), StandardCharsets.UTF_16LE);
}
public IoBuffer serialize() {
+2
View File
@@ -100,5 +100,7 @@ public class Opcodes {
public static final int CreateCharacterSuccess = 0x1DB575CC;
public static final int PlayerMoneyResponse = 0x367E737E;
public static final int CmdStartScene = 0x3AE6DFAE;
public static final int IncubatorStartMessage = CRC.StringtoCRC("IncubatorStartMessage");
public static final int EnterTicketPurchaseModeMessage = 0x904DAE1A;
}
@@ -1351,7 +1351,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
}
public void sendSystemMessage(String message, OutOfBand outOfBand, byte displayType) {
notifySelf((new ChatSystemMessage(message, outOfBand, displayType)).serialize())};
notifySelf((new ChatSystemMessage(message, outOfBand, displayType)).serialize());
}
public void playMusic(String sndFile) {
@@ -1371,7 +1371,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
}
public void playMusic(String sndFile, long targetId, int repetitions, boolean flag) {
notifySelf(new PlayMusicMessage(sndFile, targetId, 1, false));
notifySelf((new PlayMusicMessage(sndFile, targetId, 1, false)).serialize());
}
public TangibleObject getInventory() {
+2 -2
View File
@@ -331,7 +331,7 @@ public class BazaarService implements INetworkDispatch {
if(vendor == null || item == null || item instanceof CreatureObject || item instanceof BuildingObject)
return;
addAuction((CreatureObject) player, item, vendor, createAuction.getPrice(), createAuction.getDuration(), createAuction.getDescription(), true, createAuction.getPremium());
addAuction((CreatureObject) player, item, vendor, createAuction.getPrice(), createAuction.getDuration(), createAuction.getDescription(), true, createAuction.isPremium());
});
@@ -359,7 +359,7 @@ public class BazaarService implements INetworkDispatch {
if(vendor == null || item == null || item instanceof CreatureObject || item instanceof BuildingObject)
return;
addAuction((CreatureObject) player, item, vendor, createAuction.getPrice(), createAuction.getDuration(), createAuction.getDescription(), false, createAuction.getPremium());
addAuction((CreatureObject) player, item, vendor, createAuction.getPrice(), createAuction.getDuration(), createAuction.getDescription(), false, createAuction.isPremium());
});