|
1 | 1 | /*********************************************************************************** |
2 | 2 | * Copyright (c) 2024 /// Project SWG /// www.projectswg.com * |
3 | 3 | * * |
4 | | - * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * |
| 4 | + * ProjectSWG is an emulation project for Star Wars Galaxies founded on * |
5 | 5 | * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * |
6 | | - * Our goal is to create an emulator which will provide a server for players to * |
7 | | - * continue playing a game similar to the one they used to play. We are basing * |
8 | | - * it on the final publish of the game prior to end-game events. * |
| 6 | + * Our goal is to create one or more emulators which will provide servers for * |
| 7 | + * players to continue playing a game similar to the one they used to play. * |
9 | 8 | * * |
10 | 9 | * This file is part of Holocore. * |
11 | 10 | * * |
|
30 | 29 | import com.projectswg.common.data.CRC; |
31 | 30 | import com.projectswg.common.data.encodables.tangible.Posture; |
32 | 31 | import com.projectswg.common.data.location.Location; |
| 32 | +import com.projectswg.common.network.NetBuffer; |
33 | 33 | import com.projectswg.common.network.NetworkProtocol; |
34 | 34 | import com.projectswg.common.network.packets.SWGPacket; |
35 | 35 | import com.projectswg.common.network.packets.swg.zone.*; |
@@ -95,7 +95,12 @@ public void sendPacket(SWGPacket packet) { |
95 | 95 | private static void encodeAndDecode(SWGPacket packet) { |
96 | 96 | try { |
97 | 97 | // This doesn't actually test the encoding and decoding of the packet, but it does test that the packet can be encoded and decoded without throwing an exception |
98 | | - NetworkProtocol.decode(NetworkProtocol.encode(packet)); |
| 98 | + NetBuffer data = NetworkProtocol.encode(packet); |
| 99 | + NetworkProtocol.decode(data); |
| 100 | + int remaining = data.remaining(); |
| 101 | + if (remaining > 0) { |
| 102 | + throw new RuntimeException("Encoded packet buffer had more data that wasn't read during decoding. Bytes remaining: " + remaining); |
| 103 | + } |
99 | 104 | } catch (Throwable t) { |
100 | 105 | throw new RuntimeException("Failed to encode and decode packet", t); |
101 | 106 | } |
|
0 commit comments