Initial commit

This commit is contained in:
2026-08-24 22:20:36 +02:00
commit 62f7b1278a
251 changed files with 16670 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
/*
@Packet name Reward
@Packet identifier 131
@Description Contains information about rewards the player got
@Data pId
@Structure -
*/
module.exports = {
init: (isRegular, length) => {
const maxEntries = Math.floor((255 - (1 + 2)) / 6);
let submittedLength = length;
if (length > maxEntries) length = maxEntries;
submittedLength -= length;
const offset = 3;
const packetLength = length * 6 + 1 + 2;
let i = 0;
let j = 0;
const buffer = new ArrayBuffer(packetLength);
const view = new DataView(buffer);
view.setUint8(0, 131);
view.setUint8(1, packetLength);
view.setUint8(2, isRegular ? 255 : 0);
const buffers = [buffer];
const views = [view];
return {
update: d => {
const startIndex = i * 6;
views[j].setUint8(offset + startIndex, d.categoryID);
views[j].setUint8(offset + startIndex + 1, d.id);
views[j].setInt32(offset + startIndex + 2, d.amount);
i++;
if (maxEntries === i) {
i = 0;
j++;
if (submittedLength > maxEntries) length = maxEntries;
else length = submittedLength;
submittedLength -= length
if (submittedLength < 0) length = maxEntries + submittedLength;
const packetLength = length * 6 + 1 + 2;
const buffer = new ArrayBuffer(packetLength);
const view = new DataView(buffer);
view.setUint8(0, 131);
view.setUint8(1, packetLength);
view.setUint8(2, isRegular ? 255 : 0);
buffers.push(buffer);
views.push(view);
};
},
get: () => {
return buffers;
}
};
}
};