From e190bc78f627276b9d154da5a77aa69187708690 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 12 Dec 2013 11:54:52 +0000 Subject: [PATCH] Added ChangeRoleIcon (gold icons), fixed titles --- .../ChangeRoleIconChoice.java | 54 +++++++++++++++++++ .../common/ObjControllerOpcodes.java | 1 + .../objects/player/PlayerMessageBuilder.java | 47 ++++------------ .../objects/player/PlayerObject.java | 46 +++++++++++++++- src/services/CharacterService.java | 1 + src/services/PlayerService.java | 29 +++++++++- 6 files changed, 137 insertions(+), 41 deletions(-) create mode 100644 src/protocol/swg/objectControllerObjects/ChangeRoleIconChoice.java diff --git a/src/protocol/swg/objectControllerObjects/ChangeRoleIconChoice.java b/src/protocol/swg/objectControllerObjects/ChangeRoleIconChoice.java new file mode 100644 index 00000000..1cbc0909 --- /dev/null +++ b/src/protocol/swg/objectControllerObjects/ChangeRoleIconChoice.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.objectControllerObjects; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +public class ChangeRoleIconChoice extends ObjControllerObject { + + private long objectId = 0; + private int icon = 0; + + @Override + public IoBuffer serialize() { + return null; + } + + @Override + public void deserialize(IoBuffer buffer) { + buffer.flip().order(ByteOrder.LITTLE_ENDIAN); + objectId = buffer.getLong(); + buffer.skip(4); + icon = buffer.getInt(); + } + + public long getObjectId() { + return objectId; + } + + public int getIcon() { + return icon; + } + +} diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index db8ef253..7d6e6b21 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -32,5 +32,6 @@ public class ObjControllerOpcodes { public static final int SECURE_TRADE = 0x15010000; public static final int BUFF_BUILDER_CHANGE = 0x5A020000; public static final int MISSION_LIST_REQUEST = 0xF5000000; + public static final int ChangeRoleIconChoice = 0x4D040000; } diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index 7259f319..eec676ab 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -34,16 +34,6 @@ import resources.objects.waypoint.WaypointObject; public class PlayerMessageBuilder extends ObjectMessageBuilder { - public static final String SPY = "spy_1a"; - public static final String SMUGGLER = "smuggler_1a"; - public static final String OFFICER = "officer_1a"; - public static final String JEDI = "force_sensitive_1a"; - public static final String COMMANDO = "commando_1a"; - public static final String ENTERTAINER = "entertainer_1a"; - public static final String MEDIC = "medic_1a"; - public static final String BOUNTYHUNTER = "bounty_hunter_1a"; - - public PlayerMessageBuilder(PlayerObject playerObject) { setObject(playerObject); } @@ -84,7 +74,7 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { buffer.putInt(player.getTotalPlayTime()); // total play time? - buffer.putInt(getProfData(player.getProfession())); // prof icon + buffer.putInt(player.getProfessionIcon()); buffer.put(getAsciiString(player.getProfession())); buffer.putInt(0); // GCW @@ -350,6 +340,15 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { } + public IoBuffer buildProfessionIconDelta(int professionIcon) { + IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(professionIcon); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x0A, buffer, size + 4); + return buffer; + } + public IoBuffer buildCollectionsDelta(byte[] collections, int highestSetBit) { IoBuffer buffer = bufferPool.allocate(8 + collections.length, false).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(collections.length); @@ -599,32 +598,6 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { return buffer; } - public int getProfData(String profession) { - - switch (profession) { - - case SPY: - return 0x23; - case SMUGGLER: - return 0x19; - case OFFICER: - return 0x0F; - case JEDI: - return 0x28; - case COMMANDO: - return 0x1E; - case ENTERTAINER: - return 0x05; - case MEDIC: - return 0x0A; - case BOUNTYHUNTER: - return 0x14; - default: - return 0x00; - - } - } - @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 eb9d58c5..b07ef567 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -41,13 +41,14 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=1) +@Persistent(version=2) public class PlayerObject extends SWGObject { // PLAY 3 private String title; private String profession; + private int professionIcon; private List flagsList = new ArrayList(); private List profileList = new ArrayList(); private List titleList = new ArrayList(); @@ -146,7 +147,9 @@ public class PlayerObject extends SWGObject { } - notifyObservers(messageBuilder.buildTitleDelta(title), true); + if (getContainer() != null) { + getContainer().notifyObservers(messageBuilder.buildTitleDelta(title), true); + } } public String getProfession() { @@ -639,4 +642,43 @@ public class PlayerObject extends SWGObject { } } + public int getProfessionIcon() { + synchronized(objectMutex) { + return professionIcon; + } + } + + public void setProfessionIcon(int professionIcon) { + synchronized(objectMutex) { + this.professionIcon = professionIcon; + } + + if (getContainer() != null) { + getContainer().notifyObservers(messageBuilder.buildProfessionIconDelta(professionIcon), true); + } + } + + public int getProfData(String profession) { + switch (profession) { + case "spy_1a": + return 0x23; + case "smuggler_1a": + return 0x19; + case "officer_1a": + return 0x0F; + case "force_sensitive_1a": + return 0x28; + case "commando_1a": + return 0x1E; + case "entertainer_1a": + return 0x05; + case "medic_1a": + return 0x0A; + case "bounty_hunter_1a": + return 0x14; + default: + return 0x00; + } + } + } diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index cb10847f..6152f7d0 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -251,6 +251,7 @@ public class CharacterService implements INetworkDispatch { object._add(player); core.skillService.addSkill(object, "species_" + object.getStfName()); player.setProfession(clientCreateCharacter.getProfession()); + player.setProfessionIcon(player.getProfData(clientCreateCharacter.getProfession())); player.setProfessionWheelPosition(clientCreateCharacter.getProfessionWheelPosition()); if(clientCreateCharacter.getHairObject().length() > 0) { String sharedHairTemplate = clientCreateCharacter.getHairObject().replace("/hair_", "/shared_hair_"); diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 55d8d2ee..a0c536eb 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -41,9 +41,11 @@ import protocol.swg.ClientIdMsg; import protocol.swg.ClientMfdStatusUpdateMessage; import protocol.swg.ExpertiseRequestMessage; import protocol.swg.ServerTimeMessage; +import protocol.swg.objectControllerObjects.ChangeRoleIconChoice; import protocol.swg.objectControllerObjects.ShowFlyText; import resources.common.Console; import resources.common.FileUtilities; +import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RGB; import resources.common.SpawnPoint; @@ -149,6 +151,31 @@ public class PlayerService implements INetworkDispatch { @Override public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + objControllerOpcodes.put(ObjControllerOpcodes.ChangeRoleIconChoice, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + Client c = core.getClient((Integer) session.getAttribute("connectionId")); + ChangeRoleIconChoice packet = new ChangeRoleIconChoice(); + PlayerObject player; + SWGObject o; + + packet.deserialize(data); + o = core.objectService.getObject(packet.getObjectId()); + + if (c.getParent() == null || o == null || c.getParent() != o + || !(o instanceof CreatureObject) || !(o.getSlottedObject("ghost") + instanceof PlayerObject)) { + return; + } + + player = (PlayerObject) o.getSlottedObject("ghost"); + + player.setProfessionIcon(packet.getIcon()); + } + + }); + swgOpcodes.put(Opcodes.CmdSceneReady, new INetworkRemoteEvent() { @Override @@ -189,7 +216,6 @@ public class PlayerService implements INetworkDispatch { } });*/ - } @@ -499,7 +525,6 @@ public class PlayerService implements INetworkDispatch { } - @Override public void shutdown() { // TODO Auto-generated method stub