add fixed name based on latest data proto.

include those that are not known maybe because it's custom or latest version has been removed.
This commit is contained in:
Akbar Yahya 2022-11-10 19:40:49 +08:00
parent a4bd28fe02
commit 61ace18318
No known key found for this signature in database
GPG Key ID: 0C9985FEC5C018C9
3 changed files with 7802 additions and 24 deletions

62
cmdid_gc_nofound.json Normal file
View File

@ -0,0 +1,62 @@
[
{
"name": "FireworkNotify",
"id": 5934
},
{
"name": "FireworkReq",
"id": 6068
},
{
"name": "FireworkRsp",
"id": 5918
},
{
"name": "FireworkSetNotify",
"id": 6079
},
{
"name": "FireworkSetReq",
"id": 6099
},
{
"name": "FireworkSetRsp",
"id": 5969
},
{
"name": "MusicGameGetBeatmapRsp",
"id": 6309
},
{
"name": "MusicGameCreateBeatmapRsp",
"id": 6347
},
{
"name": "MusicGameSearchBeatmapRsp",
"id": 6304
},
{
"name": "MusicGameSearchBeatmapReq",
"id": 6343
},
{
"name": "MusicGameStartToPlayOthersBeatmapReq",
"id": 6302
},
{
"name": "MusicGameStartToPlayOthersBeatmapRsp",
"id": 6313
},
{
"name": "PrivateChatSetSequenceReq",
"id": 4985
},
{
"name": "PrivateChatSetSequenceRsp",
"id": 4957
},
{
"name": "Unk2700_NGPMINKIOPK",
"id": 8956
}
]

7674
cmdid_gc_update.json Normal file

File diff suppressed because it is too large Load Diff

78
op.js
View File

@ -7,6 +7,8 @@ const readline = require("readline");
const read_cmdid = "cmdid.csv"; const read_cmdid = "cmdid.csv";
const read_cmdid_output = "cmdid.json"; const read_cmdid_output = "cmdid.json";
const read_cmdid_output_gc = "cmdid_gc.json"; const read_cmdid_output_gc = "cmdid_gc.json";
const read_cmdid_output_gc_update = "cmdid_gc_update.json";
const read_cmdid_output_gc_nofound = "cmdid_gc_nofound.json";
console.log(process.cwd()); console.log(process.cwd());
@ -58,17 +60,11 @@ function get_cmdid_json() {
}); });
lineReadercmdid.on("close", function () { lineReadercmdid.on("close", function () {
console.log("found cmd id " + index_file_cmdid); console.log("found cmd id " + index_file_cmdid);
var strNotes = JSON.stringify(data, null, 4); save_json(data, read_cmdid_output);
fs.writeFile(read_cmdid_output, strNotes, "utf8", function (err) {
if (err) {
console.log("An error occured while writing JSON Object to File.");
return console.log(err);
}
console.log("JSON file has been saved.");
});
}); });
} }
// create cmdid from gc which comes from PacketOpcodes
function get_cmdid_gc() { function get_cmdid_gc() {
const inputStreamcmdid = fs.createReadStream(read_cmdid_gc); const inputStreamcmdid = fs.createReadStream(read_cmdid_gc);
var lineReadercmdid = readline.createInterface({ var lineReadercmdid = readline.createInterface({
@ -94,28 +90,74 @@ function get_cmdid_gc() {
} else { } else {
index_cmdid_gc_out++; index_cmdid_gc_out++;
} }
/*
var subdata = new Object();
subdata["name"] = config[0];
subdata["id"] = parseInt(config[1]);
data.push(subdata);
*/
}); });
lineReadercmdid.on("close", function () { lineReadercmdid.on("close", function () {
console.log( console.log(
"found cmd id " + index_cmdid_gc + " | no need " + index_cmdid_gc_out "found cmd id " + index_cmdid_gc + " | no need " + index_cmdid_gc_out
); );
var strNotes = JSON.stringify(data_gc, null, 4); save_json(data_gc, read_cmdid_output_gc);
fs.writeFile(read_cmdid_output_gc, strNotes, "utf8", function (err) { });
}
var found_cmdid_new = 0;
var nofound_cmdid_new = 0;
var rename_name_cmdid = 0;
var noneed_rename_name_cmdid = 0;
var data_gc_cmdid_nofound = [];
function update_cmdid_gc() {
const cmd_last = fs.readFileSync(read_cmdid_output);
const cmd_old = fs.readFileSync(read_cmdid_output_gc);
const json_cmdid_last = JSON.parse(cmd_last);
const json_cmdid_old = JSON.parse(cmd_old);
json_cmdid_old.forEach(function (s) {
var id = s.id;
var name = s.name;
var found_id = json_cmdid_last.find((j) => j.id == id);
if (found_id) {
found_cmdid_new++;
if (name == found_id.name) {
noneed_rename_name_cmdid++;
} else {
rename_name_cmdid++;
//console.log("Wow rename -> ID: "+id+" | Name: "+name+" > "+found_id.name);
// rename json_cmdid_old
s.name = found_id.name;
}
} else {
//console.log("Wow nofound -> ID: " + id + " | Name: " + name);
data_gc_cmdid_nofound.push(s);
nofound_cmdid_new++;
}
});
console.log(
"found " +
found_cmdid_new +
" | no found " +
nofound_cmdid_new +
" | rename " +
rename_name_cmdid +
" | noneed rename " +
noneed_rename_name_cmdid
);
save_json(json_cmdid_old, read_cmdid_output_gc_update);
save_json(data_gc_cmdid_nofound, read_cmdid_output_gc_nofound);
}
// save json
function save_json(raw, file) {
var j = JSON.stringify(raw, null, 4);
fs.writeFile(file, j, "utf8", function (err) {
if (err) { if (err) {
console.log("An error occured while writing JSON Object to File."); console.log("An error occured while writing JSON Object to File.");
return console.log(err); return console.log(err);
} }
console.log("JSON file has been saved."); console.log("JSON file has been saved.");
}); });
});
} }
get_cmdid_gc(); update_cmdid_gc();
//get_cmdid_gc();
//get_cmdid_json(); //get_cmdid_json();
//check_gen(); //check_gen();