Significant tidy-up. Update msg_template and add new ObjectAnimation message. Tidy up imports. Added buffer overrun check to the packet decoders since the message template doesn't seem to always correspond with what we receive (Specifically, MapBlockReply's new Size parameter)
This commit is contained in:
80
lib/classes/messages/ObjectAnimation.ts
Normal file
80
lib/classes/messages/ObjectAnimation.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
// This file has been automatically generated by writeMessageClasses.js
|
||||
|
||||
import { UUID } from '../UUID';
|
||||
import { MessageFlags } from '../../enums/MessageFlags';
|
||||
import { MessageBase } from '../MessageBase';
|
||||
import { Message } from '../../enums/Message';
|
||||
|
||||
export class ObjectAnimationMessage implements MessageBase
|
||||
{
|
||||
name = 'ObjectAnimation';
|
||||
messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyHigh;
|
||||
id = Message.ObjectAnimation;
|
||||
|
||||
Sender: {
|
||||
ID: UUID;
|
||||
};
|
||||
AnimationList: {
|
||||
AnimID: UUID;
|
||||
AnimSequenceID: number;
|
||||
}[];
|
||||
|
||||
getSize(): number
|
||||
{
|
||||
return ((20) * this.AnimationList.length) + 17;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.Sender['ID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
const count = this.AnimationList.length;
|
||||
buf.writeUInt8(this.AnimationList.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.AnimationList[i]['AnimID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.AnimationList[i]['AnimSequenceID'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
let varLength = 0;
|
||||
const newObjSender: {
|
||||
ID: UUID
|
||||
} = {
|
||||
ID: UUID.zero()
|
||||
};
|
||||
newObjSender['ID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.Sender = newObjSender;
|
||||
if (pos >= buf.length)
|
||||
{
|
||||
return pos - startPos;
|
||||
}
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.AnimationList = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjAnimationList: {
|
||||
AnimID: UUID,
|
||||
AnimSequenceID: number
|
||||
} = {
|
||||
AnimID: UUID.zero(),
|
||||
AnimSequenceID: 0
|
||||
};
|
||||
newObjAnimationList['AnimID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAnimationList['AnimSequenceID'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
this.AnimationList.push(newObjAnimationList);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user