Commit feefd40d authored by nanahira's avatar nanahira

Merge branch 'mc'

parents d9a7b7c8 c7e68ffa
......@@ -28,7 +28,7 @@ class Handler {
}
}
class YGOProMessagesHelper {
constructor() {
constructor(singleHandleLimit) {
this.handlers = {
STOC: [new Map(),
new Map(),
......@@ -45,6 +45,12 @@ class YGOProMessagesHelper {
};
this.initDatas();
this.initStructs();
if (singleHandleLimit) {
this.singleHandleLimit = singleHandleLimit;
}
else {
this.singleHandleLimit = 1000;
}
}
initDatas() {
this.structs_declaration = structs_json_1.default;
......@@ -159,7 +165,7 @@ class YGOProMessagesHelper {
let messageLength = 0;
let bufferProto = 0;
let datas = [];
for (let l = 0; l < 1000; ++l) {
for (let l = 0; l < this.singleHandleLimit; ++l) {
if (messageLength === 0) {
if (messageBuffer.length >= 2) {
messageLength = messageBuffer.readUInt16LE(0);
......@@ -229,7 +235,7 @@ class YGOProMessagesHelper {
break;
}
}
if (l === 999) {
if (l === this.singleHandleLimit - 1) {
feedback = {
type: "OVERSIZE",
message: `Oversized ${direction}`
......
......@@ -54,8 +54,9 @@ export class YGOProMessagesHelper {
typedefs: any;
proto_structs: any;
constants: any;
singleHandleLimit: number;
constructor() {
constructor(singleHandleLimit?: number) {
this.handlers = {
STOC: [new Map(),
new Map(),
......@@ -72,6 +73,11 @@ export class YGOProMessagesHelper {
}
this.initDatas();
this.initStructs();
if (singleHandleLimit) {
this.singleHandleLimit = singleHandleLimit;
} else {
this.singleHandleLimit = 1000;
}
}
initDatas() {
......@@ -195,7 +201,7 @@ export class YGOProMessagesHelper {
let messageLength = 0;
let bufferProto = 0;
let datas: Buffer[] = [];
for (let l = 0; l < 1000; ++l) {
for (let l = 0; l < this.singleHandleLimit; ++l) {
if (messageLength === 0) {
if (messageBuffer.length >= 2) {
messageLength = messageBuffer.readUInt16LE(0);
......@@ -260,7 +266,7 @@ export class YGOProMessagesHelper {
break;
}
}
if (l === 999) {
if (l === this.singleHandleLimit - 1) {
feedback = {
type: "OVERSIZE",
message: `Oversized ${direction}`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment