From 4e025ac287e9356bad8b684fb2190ae796edbb48 Mon Sep 17 00:00:00 2001 From: Obique PSWG Date: Sun, 24 Jul 2022 13:36:19 -0500 Subject: [PATCH] Added CharacterSheetResponseMessage and fixed decode CRC in EnterStructurePlacementModeMessage --- .../common/network/packets/PacketType.java | 3 + .../swg/zone/CharacterSheetResponseMessage.kt | 100 ++++++++++++++++++ .../EnterStructurePlacementModeMessage.kt | 3 +- 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/projectswg/common/network/packets/swg/zone/CharacterSheetResponseMessage.kt diff --git a/src/main/java/com/projectswg/common/network/packets/PacketType.java b/src/main/java/com/projectswg/common/network/packets/PacketType.java index 3c4beda..b829960 100644 --- a/src/main/java/com/projectswg/common/network/packets/PacketType.java +++ b/src/main/java/com/projectswg/common/network/packets/PacketType.java @@ -30,6 +30,7 @@ import com.projectswg.common.data.EnumLookup; import com.projectswg.common.network.packets.swg.holo.login.HoloLoginRequestPacket; import com.projectswg.common.network.packets.swg.holo.login.HoloLoginResponsePacket; import com.projectswg.common.network.packets.swg.zone.*; +import com.projectswg.common.network.packets.swg.zone.structures.EnterStructurePlacementModeMessage; import me.joshlarson.jlcommon.log.Log; import com.projectswg.common.network.packets.swg.ErrorMessage; import com.projectswg.common.network.packets.swg.ServerUnixEpochTime; @@ -234,6 +235,7 @@ public enum PacketType { GALAXY_LOOP_TIMES_RESPONSE (GalaxyLoopTimesResponse.CRC, GalaxyLoopTimesResponse.class), PARAMETERS_MESSAGE (ParametersMessage.CRC, ParametersMessage.class), DELTA (DeltasMessage.CRC, DeltasMessage.class), + CHARACTER_SHEET_RESPONSE_MESSAGE (CharacterSheetResponseMessage.Companion.getCRC(), CharacterSheetResponseMessage.class), SERVER_TIME_MESSAGE (ServerTimeMessage.CRC, ServerTimeMessage.class), SET_WAYPOINT_COLOR (SetWaypointColor.CRC, SetWaypointColor.class), SERVER_WEATHER_MESSAGE (ServerWeatherMessage.CRC, ServerWeatherMessage.class), @@ -296,6 +298,7 @@ public enum PacketType { UPDATE_CELL_PERMISSIONS_MESSAGE (UpdateCellPermissionMessage.CRC, UpdateCellPermissionMessage.class), GET_MAP_LOCATIONS_MESSAGE (GetMapLocationsMessage.CRC, GetMapLocationsMessage.class), GET_MAP_LOCATIONS_RESPONSE_MESSAGE (GetMapLocationsResponseMessage.CRC, GetMapLocationsResponseMessage.class), + ENTER_STRUCTURE_PLACEMENT_MODE_MESSAGE (EnterStructurePlacementModeMessage.Companion.getCRC(), EnterStructurePlacementModeMessage.class), // Spatial UPDATE_POSTURE_MESSAGE (UpdatePostureMessage.CRC, UpdatePostureMessage.class), diff --git a/src/main/java/com/projectswg/common/network/packets/swg/zone/CharacterSheetResponseMessage.kt b/src/main/java/com/projectswg/common/network/packets/swg/zone/CharacterSheetResponseMessage.kt new file mode 100644 index 0000000..5b2c508 --- /dev/null +++ b/src/main/java/com/projectswg/common/network/packets/swg/zone/CharacterSheetResponseMessage.kt @@ -0,0 +1,100 @@ +/*********************************************************************************** + * Copyright (c) 2022 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore 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 Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ + +package com.projectswg.common.network.packets.swg.zone + +import com.projectswg.common.data.location.Point3D +import com.projectswg.common.network.NetBuffer +import com.projectswg.common.network.packets.SWGPacket + +data class CharacterSheetResponseMessage( + var bornDate: Int = 0, + var played: Int = 0, + var bindLocation: Point3D = Point3D(), + var bindPlanet: String = "", + var bankLocation: Point3D = Point3D(), + var bankPlanet: String = "", + var residenceLocation: Point3D = Point3D(), + var residencePlanet: String = "", + var spouseName: String = "", + var lotsUsed: Int = 0, + var factionCrc: Int = 0, + var factionStatus: Int = 0 +) : SWGPacket() { + + override fun decode(data: NetBuffer) { + if (!super.checkDecode(data, CRC)) + return + bornDate = data.int + played = data.int + bindLocation.decode(data) + bindPlanet = data.ascii + bankLocation.decode(data) + bankPlanet = data.ascii + residenceLocation.decode(data) + residencePlanet = data.ascii + spouseName = data.unicode + lotsUsed = data.int + factionCrc = data.int + factionStatus = data.int + } + + override fun encode(): NetBuffer { + val data = NetBuffer.allocate(72 + + bindPlanet.length + bankPlanet.length + + residencePlanet.length + spouseName.length * 2) + + data.addShort(13) + data.addInt(CRC) + data.addInt(bornDate) + data.addInt(played) + data.addFloat(bindLocation.x.toFloat()) + data.addFloat(bindLocation.y.toFloat()) + data.addFloat(bindLocation.z.toFloat()) + data.addAscii(bindPlanet) + data.addFloat(bankLocation.x.toFloat()) + data.addFloat(bankLocation.y.toFloat()) + data.addFloat(bankLocation.z.toFloat()) + data.addAscii(bankPlanet) + data.addFloat(residenceLocation.x.toFloat()) + data.addFloat(residenceLocation.y.toFloat()) + data.addFloat(residenceLocation.z.toFloat()) + data.addAscii(residencePlanet) + data.addUnicode(spouseName) + data.addInt(lotsUsed) + data.addInt(factionCrc) + data.addInt(factionStatus) + return data + } + + companion object { + + val CRC = getCrc("CharacterSheetResponseMessage") + + } + +} \ No newline at end of file diff --git a/src/main/java/com/projectswg/common/network/packets/swg/zone/structures/EnterStructurePlacementModeMessage.kt b/src/main/java/com/projectswg/common/network/packets/swg/zone/structures/EnterStructurePlacementModeMessage.kt index c177884..1e219af 100644 --- a/src/main/java/com/projectswg/common/network/packets/swg/zone/structures/EnterStructurePlacementModeMessage.kt +++ b/src/main/java/com/projectswg/common/network/packets/swg/zone/structures/EnterStructurePlacementModeMessage.kt @@ -29,7 +29,6 @@ package com.projectswg.common.network.packets.swg.zone.structures import com.projectswg.common.network.NetBuffer import com.projectswg.common.network.packets.SWGPacket -import com.projectswg.common.network.packets.swg.zone.CmdSceneReady data class EnterStructurePlacementModeMessage( var deedId: Long = 0, @@ -37,7 +36,7 @@ data class EnterStructurePlacementModeMessage( ) : SWGPacket() { override fun decode(data: NetBuffer) { - if (!super.checkDecode(data, CmdSceneReady.CRC)) + if (!super.checkDecode(data, CRC)) return deedId = data.long template = data.ascii