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:
simoleo89
2026-05-11 21:09:41 +02:00
parent 0fc38a1c71
commit 999b8187d6
@@ -19,10 +19,9 @@ export class PetBreedingMessageParser implements IMessageParser
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean {
if (!wrapper || wrapper.bytesAvailable < 12) {
return false;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper || !wrapper.bytesAvailable) return false;
this._state = wrapper.readInt();
this._ownPetId = wrapper.readInt();