From 4ccbf897272fc15fe25d8a33479011a49e68249b Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 31 Mar 2014 20:13:37 +0200 Subject: [PATCH] More work on NPC conversation packets --- .../NpcConversationMessage.java | 56 +++++++++++++++- .../NpcConversationOptions.java | 65 ++++++++++++++++++- .../objectControllerObjects/SecureTrade.java | 21 ++++++ .../StartNpcConversation.java | 21 ++++++ .../StopNpcConversation.java | 21 ++++++ src/resources/common/ConversationOption.java | 40 ++++++++++++ src/resources/common/OutOfBand.java | 3 +- 7 files changed, 224 insertions(+), 3 deletions(-) create mode 100644 src/resources/common/ConversationOption.java diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java b/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java index e55e0c98..8c72d535 100644 --- a/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java +++ b/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java @@ -1,5 +1,59 @@ +/******************************************************************************* + * 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; -public class NpcConversationMessage { +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.common.ObjControllerOpcodes; +import resources.common.OutOfBand; + +public class NpcConversationMessage extends ObjControllerObject { + + private long objectId; + private OutOfBand outOfBand; + + public NpcConversationMessage(long objectId, OutOfBand outOfBand) { + this.objectId = objectId; + this.outOfBand = outOfBand; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer outOfBandBuffer = outOfBand.serialize(); + IoBuffer buffer = IoBuffer.allocate(16 + outOfBandBuffer.array().length).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(ObjControllerOpcodes.NPC_CONVERSATION_MESSAGE); + buffer.putLong(objectId); + buffer.putInt(0); + buffer.put(outOfBandBuffer); + + return buffer.flip(); + } } diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java index fec41aa3..3d838c5d 100644 --- a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java +++ b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java @@ -1,5 +1,68 @@ +/******************************************************************************* + * 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; -public class NpcConversationOptions { +import java.nio.ByteOrder; +import java.util.Vector; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.common.ConversationOption; +import resources.common.ObjControllerOpcodes; + +public class NpcConversationOptions extends ObjControllerObject { + + private long npcId; + private long objectId; + private Vector conversationOptions = new Vector(); + + public NpcConversationOptions(long objectId, long npcId) { + this.objectId = objectId; + this.npcId = npcId; + } + + @Override + public void deserialize(IoBuffer data) { + } + + public void addOption(ConversationOption option) { + conversationOptions.add(option); + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(17).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putInt(ObjControllerOpcodes.NPC_CONVERSATION_OPTIONS); + buffer.putLong(objectId); + + buffer.putInt(0); + buffer.put((byte) conversationOptions.size()); + + for(ConversationOption option : conversationOptions) { + buffer.put(option.getOutOfBand().serialize()); + } + + return IoBuffer.allocate(buffer.position()).order(ByteOrder.LITTLE_ENDIAN).put(buffer).flip(); + } } diff --git a/src/protocol/swg/objectControllerObjects/SecureTrade.java b/src/protocol/swg/objectControllerObjects/SecureTrade.java index bd61aad4..3f48253c 100644 --- a/src/protocol/swg/objectControllerObjects/SecureTrade.java +++ b/src/protocol/swg/objectControllerObjects/SecureTrade.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * 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; diff --git a/src/protocol/swg/objectControllerObjects/StartNpcConversation.java b/src/protocol/swg/objectControllerObjects/StartNpcConversation.java index a96adedf..e60d19ae 100644 --- a/src/protocol/swg/objectControllerObjects/StartNpcConversation.java +++ b/src/protocol/swg/objectControllerObjects/StartNpcConversation.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * 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; diff --git a/src/protocol/swg/objectControllerObjects/StopNpcConversation.java b/src/protocol/swg/objectControllerObjects/StopNpcConversation.java index b3bc6947..1ac52dd0 100644 --- a/src/protocol/swg/objectControllerObjects/StopNpcConversation.java +++ b/src/protocol/swg/objectControllerObjects/StopNpcConversation.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * 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; diff --git a/src/resources/common/ConversationOption.java b/src/resources/common/ConversationOption.java new file mode 100644 index 00000000..768301d6 --- /dev/null +++ b/src/resources/common/ConversationOption.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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 resources.common; + +public class ConversationOption { + + private OutOfBand outOfBand; + + public ConversationOption(OutOfBand outOfBand) { + this.setOutOfBand(outOfBand); + } + + public OutOfBand getOutOfBand() { + return outOfBand; + } + + public void setOutOfBand(OutOfBand outOfBand) { + this.outOfBand = outOfBand; + } + +} diff --git a/src/resources/common/OutOfBand.java b/src/resources/common/OutOfBand.java index ace435f6..21a08832 100644 --- a/src/resources/common/OutOfBand.java +++ b/src/resources/common/OutOfBand.java @@ -43,6 +43,7 @@ public class OutOfBand { buffer.putInt(2); buffer.putShort(getCount()); + buffer.putShort((short) 0); // unk for(ProsePackage prosePackage : prosePackages) { @@ -88,7 +89,7 @@ public class OutOfBand { setLength(buffer); - return buffer.flip(); + return IoBuffer.allocate(buffer.position()).order(ByteOrder.LITTLE_ENDIAN).put(buffer).flip(); } public void setLength(IoBuffer buffer) {