You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 15:36:18 +00:00
Fix PetBreedingMessageParser bytesAvailable check
bytesAvailable is a boolean (IMessageDataWrapper.bytesAvailable: boolean, returns 'there is at least one byte left'); the parser was doing 'wrapper.bytesAvailable < 12' as if it were a count, which both mis-compares boolean to number and short-circuits incorrectly when exactly 11 bytes remain. Align with every other parser in the codebase: 'if(!wrapper || !wrapper.bytesAvailable) return false;'. The downstream readInt calls already throw on truncated packets so the explicit length check was load-bearing only against malformed inputs that wouldn't parse anyway.
This commit is contained in:
+3
-4
@@ -19,10 +19,9 @@ export class PetBreedingMessageParser implements IMessageParser
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean {
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
if (!wrapper || wrapper.bytesAvailable < 12) {
|
{
|
||||||
return false;
|
if(!wrapper || !wrapper.bytesAvailable) return false;
|
||||||
}
|
|
||||||
|
|
||||||
this._state = wrapper.readInt();
|
this._state = wrapper.readInt();
|
||||||
this._ownPetId = wrapper.readInt();
|
this._ownPetId = wrapper.readInt();
|
||||||
|
|||||||
Reference in New Issue
Block a user