diff --git a/doc/README.txt b/doc/README.txt index d60a57d..477542d 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -36,4 +36,8 @@ config.json常用设置 例 略 5. 如果有多个条件,请分别填上 -例 "room": [3, 4],"round": [8],"timeafter": "2019-02-02 00:00:00" 分析在19年2月2日以后打的金场南风及玉场南风 \ No newline at end of file +例 "room": [3, 4],"round": [8],"timeafter": "2019-02-02 00:00:00" 分析在19年2月2日以后打的金场南风及玉场南风 + +6. 更多配置请参考https://github.com/zyr17/MajsoulPaipuAnalyzer/blob/master/doc/config.md + +7. 若在文件中添加了中文(如name中使用了中文字符串),请确保文件以UTF-8编码保存。例如对于Windows记事本需要另存为并在下方编码选择UTF-8。 \ No newline at end of file diff --git a/doc/release-notes.txt b/doc/release-notes.txt index 6411ad6..bffeb42 100644 --- a/doc/release-notes.txt +++ b/doc/release-notes.txt @@ -1,5 +1,7 @@ 0.2.4 1.PaipuAnalyzer运行速度优化 +2.支持UTF-8 with BOM的json数据 +3.增强错误收集功能 0.2.3 1.重构analyzer.cpp代码 diff --git a/lib/majsoul/analyze.js b/lib/majsoul/analyze.js index ee42a8d..3dbaa32 100644 --- a/lib/majsoul/analyze.js +++ b/lib/majsoul/analyze.js @@ -101,13 +101,27 @@ function getstring(arr, start, length){ function analyzelogin(sender, arr, start){ if (arr[start] != 0x12){ - console.error('in analyzelogin: not start with 0x12'); + reporterror({ + position: 'analyzelogin', + message: 'in analyzelogin: not start with 0x12', + data: { + arr: arr.slice(0, arr.length - 36),//为安全考虑,不上传最后36字节的access_token + start + } + }); return; } let length; [length, start] = getnumber(arr, start + 1); if (arr[start] != 0x10){ - console.error('in analyzelogin: not start with 0x10'); + reporterror({ + position: 'analyzelogin', + message: 'in analyzelogin: not start with 0x10', + data: { + arr: arr.slice(0, arr.length - 36),//为安全考虑,不上传最后36字节的access_token + start + } + }); return; } [length, start] = getnumber(arr, start + 1); @@ -116,7 +130,14 @@ function analyzelogin(sender, arr, start){ function analyzepaipu(arr, start){ if (arr[start] != 0x12){ - console.error('in analyzepaipu: not start with 0x12'); + reporterror({ + position: 'analyzepaipu', + message: 'in analyzepaipu: not start with 0x12', + data: { + arr, + start + } + }); return; } let length; @@ -492,7 +513,14 @@ function analyze(sender, data){ let number = arr8[1] + arr8[2] * 256; let req = clientrequest[number]; if (req == undefined){ - console.error('request not find'); + reporterror({ + position: 'analyze', + message: 'request not find', + data: { + servernumber: number, + clientrequest + } + }); return; } if (req == '.lq.Lobby.oauth2Login'){ diff --git a/src/algo.cpp b/src/algo.cpp index c240d32..959594c 100644 --- a/src/algo.cpp +++ b/src/algo.cpp @@ -343,6 +343,7 @@ CJsonObject ReadJSON(const std::string &filename){ } delete[] buffer; fclose(f); + if ((unsigned char)jsonstr[0] == 0xef && (unsigned char)jsonstr[1] == 0xbb && (unsigned char)jsonstr[2] == 0xbf) jsonstr.erase(0, 3); return CJsonObject(jsonstr); } @@ -355,6 +356,7 @@ std::vector ReadLineJSON(const std::string &filename, const std::st if (fgets(buf, JSONBUFFERSIZE, f) == NULL) break; ts += buf; ts += suffix; + if ((unsigned char)ts[0] == 0xef && (unsigned char)ts[1] == 0xbb && (unsigned char)ts[2] == 0xbf) ts.erase(0, 3); res.push_back(CJsonObject(ts)); } fclose(f);