diff --git a/scripts/commands/of_buff_def_1.py b/scripts/commands/of_buff_def_1.py index dcc1881b..a83218bd 100644 --- a/scripts/commands/of_buff_def_1.py +++ b/scripts/commands/of_buff_def_1.py @@ -4,9 +4,7 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - - core.buffService.addGroupBuff(target, 'of_buff_def_1', actor) + + core.buffService.addGroupBuff(actor, 'of_buff_def_1', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_2.py b/scripts/commands/of_buff_def_2.py index 9b018174..f8f1b6be 100644 --- a/scripts/commands/of_buff_def_2.py +++ b/scripts/commands/of_buff_def_2.py @@ -4,8 +4,7 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_2', actor) + + core.buffService.addGroupBuff(actor, 'of_buff_def_2', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_3.py b/scripts/commands/of_buff_def_3.py index 45cbf987..9215bcf2 100644 --- a/scripts/commands/of_buff_def_3.py +++ b/scripts/commands/of_buff_def_3.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_3', actor) + core.buffService.addGroupBuff(actor, 'of_buff_def_3', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_4.py b/scripts/commands/of_buff_def_4.py index 43627e27..819db023 100644 --- a/scripts/commands/of_buff_def_4.py +++ b/scripts/commands/of_buff_def_4.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_4', actor) + core.buffService.addGroupBuff(actor, 'of_buff_def_4', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_5.py b/scripts/commands/of_buff_def_5.py index 3f9fdc33..f919171c 100644 --- a/scripts/commands/of_buff_def_5.py +++ b/scripts/commands/of_buff_def_5.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_5', actor) + core.buffService.addGroupBuff(actor, 'of_buff_def_5', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_6.py b/scripts/commands/of_buff_def_6.py index 00d8b7e3..54aaa36e 100644 --- a/scripts/commands/of_buff_def_6.py +++ b/scripts/commands/of_buff_def_6.py @@ -4,8 +4,7 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_6', actor) + + core.buffService.addGroupBuff(actor, 'of_buff_def_6', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_7.py b/scripts/commands/of_buff_def_7.py index a5dd7341..a7b8e72a 100644 --- a/scripts/commands/of_buff_def_7.py +++ b/scripts/commands/of_buff_def_7.py @@ -4,8 +4,7 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_7', actor) + + core.buffService.addGroupBuff(actor, 'of_buff_def_7', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_8.py b/scripts/commands/of_buff_def_8.py index 9fd12b12..d84ba723 100644 --- a/scripts/commands/of_buff_def_8.py +++ b/scripts/commands/of_buff_def_8.py @@ -4,8 +4,7 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_8', actor) + + core.buffService.addGroupBuff(actor, 'of_buff_def_8', actor) return \ No newline at end of file diff --git a/scripts/commands/of_buff_def_9.py b/scripts/commands/of_buff_def_9.py index 116775df..45f6a8f8 100644 --- a/scripts/commands/of_buff_def_9.py +++ b/scripts/commands/of_buff_def_9.py @@ -4,8 +4,7 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_buff_def_9', actor) + + core.buffService.addGroupBuff(actor, 'of_buff_def_9', actor) return \ No newline at end of file diff --git a/scripts/commands/of_focus_fire_1.py b/scripts/commands/of_focus_fire_1.py index 9fdb7d5c..1cd0503c 100644 --- a/scripts/commands/of_focus_fire_1.py +++ b/scripts/commands/of_focus_fire_1.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_focus_fire_1', actor) + core.buffService.addGroupBuff(actor, 'of_focus_fire_1', actor) return \ No newline at end of file diff --git a/scripts/commands/of_focus_fire_2.py b/scripts/commands/of_focus_fire_2.py index 92d99f17..b7fe9e07 100644 --- a/scripts/commands/of_focus_fire_2.py +++ b/scripts/commands/of_focus_fire_2.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_focus_fire_2', actor) + core.buffService.addGroupBuff(actor, 'of_focus_fire_2', actor) return \ No newline at end of file diff --git a/scripts/commands/of_focus_fire_3.py b/scripts/commands/of_focus_fire_3.py index f5900d0a..a7cd6223 100644 --- a/scripts/commands/of_focus_fire_3.py +++ b/scripts/commands/of_focus_fire_3.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_focus_fire_3', actor) + core.buffService.addGroupBuff(actor, 'of_focus_fire_3', actor) return \ No newline at end of file diff --git a/scripts/commands/of_focus_fire_4.py b/scripts/commands/of_focus_fire_4.py index 9f6dc518..208f53e5 100644 --- a/scripts/commands/of_focus_fire_4.py +++ b/scripts/commands/of_focus_fire_4.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_focus_fire_4', actor) + core.buffService.addGroupBuff(actor, 'of_focus_fire_4', actor) return \ No newline at end of file diff --git a/scripts/commands/of_focus_fire_5.py b/scripts/commands/of_focus_fire_5.py index dc51c2e6..7842cb4f 100644 --- a/scripts/commands/of_focus_fire_5.py +++ b/scripts/commands/of_focus_fire_5.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_focus_fire_5', actor) + core.buffService.addGroupBuff(actor, 'of_focus_fire_5', actor) return \ No newline at end of file diff --git a/scripts/commands/of_focus_fire_6.py b/scripts/commands/of_focus_fire_6.py index 674a5bec..ae915fa1 100644 --- a/scripts/commands/of_focus_fire_6.py +++ b/scripts/commands/of_focus_fire_6.py @@ -4,8 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - if target is None: - target = actor - core.buffService.addGroupBuff(target, 'of_focus_fire_6', actor) + core.buffService.addGroupBuff(actor, 'of_focus_fire_6', actor) return \ No newline at end of file diff --git a/src/protocol/swg/ShowBackpack.java b/src/protocol/swg/ShowBackpack.java new file mode 100644 index 00000000..04ba5b3b --- /dev/null +++ b/src/protocol/swg/ShowBackpack.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * 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 . + * + * 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 protocol.swg; + +import org.apache.mina.core.buffer.IoBuffer; + +public class ShowBackpack extends SWGMessage { + + private long objectId; + private boolean showBackpack; + + public ShowBackpack() { } + + @Override + public void deserialize(IoBuffer data) { + setObjectId(data.getLong()); + setShowBackpack((data.get() == 1) ? true : false); + } + + public long getObjectId() { + return objectId; + } + + public boolean isShowBackpack() { + return showBackpack; + } + + @Override + public IoBuffer serialize() { + return null; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public void setShowBackpack(boolean showBackpack) { + this.showBackpack = showBackpack; + } + +} diff --git a/src/protocol/swg/ShowHelmet.java b/src/protocol/swg/ShowHelmet.java new file mode 100644 index 00000000..4c5c2ecb --- /dev/null +++ b/src/protocol/swg/ShowHelmet.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * 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 . + * + * 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 protocol.swg; + +import org.apache.mina.core.buffer.IoBuffer; + +public class ShowHelmet extends SWGMessage { + + private long objectId; + private boolean showHelmet; + + public ShowHelmet() { } + + @Override + public void deserialize(IoBuffer data) { + setObjectId(data.getLong()); + setShowHelmet((data.get() == 1) ? true : false); + } + + public long getObjectId() { + return objectId; + } + + public boolean isShowHelmet() { + return showHelmet; + } + + @Override + public IoBuffer serialize() { + return null; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public void setShowHelmet(boolean showHelmet) { + this.showHelmet = showHelmet; + } + +} diff --git a/src/resources/common/Opcodes.java b/src/resources/common/Opcodes.java index f9284c25..a97993f9 100644 --- a/src/resources/common/Opcodes.java +++ b/src/resources/common/Opcodes.java @@ -73,6 +73,8 @@ public class Opcodes { public static int SetFurnitureRoationDegree = CRC.StringtoCRC("SetFurnitureRotationDegree"); public static int SetJediSlotInfo = CRC.StringtoCRC("SetJediSlotInfo"); public static int CollectionServerFirstListRequest = CRC.StringtoCRC("CollectionServerFirstListRequest"); - + public static int ShowHelmet = CRC.StringtoCRC("ShowHelmet"); + public static int ShowBackpack = CRC.StringtoCRC("ShowBackpack"); + public static int Unknown = 0x173B91C2; // packet sent to server on every character load-in } diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index ca901719..41df49b1 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -70,7 +70,7 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { else buffer.put(getAsciiString(player.getTitle())); - buffer.putInt(0); // born date? + buffer.putInt(0); // born date - Needs to be in yyymmdd format - Stored as epoch time of character create buffer.putInt(player.getTotalPlayTime()); // total play time? @@ -86,8 +86,8 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { buffer.put(player.getCollections()); buffer.putInt(0); // Unknown, part of one delta, maybe a list buffer.putInt(0); // Unknown, part of one delta, maybe a list - buffer.put((byte) 0); // Unknown Boolean used in Tansarii - buffer.put((byte) 0); // Unknown Boolean used in Tansarii + buffer.put((byte) ((player.isShowBackpack()) ? 1 : 0)); + buffer.put((byte) ((player.isShowHelmet()) ? 1 : 0)); int size = buffer.position(); @@ -633,6 +633,30 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { return buffer; } + public IoBuffer buildShowBackpackDelta(boolean showBackpack) { + IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put((byte) (showBackpack ? 1 : 0)); + + int size = buffer.position(); + buffer.flip(); + + buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 18, buffer, size + 4); + return buffer; + } + + public IoBuffer buildShowHelmetDelta(boolean showHelmet) { + IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put((byte) (showHelmet ? 1 : 0)); + + int size = buffer.position(); + buffer.flip(); + + buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 19, buffer, size + 4); + return buffer; + } + @Override public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { // TODO Auto-generated method stub diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 73eb9787..fb284587 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -43,7 +43,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=6) +@Persistent(version=7) public class PlayerObject extends IntangibleObject { // PLAY 3 @@ -54,11 +54,13 @@ public class PlayerObject extends IntangibleObject { private List flagsList = new ArrayList(); private List profileList = new ArrayList(); private List titleList = new ArrayList(); - private int bornDate = 0; + private long bornDate = 0; private int totalPlayTime = 0; private byte[] collections = new byte[] { }; private int highestSetBit = 0; private int flagBitmask = 0; + private boolean showHelmet = true; + private boolean showBackpack = true; // PLAY 6 @@ -180,13 +182,13 @@ public class PlayerObject extends IntangibleObject { return profileList; } - public int getBornDate() { + public long getBornDate() { synchronized(objectMutex) { return bornDate; } } - public void setBornDate(int bornDate) { + public void setBornDate(long bornDate) { synchronized(objectMutex) { this.bornDate = bornDate; } @@ -758,4 +760,32 @@ public class PlayerObject extends IntangibleObject { public void setHoloEmoteUses(int holoEmoteUses) { this.holoEmoteUses = holoEmoteUses; } + + public boolean isShowHelmet() { + return showHelmet; + } + + public void setShowHelmet(boolean showHelmet) { + synchronized(objectMutex) { + this.showHelmet = showHelmet; + } + + if (getContainer() != null) { + getContainer().getClient().getSession().write(messageBuilder.buildShowHelmetDelta(showHelmet)); + } + } + + public boolean isShowBackpack() { + return showBackpack; + } + + public void setShowBackpack(boolean showBackpack) { + synchronized(objectMutex) { + this.showBackpack = showBackpack; + } + + if (getContainer() != null) { + getContainer().getClient().getSession().write(messageBuilder.buildShowBackpackDelta(showBackpack)); + } + } } diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 4f33063e..5977b9be 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -26,6 +26,7 @@ import java.nio.ByteOrder; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Calendar; import java.util.Map; import main.NGECore; @@ -34,6 +35,7 @@ import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; + import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; @@ -286,6 +288,8 @@ public class CharacterService implements INetworkDispatch { object.addObjectToEquipList(hair); } + player.setBornDate((int) System.currentTimeMillis()); + TangibleObject inventory = (TangibleObject) core.objectService.createObject("object/tangible/inventory/shared_character_inventory.iff", object.getPlanet()); inventory.setContainerPermissions(CreatureContainerPermissions.CREATURE_CONTAINER_PERMISSIONS); TangibleObject appInventory = (TangibleObject) core.objectService.createObject("object/tangible/inventory/shared_appearance_inventory.iff", object.getPlanet()); diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 70447466..9adfe894 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -52,6 +52,8 @@ import protocol.swg.ObjControllerMessage; import protocol.swg.PlayerMoneyResponse; import protocol.swg.ServerTimeMessage; import protocol.swg.SetWaypointColor; +import protocol.swg.ShowBackpack; +import protocol.swg.ShowHelmet; import protocol.swg.objectControllerObjects.ChangeRoleIconChoice; import protocol.swg.objectControllerObjects.ShowFlyText; import protocol.swg.objectControllerObjects.ShowLootBox; @@ -155,7 +157,55 @@ public class PlayerService implements INetworkDispatch { @Override public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { - + + swgOpcodes.put(Opcodes.ShowBackpack, (session, data) -> { + data.order(ByteOrder.LITTLE_ENDIAN); + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + PlayerObject ghost = (PlayerObject) player.getSlottedObject("ghost"); + + if (ghost == null) + return; + + ShowBackpack sentPacket = new ShowBackpack(); + sentPacket.deserialize(data); + + ghost.setShowBackpack(sentPacket.isShowBackpack()); + }); + + swgOpcodes.put(Opcodes.ShowHelmet, (session, data) -> { + data.order(ByteOrder.LITTLE_ENDIAN); + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + PlayerObject ghost = (PlayerObject) player.getSlottedObject("ghost"); + + if (ghost == null) + return; + + ShowHelmet sentPacket = new ShowHelmet(); + sentPacket.deserialize(data); + + ghost.setShowHelmet(sentPacket.isShowHelmet()); + }); + objControllerOpcodes.put(ObjControllerOpcodes.ChangeRoleIconChoice, (session, data) -> { Client c = core.getClient(session);