You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +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:
+8
-9
@@ -19,17 +19,16 @@ 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();
|
||||
this._otherPetId = wrapper.readInt();
|
||||
this._state = wrapper.readInt();
|
||||
this._ownPetId = wrapper.readInt();
|
||||
this._otherPetId = wrapper.readInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public get state(): number
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user