-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add proper CRC decoding (excluding beta support for now)
- Loading branch information
Showing
3 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...src/main/kotlin/net/rsprot/protocol/loginprot/incoming/util/CyclicRedundancyCheckBlock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.rsprot.protocol.loginprot.incoming.util | ||
|
||
/** | ||
* CRC blocks are helper structures used for the server to verify that the CRC is up-to-date. | ||
* As the client transmits less CRCs than there are cache indices, we provide validation methods | ||
* through this abstract class at the respective revision's decoder level, so we can perform checks | ||
* that correspond to the information received from the client, and not what the server fully knows of. | ||
* @property clientCrc the int array of client CRCs, indexed by the cache archives. | ||
*/ | ||
public abstract class CyclicRedundancyCheckBlock( | ||
protected val clientCrc: IntArray, | ||
) { | ||
public abstract fun validate(serverCrc: IntArray): Boolean | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (other !is CyclicRedundancyCheckBlock) return false | ||
|
||
if (!clientCrc.contentEquals(other.clientCrc)) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return clientCrc.contentHashCode() | ||
} | ||
|
||
override fun toString(): String { | ||
return "CyclicRedundancyCheckBlock(clientCrc=${clientCrc.contentToString()})" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters