mirror of
https://gitlab.com/YuukiPS/GC-Proto.git
synced 2024-12-25 07:59:24 +03:00
add scan gc
This commit is contained in:
parent
95bcedf14b
commit
d508ff6c88
1880
gc_needed2.json
Normal file
1880
gc_needed2.json
Normal file
File diff suppressed because it is too large
Load Diff
134
op.js
134
op.js
@ -9,7 +9,9 @@ const read_cmdid_output = "cmdid.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";
|
||||
|
||||
const file_gc_needed = "gc_needed.json";
|
||||
const file_gc_needed2 = "gc_needed2.json";
|
||||
|
||||
const write_op = "PacketOpcodes.java";
|
||||
|
||||
@ -19,6 +21,7 @@ console.log(process.cwd());
|
||||
// folder gc auto-generated proto
|
||||
const folder_proto_gc_gen =
|
||||
"../Grasscutter-Yuuki/src/generated/main/java/emu/grasscutter/net/proto/";
|
||||
|
||||
// file PacketOpcodes currently in use
|
||||
const read_cmdid_gc =
|
||||
"../Grasscutter-Yuuki/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java";
|
||||
@ -26,6 +29,8 @@ const read_cmdid_gc =
|
||||
const folder_packet_gc =
|
||||
"../Grasscutter-Yuuki/src/main/java/emu/grasscutter/server/packet/";
|
||||
|
||||
const folder_gc_scan = "../Grasscutter-Yuuki/src/main/java/emu/grasscutter/";
|
||||
|
||||
//const read_cmdid = fs.readFileSync("cmdid.csv");
|
||||
//const read_packetopcodes = fs.readFileSync("PacketOpcodes.java");
|
||||
|
||||
@ -366,7 +371,7 @@ function fix_packet(saveit = false) {
|
||||
//return;
|
||||
index_file_packet++;
|
||||
});
|
||||
save_json(file_gc_need, file_gc_needed);
|
||||
save_json(file_gc_need, file_gc_needed); // This only applies to PacketOpcodes
|
||||
console.log(
|
||||
"Index file: " +
|
||||
index_file_packet +
|
||||
@ -416,6 +421,8 @@ function getPacketOpcodes(raw) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// C:\Users\Administrator\Desktop\Projek\Docker\GS\gs\Grasscutter-Yuuki\src\main\java\emu\grasscutter
|
||||
|
||||
var file_toclean = [];
|
||||
var file_toaddmore = [];
|
||||
var found_noclean = 0;
|
||||
@ -426,10 +433,12 @@ function clean_proto_gen() {
|
||||
const files = getAllFiles("./proto");
|
||||
|
||||
const json_gc_needed = read_json(file_gc_needed);
|
||||
const json_gc_needed2 = read_json(file_gc_needed2);
|
||||
|
||||
const json_gc_now = read_json(read_cmdid_output_gc);
|
||||
const json_gc_update = read_json(read_cmdid_output_gc_update);
|
||||
//console.log(json_gc_needed);
|
||||
|
||||
//AbilityInvokeArgument
|
||||
console.log(
|
||||
"File proto: " + files.length + " | Need " + json_gc_needed.length
|
||||
);
|
||||
@ -438,66 +447,72 @@ function clean_proto_gen() {
|
||||
|
||||
// find all file import
|
||||
files.forEach(function (file) {
|
||||
var found = json_gc_needed.find((j) => file.match(j.name));
|
||||
if (found) {
|
||||
// read file
|
||||
const read = fs.readFileSync(file);
|
||||
var rd = read.toString();
|
||||
// find import
|
||||
while ((m = regex.exec(rd)) !== null) {
|
||||
// This is necessary to avoid infinite loops with zero-width matches
|
||||
if (m.index === regex.lastIndex) {
|
||||
regex.lastIndex++;
|
||||
}
|
||||
// The result can be accessed through the `m`-variable.
|
||||
m.forEach((match, groupIndex) => {
|
||||
// only index 1 grup
|
||||
if (groupIndex == 1) {
|
||||
var found_rt = file_toaddmore.find((j) => j.name === match);
|
||||
if (found_rt) {
|
||||
//found_maybe_related++;
|
||||
//console.log(`Skip ${match}`);
|
||||
} else {
|
||||
var subdata = new Object();
|
||||
subdata["name"] = match;
|
||||
file_toaddmore.push(subdata);
|
||||
found_maybe_related++;
|
||||
}
|
||||
}
|
||||
});
|
||||
// read file
|
||||
const read = fs.readFileSync(file);
|
||||
var rd = read.toString();
|
||||
|
||||
// find import
|
||||
while ((m = regex.exec(rd)) !== null) {
|
||||
// This is necessary to avoid infinite loops with zero-width matches
|
||||
if (m.index === regex.lastIndex) {
|
||||
regex.lastIndex++;
|
||||
}
|
||||
// The result can be accessed through the `m`-variable.
|
||||
m.forEach((match, groupIndex) => {
|
||||
// only index 1 grup
|
||||
if (groupIndex == 1) {
|
||||
var found_rt = file_toaddmore.find((j) => j.name === match);
|
||||
if (found_rt) {
|
||||
//console.log(`Skip ${match}`);
|
||||
} else {
|
||||
var subdata = new Object();
|
||||
subdata["name"] = match;
|
||||
file_toaddmore.push(subdata);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// all
|
||||
// last try
|
||||
files.forEach(function (file) {
|
||||
var todoremove = false;
|
||||
|
||||
// main file
|
||||
var found = json_gc_needed.find((j) => file.match(j.name));
|
||||
if (found) {
|
||||
found_noclean++;
|
||||
// skip
|
||||
} else {
|
||||
var found1 = file_toaddmore.find((j) => file.match(j.name));
|
||||
var found1 = file_toaddmore.find((j) => file.match(j.name)); // find import
|
||||
if (found1) {
|
||||
found_noclean++;
|
||||
// skip
|
||||
//console.log("Files sub are required: "+file);
|
||||
found_maybe_related++;
|
||||
} else {
|
||||
found_needclean++;
|
||||
if (file.match("Retcode")) {
|
||||
console.log("found");
|
||||
} else {
|
||||
todoremove = true;
|
||||
var found2 = json_gc_needed2.find((j) => file.match(j.name)); // find miss scan
|
||||
if (found2) {
|
||||
// skip
|
||||
found_maybe_related++;
|
||||
} else {
|
||||
todoremove = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (todoremove) {
|
||||
found_needclean++;
|
||||
try {
|
||||
fs.unlinkSync(file);
|
||||
//file removed
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
} else {
|
||||
found_noclean++;
|
||||
}
|
||||
});
|
||||
|
||||
@ -513,6 +528,55 @@ function clean_proto_gen() {
|
||||
);
|
||||
}
|
||||
|
||||
var g_todump = [];
|
||||
function scan_gc() {
|
||||
const files = getAllFiles(folder_gc_scan);
|
||||
|
||||
console.log("index file: " + files.length);
|
||||
|
||||
const regex = /import emu.grasscutter.net.proto.(.*?);/g;
|
||||
|
||||
files.forEach(function (file) {
|
||||
// read file
|
||||
const read = fs.readFileSync(file);
|
||||
var rd = read.toString();
|
||||
// find import
|
||||
while ((m = regex.exec(rd)) !== null) {
|
||||
// This is necessary to avoid infinite loops with zero-width matches
|
||||
if (m.index === regex.lastIndex) {
|
||||
regex.lastIndex++;
|
||||
}
|
||||
// The result can be accessed through the `m`-variable.
|
||||
m.forEach((match, groupIndex) => {
|
||||
// only index 1 grup
|
||||
if (groupIndex == 1) {
|
||||
if (match === "*") {
|
||||
return;
|
||||
}
|
||||
if (match.match(".")) {
|
||||
match = match.split(".")[0];
|
||||
}
|
||||
match = match.replace("OuterClass", "");
|
||||
var found_rt = g_todump.find((j) => j.name === match);
|
||||
if (found_rt) {
|
||||
//found_maybe_related++;
|
||||
//console.log(`Skip ${match}`);
|
||||
} else {
|
||||
var subdata = new Object();
|
||||
subdata["name"] = match;
|
||||
g_todump.push(subdata);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
save_json(g_todump, file_gc_needed2); // This only applies to PacketOpcodes
|
||||
|
||||
//console.log(g_todump);
|
||||
}
|
||||
|
||||
//scan_gc();
|
||||
clean_proto_gen();
|
||||
//fix_packet(false);
|
||||
//cmdid_to_op();
|
||||
|
Loading…
Reference in New Issue
Block a user