mirror of
https://github.com/ProjectSWGCore/pswgcommon.git
synced 2026-01-15 23:04:19 -05:00
Fixed a bug with customization string decoding, where empty state was not being handled correctly
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2024 /// Project SWG /// www.projectswg.com *
|
||||
* Copyright (c) 2025 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is an emulation project for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
@@ -92,7 +92,9 @@ class CustomizationString : Encodable, MongoPersistable {
|
||||
}
|
||||
|
||||
override fun decode(data: NetBuffer) {
|
||||
val stream = CustomizationStringInputStream(data.array)
|
||||
val buffer = data.array
|
||||
if (buffer.isEmpty()) return
|
||||
val stream = CustomizationStringInputStream(buffer)
|
||||
stream.read() // version - should be 0x02
|
||||
val variableCount = stream.read()
|
||||
for (i in 0 until variableCount) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2024 /// Project SWG /// www.projectswg.com *
|
||||
* Copyright (c) 2025 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is an emulation project for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
@@ -78,6 +78,16 @@ class TestCustomizationString {
|
||||
assertEquals(-100, decoded.get("/private/index_color_tattoo"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decodeEmptyCustomizationString() {
|
||||
// Customization string with no variables. Can happen when creating a new character of a species that has no hair, for example. In this case, the hair customization string is empty.
|
||||
val string = CustomizationString()
|
||||
val encoded = string.encode()
|
||||
val decoded = CustomizationString()
|
||||
|
||||
assertDoesNotThrow { decoded.decode(NetBuffer.wrap(encoded)) }
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideRealWorldValues")
|
||||
fun testRealWorld(input: ByteArray) {
|
||||
|
||||
Reference in New Issue
Block a user