Commit feefd40d authored by nanahira's avatar nanahira

Merge branch 'mc'

parents d9a7b7c8 c7e68ffa
...@@ -28,7 +28,7 @@ class Handler { ...@@ -28,7 +28,7 @@ class Handler {
} }
} }
class YGOProMessagesHelper { class YGOProMessagesHelper {
constructor() { constructor(singleHandleLimit) {
this.handlers = { this.handlers = {
STOC: [new Map(), STOC: [new Map(),
new Map(), new Map(),
...@@ -45,6 +45,12 @@ class YGOProMessagesHelper { ...@@ -45,6 +45,12 @@ class YGOProMessagesHelper {
}; };
this.initDatas(); this.initDatas();
this.initStructs(); this.initStructs();
if (singleHandleLimit) {
this.singleHandleLimit = singleHandleLimit;
}
else {
this.singleHandleLimit = 1000;
}
} }
initDatas() { initDatas() {
this.structs_declaration = structs_json_1.default; this.structs_declaration = structs_json_1.default;
...@@ -159,7 +165,7 @@ class YGOProMessagesHelper { ...@@ -159,7 +165,7 @@ class YGOProMessagesHelper {
let messageLength = 0; let messageLength = 0;
let bufferProto = 0; let bufferProto = 0;
let datas = []; let datas = [];
for (let l = 0; l < 1000; ++l) { for (let l = 0; l < this.singleHandleLimit; ++l) {
if (messageLength === 0) { if (messageLength === 0) {
if (messageBuffer.length >= 2) { if (messageBuffer.length >= 2) {
messageLength = messageBuffer.readUInt16LE(0); messageLength = messageBuffer.readUInt16LE(0);
...@@ -229,7 +235,7 @@ class YGOProMessagesHelper { ...@@ -229,7 +235,7 @@ class YGOProMessagesHelper {
break; break;
} }
} }
if (l === 999) { if (l === this.singleHandleLimit - 1) {
feedback = { feedback = {
type: "OVERSIZE", type: "OVERSIZE",
message: `Oversized ${direction}` message: `Oversized ${direction}`
......
...@@ -54,8 +54,9 @@ export class YGOProMessagesHelper { ...@@ -54,8 +54,9 @@ export class YGOProMessagesHelper {
typedefs: any; typedefs: any;
proto_structs: any; proto_structs: any;
constants: any; constants: any;
singleHandleLimit: number;
constructor() { constructor(singleHandleLimit?: number) {
this.handlers = { this.handlers = {
STOC: [new Map(), STOC: [new Map(),
new Map(), new Map(),
...@@ -72,6 +73,11 @@ export class YGOProMessagesHelper { ...@@ -72,6 +73,11 @@ export class YGOProMessagesHelper {
} }
this.initDatas(); this.initDatas();
this.initStructs(); this.initStructs();
if (singleHandleLimit) {
this.singleHandleLimit = singleHandleLimit;
} else {
this.singleHandleLimit = 1000;
}
} }
initDatas() { initDatas() {
...@@ -195,7 +201,7 @@ export class YGOProMessagesHelper { ...@@ -195,7 +201,7 @@ export class YGOProMessagesHelper {
let messageLength = 0; let messageLength = 0;
let bufferProto = 0; let bufferProto = 0;
let datas: Buffer[] = []; let datas: Buffer[] = [];
for (let l = 0; l < 1000; ++l) { for (let l = 0; l < this.singleHandleLimit; ++l) {
if (messageLength === 0) { if (messageLength === 0) {
if (messageBuffer.length >= 2) { if (messageBuffer.length >= 2) {
messageLength = messageBuffer.readUInt16LE(0); messageLength = messageBuffer.readUInt16LE(0);
...@@ -260,7 +266,7 @@ export class YGOProMessagesHelper { ...@@ -260,7 +266,7 @@ export class YGOProMessagesHelper {
break; break;
} }
} }
if (l === 999) { if (l === this.singleHandleLimit - 1) {
feedback = { feedback = {
type: "OVERSIZE", type: "OVERSIZE",
message: `Oversized ${direction}` 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