mirror of
https://gitlab.com/YuukiPS/GC-Proto.git
synced 2024-12-24 15:39:25 +03:00
* add check dup id.
* add PacketOpcodes (cmdid_to_op)
This commit is contained in:
parent
61ace18318
commit
85e0ba8e44
1924
PacketOpcodes.java
Normal file
1924
PacketOpcodes.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -1759,10 +1759,6 @@
|
||||
"name": "EvtSetAttackTargetNotify",
|
||||
"id": 399
|
||||
},
|
||||
{
|
||||
"name": "DebugNotify",
|
||||
"id": 101
|
||||
},
|
||||
{
|
||||
"name": "ExecuteGadgetLuaReq",
|
||||
"id": 269
|
||||
@ -6407,10 +6403,6 @@
|
||||
"name": "ActivityAcceptAllGiveGiftRsp",
|
||||
"id": 8132
|
||||
},
|
||||
{
|
||||
"name": "GetUgcRsp",
|
||||
"id": 6318
|
||||
},
|
||||
{
|
||||
"name": "FinishLanternProjectionReq",
|
||||
"id": 8704
|
||||
@ -6599,10 +6591,6 @@
|
||||
"name": "GetQuestLackingResourceRsp",
|
||||
"id": 458
|
||||
},
|
||||
{
|
||||
"name": "GetUgcReq",
|
||||
"id": 6326
|
||||
},
|
||||
{
|
||||
"name": "WinterCampStageInfoChangeNotify",
|
||||
"id": 8154
|
||||
|
84
op.js
84
op.js
@ -10,6 +10,8 @@ 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";
|
||||
|
||||
const write_op = "PacketOpcodes.java";
|
||||
|
||||
console.log(process.cwd());
|
||||
|
||||
//(TODO: add input file)
|
||||
@ -105,12 +107,13 @@ var rename_name_cmdid = 0;
|
||||
var noneed_rename_name_cmdid = 0;
|
||||
var data_gc_cmdid_nofound = [];
|
||||
|
||||
var check_dunp_id = [];
|
||||
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) {
|
||||
json_cmdid_old.forEach(function (s, index) {
|
||||
var id = s.id;
|
||||
var name = s.name;
|
||||
|
||||
@ -126,11 +129,49 @@ function update_cmdid_gc() {
|
||||
s.name = found_id.name;
|
||||
}
|
||||
} else {
|
||||
//console.log("Wow nofound -> ID: " + id + " | Name: " + name);
|
||||
console.log("Wow nofound -> ID: " + id + " | Name: " + name);
|
||||
data_gc_cmdid_nofound.push(s);
|
||||
nofound_cmdid_new++;
|
||||
}
|
||||
|
||||
// find dump by id
|
||||
var found_id = check_dunp_id.find((j) => j.id == id);
|
||||
if (found_id) {
|
||||
console.log(
|
||||
"Wow dup -> ID: " +
|
||||
id +
|
||||
" (ADD " +
|
||||
found_id.id +
|
||||
") | Name Remove: " +
|
||||
name +
|
||||
" (ADD " +
|
||||
found_id.name +
|
||||
")"
|
||||
);
|
||||
// remove bad
|
||||
json_cmdid_old.splice(index, 1);
|
||||
} else {
|
||||
check_dunp_id.push(s);
|
||||
}
|
||||
});
|
||||
|
||||
// I don't know why this happened but make sure to check again
|
||||
json_cmdid_old.forEach(function (s, index) {
|
||||
var id = s.id;
|
||||
var name = s.name;
|
||||
|
||||
// maybe need || j.name == name
|
||||
var found_id = json_cmdid_last.find((j) => j.id == id);
|
||||
if (found_id) {
|
||||
if (name != found_id.name) {
|
||||
console.log(
|
||||
"Wow why? -> ID: " + id + " | Name: " + name + " > " + found_id.name
|
||||
);
|
||||
s.name = found_id.name;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log(
|
||||
"found " +
|
||||
found_cmdid_new +
|
||||
@ -148,16 +189,47 @@ function update_cmdid_gc() {
|
||||
// save json
|
||||
function save_json(raw, file) {
|
||||
var j = JSON.stringify(raw, null, 4);
|
||||
fs.writeFile(file, j, "utf8", function (err) {
|
||||
save(j, file);
|
||||
}
|
||||
|
||||
function save(raw, file) {
|
||||
fs.writeFile(file, raw, "utf8", function (err) {
|
||||
if (err) {
|
||||
console.log("An error occured while writing JSON Object to File.");
|
||||
console.log("An error occured while writing to File.");
|
||||
return console.log(err);
|
||||
}
|
||||
console.log("JSON file has been saved.");
|
||||
console.log("File has been saved.");
|
||||
});
|
||||
}
|
||||
|
||||
update_cmdid_gc();
|
||||
function cmdid_to_op() {
|
||||
let melon =
|
||||
"\
|
||||
package emu.grasscutter.net.packet;\
|
||||
\n\
|
||||
\npublic class PacketOpcodes {\
|
||||
\n// Empty\
|
||||
\npublic static final int NONE = 0;\
|
||||
\n\
|
||||
\n// Opcodes\
|
||||
";
|
||||
|
||||
const cmdidfix_raw = fs.readFileSync(read_cmdid_output_gc_update);
|
||||
const json_cmdidfix_raw = JSON.parse(cmdidfix_raw);
|
||||
json_cmdidfix_raw.forEach(function (s) {
|
||||
melon += "\npublic static final int " + s.name + " = " + s.id + ";";
|
||||
});
|
||||
|
||||
melon += "\n}";
|
||||
save(melon, write_op); // use "npx prettier --write PacketOpcodes.java" for better Formatter
|
||||
}
|
||||
|
||||
function isBlank(str) {
|
||||
return !!!str || /^\s*$/.test(str);
|
||||
}
|
||||
|
||||
cmdid_to_op();
|
||||
//update_cmdid_gc();
|
||||
//get_cmdid_gc();
|
||||
//get_cmdid_json();
|
||||
//check_gen();
|
||||
|
Loading…
Reference in New Issue
Block a user