diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 050e213b..7676a83a 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -43,7 +43,7 @@ import org.apache.mina.core.session.IoSession; import com.sleepycat.je.Transaction; import com.sleepycat.persist.EntityCursor; -import protocol.swg.ChatSystemMessage; +import protocol.swg.chat.ChatSystemMessage; import net.engio.mbassy.bus.config.BusConfiguration; import resources.common.RadialOptions; import resources.common.ThreadMonitor; diff --git a/src/protocol/swg/SWGMessageFactory.java b/src/protocol/swg/SWGMessageFactory.java index fc5bd8c3..640b019e 100644 --- a/src/protocol/swg/SWGMessageFactory.java +++ b/src/protocol/swg/SWGMessageFactory.java @@ -24,6 +24,7 @@ package protocol.swg; import java.nio.ByteBuffer; import protocol.Message; +import protocol.swg.chat.ChatInstantMessageToCharacter; public class SWGMessageFactory { diff --git a/src/protocol/swg/ChatCreateRoom.java b/src/protocol/swg/chat/ChatCreateRoom.java similarity index 97% rename from src/protocol/swg/ChatCreateRoom.java rename to src/protocol/swg/chat/ChatCreateRoom.java index 640cba0e..841c1614 100644 --- a/src/protocol/swg/ChatCreateRoom.java +++ b/src/protocol/swg/chat/ChatCreateRoom.java @@ -19,10 +19,12 @@ * 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; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatCreateRoom extends SWGMessage { diff --git a/src/protocol/swg/ChatDeletePersistentMessage.java b/src/protocol/swg/chat/ChatDeletePersistentMessage.java similarity index 96% rename from src/protocol/swg/ChatDeletePersistentMessage.java rename to src/protocol/swg/chat/ChatDeletePersistentMessage.java index 1e812255..3f0d1b70 100644 --- a/src/protocol/swg/ChatDeletePersistentMessage.java +++ b/src/protocol/swg/chat/ChatDeletePersistentMessage.java @@ -19,10 +19,12 @@ * 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; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatDeletePersistentMessage extends SWGMessage { diff --git a/src/protocol/swg/ChatEnterRoomById.java b/src/protocol/swg/chat/ChatEnterRoomById.java similarity index 96% rename from src/protocol/swg/ChatEnterRoomById.java rename to src/protocol/swg/chat/ChatEnterRoomById.java index a5b2d4c3..15e9bb0c 100644 --- a/src/protocol/swg/ChatEnterRoomById.java +++ b/src/protocol/swg/chat/ChatEnterRoomById.java @@ -19,10 +19,11 @@ * 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; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import resources.common.StringUtilities; public class ChatEnterRoomById extends SWGMessage { @@ -34,7 +35,6 @@ public class ChatEnterRoomById extends SWGMessage { @Override public void deserialize(IoBuffer data) { - StringUtilities.printBytes(data.array()); data.getShort(); data.getInt(); diff --git a/src/protocol/swg/ChatFriendsListUpdate.java b/src/protocol/swg/chat/ChatFriendsListUpdate.java similarity index 94% rename from src/protocol/swg/ChatFriendsListUpdate.java rename to src/protocol/swg/chat/ChatFriendsListUpdate.java index 962b2ad2..f3a17a34 100644 --- a/src/protocol/swg/ChatFriendsListUpdate.java +++ b/src/protocol/swg/chat/ChatFriendsListUpdate.java @@ -1,4 +1,4 @@ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -6,6 +6,8 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatFriendsListUpdate extends SWGMessage { private String friendName; diff --git a/src/protocol/swg/ChatInstantMessageToCharacter.java b/src/protocol/swg/chat/ChatInstantMessageToCharacter.java similarity index 98% rename from src/protocol/swg/ChatInstantMessageToCharacter.java rename to src/protocol/swg/chat/ChatInstantMessageToCharacter.java index 1d0efccd..8a1414f9 100644 --- a/src/protocol/swg/ChatInstantMessageToCharacter.java +++ b/src/protocol/swg/chat/ChatInstantMessageToCharacter.java @@ -19,13 +19,15 @@ * 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; +package protocol.swg.chat; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + @SuppressWarnings("unused") public class ChatInstantMessageToCharacter extends SWGMessage { diff --git a/src/protocol/swg/ChatInstantMessagetoClient.java b/src/protocol/swg/chat/ChatInstantMessagetoClient.java similarity index 97% rename from src/protocol/swg/ChatInstantMessagetoClient.java rename to src/protocol/swg/chat/ChatInstantMessagetoClient.java index f87c0da8..f11903fc 100644 --- a/src/protocol/swg/ChatInstantMessagetoClient.java +++ b/src/protocol/swg/chat/ChatInstantMessagetoClient.java @@ -19,12 +19,14 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatInstantMessagetoClient extends SWGMessage{ diff --git a/src/protocol/swg/ChatOnAddFriend.java b/src/protocol/swg/chat/ChatOnAddFriend.java similarity index 96% rename from src/protocol/swg/ChatOnAddFriend.java rename to src/protocol/swg/chat/ChatOnAddFriend.java index 0b84e6ff..44b0b8ac 100644 --- a/src/protocol/swg/ChatOnAddFriend.java +++ b/src/protocol/swg/chat/ChatOnAddFriend.java @@ -19,12 +19,14 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnAddFriend extends SWGMessage { @Override diff --git a/src/protocol/swg/ChatOnChangeFriendStatus.java b/src/protocol/swg/chat/ChatOnChangeFriendStatus.java similarity index 97% rename from src/protocol/swg/ChatOnChangeFriendStatus.java rename to src/protocol/swg/chat/ChatOnChangeFriendStatus.java index a11c85bb..1c770233 100644 --- a/src/protocol/swg/ChatOnChangeFriendStatus.java +++ b/src/protocol/swg/chat/ChatOnChangeFriendStatus.java @@ -19,7 +19,7 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import engine.resources.config.Config; public class ChatOnChangeFriendStatus extends SWGMessage { diff --git a/src/protocol/swg/chat/ChatOnConnectAvatar.java b/src/protocol/swg/chat/ChatOnConnectAvatar.java new file mode 100644 index 00000000..faebcf9d --- /dev/null +++ b/src/protocol/swg/chat/ChatOnConnectAvatar.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.chat; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class ChatOnConnectAvatar extends SWGMessage { + + public ChatOnConnectAvatar() { } + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(6).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 1); + buffer.putInt(0xD72FE9BE); + + return buffer.flip(); + } + +} diff --git a/src/protocol/swg/ChatOnCreateRoom.java b/src/protocol/swg/chat/ChatOnCreateRoom.java similarity index 97% rename from src/protocol/swg/ChatOnCreateRoom.java rename to src/protocol/swg/chat/ChatOnCreateRoom.java index 0492800c..fc690fae 100644 --- a/src/protocol/swg/ChatOnCreateRoom.java +++ b/src/protocol/swg/chat/ChatOnCreateRoom.java @@ -19,7 +19,7 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import services.chat.ChatRoom; public class ChatOnCreateRoom extends SWGMessage { diff --git a/src/protocol/swg/ChatOnEnteredRoom.java b/src/protocol/swg/chat/ChatOnEnteredRoom.java similarity index 97% rename from src/protocol/swg/ChatOnEnteredRoom.java rename to src/protocol/swg/chat/ChatOnEnteredRoom.java index 179f981a..786f16a6 100644 --- a/src/protocol/swg/ChatOnEnteredRoom.java +++ b/src/protocol/swg/chat/ChatOnEnteredRoom.java @@ -19,7 +19,7 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import engine.resources.common.CRC; import resources.common.Opcodes; diff --git a/src/protocol/swg/ChatOnGetFriendsList.java b/src/protocol/swg/chat/ChatOnGetFriendsList.java similarity index 95% rename from src/protocol/swg/ChatOnGetFriendsList.java rename to src/protocol/swg/chat/ChatOnGetFriendsList.java index 3e497bf1..14d5ac8f 100644 --- a/src/protocol/swg/ChatOnGetFriendsList.java +++ b/src/protocol/swg/chat/ChatOnGetFriendsList.java @@ -1,4 +1,4 @@ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import java.util.List; @@ -7,6 +7,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import resources.objects.player.PlayerObject; // This is possibly unused diff --git a/src/protocol/swg/ChatOnSendInstantMessage.java b/src/protocol/swg/chat/ChatOnSendInstantMessage.java similarity index 96% rename from src/protocol/swg/ChatOnSendInstantMessage.java rename to src/protocol/swg/chat/ChatOnSendInstantMessage.java index 9bcb41da..f1be9e0a 100644 --- a/src/protocol/swg/ChatOnSendInstantMessage.java +++ b/src/protocol/swg/chat/ChatOnSendInstantMessage.java @@ -19,12 +19,14 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnSendInstantMessage extends SWGMessage { private int errorType; diff --git a/src/protocol/swg/ChatOnSendPersistentMessage.java b/src/protocol/swg/chat/ChatOnSendPersistentMessage.java similarity index 96% rename from src/protocol/swg/ChatOnSendPersistentMessage.java rename to src/protocol/swg/chat/ChatOnSendPersistentMessage.java index 3d8a3a48..9dc28eff 100644 --- a/src/protocol/swg/ChatOnSendPersistentMessage.java +++ b/src/protocol/swg/chat/ChatOnSendPersistentMessage.java @@ -19,12 +19,14 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnSendPersistentMessage extends SWGMessage { diff --git a/src/protocol/swg/ChatOnSendRoomMessage.java b/src/protocol/swg/chat/ChatOnSendRoomMessage.java similarity index 96% rename from src/protocol/swg/ChatOnSendRoomMessage.java rename to src/protocol/swg/chat/ChatOnSendRoomMessage.java index 0d7729e5..21d03390 100644 --- a/src/protocol/swg/ChatOnSendRoomMessage.java +++ b/src/protocol/swg/chat/ChatOnSendRoomMessage.java @@ -19,12 +19,14 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnSendRoomMessage extends SWGMessage { private int errorCode; diff --git a/src/protocol/swg/ChatPersistentMessageToClient.java b/src/protocol/swg/chat/ChatPersistentMessageToClient.java similarity index 98% rename from src/protocol/swg/ChatPersistentMessageToClient.java rename to src/protocol/swg/chat/ChatPersistentMessageToClient.java index 3db681b6..a5013ab8 100644 --- a/src/protocol/swg/ChatPersistentMessageToClient.java +++ b/src/protocol/swg/chat/ChatPersistentMessageToClient.java @@ -19,11 +19,14 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import java.util.List; + import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; import services.chat.WaypointAttachment; diff --git a/src/protocol/swg/ChatPersistentMessageToServer.java b/src/protocol/swg/chat/ChatPersistentMessageToServer.java similarity index 98% rename from src/protocol/swg/ChatPersistentMessageToServer.java rename to src/protocol/swg/chat/ChatPersistentMessageToServer.java index a8602f83..84fa1e52 100644 --- a/src/protocol/swg/ChatPersistentMessageToServer.java +++ b/src/protocol/swg/chat/ChatPersistentMessageToServer.java @@ -19,13 +19,16 @@ * 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; +package protocol.swg.chat; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; + import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; import services.chat.WaypointAttachment; diff --git a/src/protocol/swg/chat/ChatQueryRoomResults.java b/src/protocol/swg/chat/ChatQueryRoomResults.java new file mode 100644 index 00000000..da760c20 --- /dev/null +++ b/src/protocol/swg/chat/ChatQueryRoomResults.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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.chat; + +import java.nio.ByteOrder; +import java.util.Vector; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; +import resources.objects.creature.CreatureObject; +import services.chat.ChatRoom; + +public class ChatQueryRoomResults extends SWGMessage { + + private ChatRoom room; + private int requestId; + + public ChatQueryRoomResults(ChatRoom room, int requestId) { + this.room = room; + this.requestId = requestId; + } + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + String server = NGECore.getInstance().getGalaxyName(); + IoBuffer buffer = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 7); + buffer.putInt(0xC4DE864E); + + Vector users = room.getUserList(); + + buffer.putInt(users.size()); + if (users.size() > 0) { + for (CreatureObject creo : users) { + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(creo.getCustomName())); + } + } + + buffer.putInt(0); // TODO: Invited list for chat rooms + + Vector moderators = room.getModeratorList(); + + buffer.putInt(moderators.size()); + if (moderators.size() > 0) { + for (CreatureObject creo : users) { + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(creo.getCustomName())); + } + } + + Vector banned = room.getBanList(); + buffer.putInt(banned.size()); + if (banned.size() > 0) { + for (CreatureObject creo : users) { + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(creo.getCustomName())); + } + } + + buffer.putInt(requestId); + buffer.putInt(room.getRoomId()); + buffer.putInt(room.isPrivateRoom() ? 0 : 1); + buffer.put((byte) (room.isModeratorsOnly() ? 1 : 0)); + + buffer.put(getAsciiString(room.getRoomAddress())); + + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getOwner())); + + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getCreator())); + + buffer.put(getUnicodeString(room.getDescription())); + + buffer.putInt(0); // moderator list + buffer.putInt(0); // user list + return buffer.flip(); + } + +} diff --git a/src/protocol/swg/ChatRequestPersistentMessage.java b/src/protocol/swg/chat/ChatRequestPersistentMessage.java similarity index 96% rename from src/protocol/swg/ChatRequestPersistentMessage.java rename to src/protocol/swg/chat/ChatRequestPersistentMessage.java index d52b4afd..dd9ec88f 100644 --- a/src/protocol/swg/ChatRequestPersistentMessage.java +++ b/src/protocol/swg/chat/ChatRequestPersistentMessage.java @@ -19,10 +19,12 @@ * 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; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatRequestPersistentMessage extends SWGMessage { diff --git a/src/protocol/swg/ChatRoomList.java b/src/protocol/swg/chat/ChatRoomList.java similarity index 90% rename from src/protocol/swg/ChatRoomList.java rename to src/protocol/swg/chat/ChatRoomList.java index e2bff284..042d930a 100644 --- a/src/protocol/swg/ChatRoomList.java +++ b/src/protocol/swg/chat/ChatRoomList.java @@ -19,7 +19,7 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import java.util.concurrent.ConcurrentHashMap; @@ -28,6 +28,8 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; +import resources.common.StringUtilities; import services.chat.ChatRoom; public class ChatRoomList extends SWGMessage { @@ -46,7 +48,7 @@ public class ChatRoomList extends SWGMessage { @Override public IoBuffer serialize() { String server = NGECore.getInstance().getGalaxyName(); - IoBuffer buffer = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(53).order(ByteOrder.LITTLE_ENDIAN); buffer.setAutoExpand(true); buffer.putShort((short) 2); @@ -70,7 +72,9 @@ public class ChatRoomList extends SWGMessage { buffer.putInt(0); // user list (not used by client) } }); - return buffer.flip(); + buffer.flip(); + //StringUtilities.printBytes(buffer.array()); + return buffer; } } diff --git a/src/protocol/swg/ChatRoomMessage.java b/src/protocol/swg/chat/ChatRoomMessage.java similarity index 97% rename from src/protocol/swg/ChatRoomMessage.java rename to src/protocol/swg/chat/ChatRoomMessage.java index 209db832..616d019d 100644 --- a/src/protocol/swg/ChatRoomMessage.java +++ b/src/protocol/swg/chat/ChatRoomMessage.java @@ -19,7 +19,7 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,8 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatRoomMessage extends SWGMessage { private String character; diff --git a/src/protocol/swg/ChatSendToRoom.java b/src/protocol/swg/chat/ChatSendToRoom.java similarity index 96% rename from src/protocol/swg/ChatSendToRoom.java rename to src/protocol/swg/chat/ChatSendToRoom.java index c3a07dac..0a751ac0 100644 --- a/src/protocol/swg/ChatSendToRoom.java +++ b/src/protocol/swg/chat/ChatSendToRoom.java @@ -19,10 +19,12 @@ * 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; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatSendToRoom extends SWGMessage { private String message; diff --git a/src/protocol/swg/chat/ChatServerStatus.java b/src/protocol/swg/chat/ChatServerStatus.java new file mode 100644 index 00000000..a867a244 --- /dev/null +++ b/src/protocol/swg/chat/ChatServerStatus.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.chat; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class ChatServerStatus extends SWGMessage { + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(7).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 2); + buffer.putInt(0x7102B15F); + buffer.put((byte) 1); + return buffer.flip(); + } +} diff --git a/src/protocol/swg/ChatSystemMessage.java b/src/protocol/swg/chat/ChatSystemMessage.java similarity index 98% rename from src/protocol/swg/ChatSystemMessage.java rename to src/protocol/swg/chat/ChatSystemMessage.java index e12aa1f4..af1b516d 100644 --- a/src/protocol/swg/ChatSystemMessage.java +++ b/src/protocol/swg/chat/ChatSystemMessage.java @@ -19,12 +19,13 @@ * 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; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import resources.common.Opcodes; public class ChatSystemMessage extends SWGMessage{ diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index da90caec..8391ac82 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -34,12 +34,12 @@ import java.util.concurrent.TimeUnit; import org.apache.mina.core.buffer.IoBuffer; -import protocol.swg.ChatSystemMessage; import protocol.swg.ObjControllerMessage; import protocol.swg.PlayClientEffectObjectMessage; import protocol.swg.PlayMusicMessage; import protocol.swg.UpdatePostureMessage; import protocol.swg.UpdatePVPStatusMessage; +import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.Animation; import protocol.swg.objectControllerObjects.Posture; diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 71b86388..22b30882 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -60,15 +60,15 @@ import engine.resources.scene.Quaternion; import engine.resources.scene.quadtree.QuadTree; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; -import protocol.swg.ChatFriendsListUpdate; -import protocol.swg.ChatOnChangeFriendStatus; -import protocol.swg.ChatOnGetFriendsList; import protocol.swg.CmdStartScene; import protocol.swg.HeartBeatMessage; import protocol.swg.ObjControllerMessage; import protocol.swg.OpenedContainerMessage; import protocol.swg.UpdateTransformMessage; import protocol.swg.UpdateTransformWithParentMessage; +import protocol.swg.chat.ChatFriendsListUpdate; +import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnGetFriendsList; import protocol.swg.objectControllerObjects.DataTransform; import protocol.swg.objectControllerObjects.DataTransformWithParent; import protocol.swg.objectControllerObjects.TargetUpdate; diff --git a/src/services/chat/ChatRoom.java b/src/services/chat/ChatRoom.java index 41ee1565..a2428907 100644 --- a/src/services/chat/ChatRoom.java +++ b/src/services/chat/ChatRoom.java @@ -21,7 +21,6 @@ ******************************************************************************/ package services.chat; -import java.util.List; import java.util.Vector; import resources.objects.creature.CreatureObject; @@ -29,8 +28,6 @@ import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.PrimaryKey; -import com.sleepycat.persist.model.Relationship; -import com.sleepycat.persist.model.SecondaryKey; @Entity public class ChatRoom { @@ -45,8 +42,6 @@ public class ChatRoom { @NotPersistent private Vector userList = new Vector(); // current users - @NotPersistent - private int requestId; // not-persistent private boolean moderatorsOnly; private boolean privateRoom; private boolean visible; @@ -92,14 +87,6 @@ public class ChatRoom { this.userList = userList; } - public int getRequestId() { - return requestId; - } - - public void setRequestId(int requestId) { - this.requestId = requestId; - } - public boolean isModeratorsOnly() { return moderatorsOnly; } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 8d4a159f..274fcd4e 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -49,27 +49,28 @@ import resources.common.*; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; -import protocol.swg.ChatCreateRoom; -import protocol.swg.ChatEnterRoomById; -import protocol.swg.ChatOnChangeFriendStatus; -import protocol.swg.ChatDeletePersistentMessage; -import protocol.swg.ChatFriendsListUpdate; -import protocol.swg.ChatInstantMessageToCharacter; -import protocol.swg.ChatInstantMessagetoClient; -import protocol.swg.ChatOnAddFriend; -import protocol.swg.ChatOnCreateRoom; -import protocol.swg.ChatOnEnteredRoom; -import protocol.swg.ChatOnSendInstantMessage; -import protocol.swg.ChatOnSendPersistentMessage; -import protocol.swg.ChatOnSendRoomMessage; -import protocol.swg.ChatPersistentMessageToClient; -import protocol.swg.ChatPersistentMessageToServer; -import protocol.swg.ChatRequestPersistentMessage; -import protocol.swg.ChatRoomList; -import protocol.swg.ChatRoomMessage; -import protocol.swg.ChatSendToRoom; -import protocol.swg.ChatSystemMessage; import protocol.swg.ObjControllerMessage; +import protocol.swg.chat.ChatCreateRoom; +import protocol.swg.chat.ChatDeletePersistentMessage; +import protocol.swg.chat.ChatEnterRoomById; +import protocol.swg.chat.ChatFriendsListUpdate; +import protocol.swg.chat.ChatInstantMessageToCharacter; +import protocol.swg.chat.ChatInstantMessagetoClient; +import protocol.swg.chat.ChatOnAddFriend; +import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnCreateRoom; +import protocol.swg.chat.ChatOnEnteredRoom; +import protocol.swg.chat.ChatOnSendInstantMessage; +import protocol.swg.chat.ChatOnSendPersistentMessage; +import protocol.swg.chat.ChatOnSendRoomMessage; +import protocol.swg.chat.ChatPersistentMessageToClient; +import protocol.swg.chat.ChatPersistentMessageToServer; +import protocol.swg.chat.ChatRequestPersistentMessage; +import protocol.swg.chat.ChatRoomList; +import protocol.swg.chat.ChatRoomMessage; +import protocol.swg.chat.ChatSendToRoom; +import protocol.swg.chat.ChatServerStatus; +import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.PlayerEmote; import protocol.swg.objectControllerObjects.SpatialChat; import main.NGECore; @@ -363,15 +364,17 @@ public class ChatService implements INetworkDispatch { if (obj == null) return; - ChatRoomList listMessage = new ChatRoomList(chatRooms); + //ChatServerStatus chatServerStatus = new ChatServerStatus(); + //client.getSession().write(chatServerStatus.serialize()); + ChatRoomList listMessage = new ChatRoomList(chatRooms); client.getSession().write(listMessage.serialize()); } }); swgOpcodes.put(Opcodes.ChatCreateRoom, (session, data) -> { - data.order(ByteOrder.LITTLE_ENDIAN); + /*data.order(ByteOrder.LITTLE_ENDIAN); Client client = core.getClient(session); @@ -389,19 +392,33 @@ public class ChatService implements INetworkDispatch { sentPacket.deserialize(data); ChatRoom room = createChatRoom(sentPacket.getTitle(), sentPacket.getAddress(), creo.getCustomName().toLowerCase(), true, false); - room.setPrivateRoom(sentPacket.isPrivacy()); - room.setModeratorsOnly(sentPacket.isModeratorOnly()); if (room != null) { + room.setPrivateRoom(sentPacket.isPrivacy()); + room.setModeratorsOnly(sentPacket.isModeratorOnly()); room.getUserList().add(creo); room.getModeratorList().add(creo); ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest()); session.write(response.serialize()); - } + }*/ }); swgOpcodes.put(Opcodes.ChatQueryRoom, (session, data) -> { + data.order(ByteOrder.LITTLE_ENDIAN); + //StringUtilities.printBytes(data.array()); + Client client = core.getClient(session); + + if(client == null) + return; + + SWGObject obj = client.getParent(); + + if (obj == null) + return; + + + }); swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> { @@ -441,7 +458,7 @@ public class ChatService implements INetworkDispatch { joinChatRoom((CreatureObject) obj, sentPacket.getRoomId()); - System.out.println("Entering room... " + sentPacket.getRoomId()); + //System.out.println("Entering room... " + sentPacket.getRoomId()); }); } @@ -728,15 +745,15 @@ public class ChatService implements INetworkDispatch { if (creator.contains(" ")) creator = creator.split(" ")[0]; - + ChatRoom room = new ChatRoom(); room.setDescription(roomName); if (!address.startsWith("SWG.")) room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); else room.setRoomAddress(address); - room.setCreator(creator); - room.setOwner(creator); + room.setCreator(creator.toLowerCase()); + room.setOwner(creator.toLowerCase()); room.setVisible(showInList); room.setRoomId(generateChatRoomId()); diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 6c5a44a4..816d910b 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -58,10 +58,6 @@ import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.PrimaryKey; -import protocol.swg.ChatFriendsListUpdate; -import protocol.swg.ChatOnChangeFriendStatus; -import protocol.swg.ChatOnGetFriendsList; -import protocol.swg.ChatRoomList; import protocol.swg.CmdSceneReady; import protocol.swg.CmdStartScene; import protocol.swg.HeartBeatMessage; @@ -70,6 +66,12 @@ import protocol.swg.ParametersMessage; import protocol.swg.SelectCharacter; import protocol.swg.ServerTimeMessage; import protocol.swg.UnkByteFlag; +import protocol.swg.chat.ChatFriendsListUpdate; +import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnConnectAvatar; +import protocol.swg.chat.ChatOnGetFriendsList; +import protocol.swg.chat.ChatRoomList; +import protocol.swg.chat.ChatServerStatus; import protocol.swg.objectControllerObjects.UiPlayEffect; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.CrcStringTableVisitor; @@ -783,10 +785,18 @@ public class ObjectService implements INetworkDispatch { core.chatService.loadMailHeaders(client); core.simulationService.handleZoneIn(client); + creature.makeAware(creature); + ChatServerStatus chatStatus = new ChatServerStatus(); + creature.getClient().getSession().write(chatStatus.serialize()); + + ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar(); + creature.getClient().getSession().write(chatConnect.serialize()); + ChatRoomList chatRooms = new ChatRoomList(core.chatService.getChatRooms()); creature.getClient().getSession().write(chatRooms.serialize()); + //ChatOnGetFriendsList friendsListMessage = new ChatOnGetFriendsList(ghost); //client.getSession().write(friendsListMessage.serialize());