mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
Fix LoginMessage and ConnectToWorldReqMsg token
The decoding was wrong. ASCII was the wrong choice. We needed a cstring and to add padding instead of assuming a fixed size. Fixes and closes #2
This commit is contained in:
parent
f1fae83548
commit
5ed40e73b3
|
|
@ -8,6 +8,7 @@ import scodec.codecs._
|
|||
// NOTE: this packet has a ton of bytes left over at the end and is usually all zeros
|
||||
// except for the server name and a 0x80 near the end
|
||||
final case class ConnectToWorldRequestMessage(server : String,
|
||||
token : String,
|
||||
majorVersion : Long,
|
||||
minorVersion : Long,
|
||||
revision : Long,
|
||||
|
|
@ -21,7 +22,7 @@ final case class ConnectToWorldRequestMessage(server : String,
|
|||
object ConnectToWorldRequestMessage extends Marshallable[ConnectToWorldRequestMessage] {
|
||||
implicit val codec : Codec[ConnectToWorldRequestMessage] = (
|
||||
("server_name" | PacketHelpers.encodedString) ::
|
||||
("unknown" | ignore(32*8)) ::
|
||||
("token" | paddedFixedSizeBytes(32, cstring, ignore(8))) :: // must be an ignore 8 as the memory might not be 0x00
|
||||
("major_version" | uint32L) ::
|
||||
("minor_version" | uint32L) ::
|
||||
("revision" | uint32L) ::
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ final case class LoginMessage(majorVersion : Long,
|
|||
object LoginMessage extends Marshallable[LoginMessage] {
|
||||
private def username = PacketHelpers.encodedStringAligned(7)
|
||||
private def password = PacketHelpers.encodedString
|
||||
private def tokenPath = fixedSizeBytes(32, ascii) :: username
|
||||
private def tokenPath = paddedFixedSizeBytes(32, cstring, ignore(8)) :: username
|
||||
private def passwordPath = username :: password
|
||||
|
||||
type Struct = String :: Option[String] :: Option[String] :: HNil
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ class GamePacketTest extends Specification {
|
|||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case ConnectToWorldRequestMessage(serverName, majorVersion, minorVersion, revision, buildDate, unk) =>
|
||||
case ConnectToWorldRequestMessage(serverName, token, majorVersion, minorVersion, revision, buildDate, unk) =>
|
||||
serverName mustEqual "gemini"
|
||||
token mustEqual ""
|
||||
majorVersion mustEqual 0
|
||||
minorVersion mustEqual 0
|
||||
revision mustEqual 0
|
||||
|
|
@ -28,7 +29,7 @@ class GamePacketTest extends Specification {
|
|||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = ConnectToWorldRequestMessage("gemini", 0, 0, 0, "", 0)
|
||||
val msg = ConnectToWorldRequestMessage("gemini", "", 0, 0, 0, "", 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
|
|
|
|||
Loading…
Reference in a new issue