update tool clean proto
This commit is contained in:
parent
a87f2aedc3
commit
8ae9236b56
2413
PacketOpcodes.java
2413
PacketOpcodes.java
File diff suppressed because it is too large
Load Diff
6238
cmdid_gc.json
6238
cmdid_gc.json
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
903
gc_needed.json
903
gc_needed.json
File diff suppressed because it is too large
Load Diff
294
op.js
294
op.js
|
@ -9,16 +9,18 @@ const read_cmdid = "cmdid.csv";
|
|||
const read_cmdid_output = "cmdid.json";
|
||||
const read_cmdid_ht_output = "cmdid_ht_40.json";
|
||||
const read_cmdid_output_gc = "cmdid_gc.json";
|
||||
const read_cmdid_output_gc_full = "cmdid_gc_full.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";
|
||||
|
||||
console.log(process.cwd());
|
||||
|
||||
const json_gc_needed = read_json(file_gc_needed);
|
||||
|
||||
//(TODO: add input file)
|
||||
// folder gc auto-generated proto
|
||||
const folder_proto_gc_gen =
|
||||
|
@ -38,6 +40,7 @@ const folder_gc_scan = "../GSServer-GCOriginal/src/main/java/emu/grasscutter/";
|
|||
|
||||
var data = [];
|
||||
var data_gc = [];
|
||||
var data_gc2 = [];
|
||||
|
||||
var index_file_gen = 0;
|
||||
var index_file_cmdid = 0;
|
||||
|
@ -120,10 +123,20 @@ function get_cmdid_gc() {
|
|||
if (id == 8888888) {
|
||||
id = tes++;
|
||||
}
|
||||
|
||||
var subdata = new Object();
|
||||
subdata["name"] = name;
|
||||
subdata["id"] = id;
|
||||
data_gc.push(subdata);
|
||||
|
||||
var found = json_gc_needed.find((j) => name.match(j.name));
|
||||
if (!found) {
|
||||
// skip bad
|
||||
return;
|
||||
}
|
||||
|
||||
data_gc2.push(subdata);
|
||||
|
||||
//console.log(name);
|
||||
index_cmdid_gc++;
|
||||
} else {
|
||||
|
@ -134,7 +147,8 @@ function get_cmdid_gc() {
|
|||
console.log(
|
||||
"found cmd id " + index_cmdid_gc + " | no need " + index_cmdid_gc_out
|
||||
);
|
||||
save_json(data_gc, read_cmdid_output_gc);
|
||||
save_json(data_gc2, read_cmdid_output_gc);
|
||||
save_json(data_gc, read_cmdid_output_gc_full);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -240,20 +254,20 @@ function update_cmdid_gc() {
|
|||
|
||||
console.log(
|
||||
"found " +
|
||||
found_cmdid_new +
|
||||
" | no found " +
|
||||
nofound_cmdid_new +
|
||||
" | rename " +
|
||||
rename_name_cmdid +
|
||||
" | noneed rename " +
|
||||
noneed_rename_name_cmdid
|
||||
found_cmdid_new +
|
||||
" | no found " +
|
||||
nofound_cmdid_new +
|
||||
" | rename " +
|
||||
rename_name_cmdid +
|
||||
" | noneed rename " +
|
||||
noneed_rename_name_cmdid
|
||||
);
|
||||
|
||||
// const csvRows = Object.entries(read_cmdid_output_gc_update).map(([name, id]) => `${name},${id}`);
|
||||
// const csvRows = Object.entries(read_cmdid_output_gc_update).map(([name, id]) => `${name},${id}`);
|
||||
|
||||
|
||||
|
||||
// const csvData = csvRows.join("\n");
|
||||
// const csvData = csvRows.join("\n");
|
||||
|
||||
fs.writeFileSync(read_cmdid_last, melon);
|
||||
|
||||
|
@ -296,14 +310,13 @@ function cmdid_to_op() {
|
|||
\n// Opcodes\
|
||||
";
|
||||
|
||||
//const read_file_gcneed = fs.readFileSync(file_gc_needed2);
|
||||
//const json_gcneed_raw = JSON.parse(read_file_gcneed);
|
||||
|
||||
const cmdidfix_raw = fs.readFileSync(read_cmdid_output_gc);
|
||||
const json_cmdidfix_raw = JSON.parse(cmdidfix_raw);
|
||||
|
||||
//const json_cmdidfix_raw = read_json(read_cmdid_output_gc_update);
|
||||
|
||||
json_cmdidfix_raw.sort((a, b) => a.id - b.id);
|
||||
|
||||
json_cmdidfix_raw.forEach(function (s) {
|
||||
var found_id = dup_name.find((j) => j.name == s.name);
|
||||
if (!found_id) {
|
||||
|
@ -331,127 +344,33 @@ function cmdid_to_op() {
|
|||
}
|
||||
|
||||
var index_file_packet = 0;
|
||||
var index_file_packet_found = 0;
|
||||
var index_file_packet_nofound = 0;
|
||||
var index_file_packet_rename = 0;
|
||||
var index_file_packet_norename = 0;
|
||||
var index_file_packet_renamemulti = 0;
|
||||
var file_gc_need = [];
|
||||
function fix_packet(saveit = false) {
|
||||
|
||||
function fix_packet() {
|
||||
|
||||
const files = getAllFiles(folder_packet_gc);
|
||||
|
||||
const json_cmdid_last = read_json(read_cmdid_output);
|
||||
const json_cmdid_old = read_json(read_cmdid_output_gc);
|
||||
const json_cmdidfix_raw = read_json(read_cmdid_output_gc_update);
|
||||
|
||||
files.forEach(function (file) {
|
||||
//var f = path + "/" + file;
|
||||
|
||||
const read = fs.readFileSync(file);
|
||||
var real = read.toString();
|
||||
|
||||
var name = getPacketOpcodes(real);
|
||||
if (!name) {
|
||||
console.log("no found");
|
||||
return;
|
||||
const names = getPacketOpcodes(real); // Adjusted to get an array of names
|
||||
if (names.length === 0) {
|
||||
return; // Skip if no PacketOpcodes.* found
|
||||
}
|
||||
|
||||
if (name === "NONE") {
|
||||
return;
|
||||
}
|
||||
// Iterate through the names and add them to the array
|
||||
names.forEach(name => {
|
||||
const subdata = { name };
|
||||
file_gc_need.push(subdata);
|
||||
});
|
||||
|
||||
var subdata = new Object();
|
||||
subdata["name"] = name;
|
||||
file_gc_need.push(subdata);
|
||||
|
||||
//var name = c[1];
|
||||
|
||||
//console.log(r);
|
||||
|
||||
var found_old = json_cmdid_old.find((j) => j.name === name);
|
||||
if (found_old) {
|
||||
//console.log(found_old);
|
||||
index_file_packet_found++;
|
||||
var found_new = json_cmdid_last.find((j) => j.id == found_old.id);
|
||||
if (found_new) {
|
||||
if (found_new.name != found_old.name) {
|
||||
index_file_packet_rename++;
|
||||
console.log(
|
||||
"Found need rename: " + found_old.name + " > " + found_new.name
|
||||
);
|
||||
|
||||
// rename all
|
||||
json_cmdidfix_raw.forEach(function (s) {
|
||||
var r = s.replace;
|
||||
if (r) {
|
||||
// var notify = HomeNewUnlockedBgmIdListNotify.Unk2700_MEBFPBDNPGO_ServerNotify
|
||||
// var notify = Unk2700MEBFPBDNPGOServerNotify.HomeNewUnlockedBgmIdListNotify
|
||||
|
||||
// Unk2700MEBFPBDNPGOServerNotify to HomeNewUnlockedBgmIdListNotifyOuterClass
|
||||
// Unk2700OGHMHELMBNNServerRsp to HomeChangeBgmRspOuterClass
|
||||
|
||||
// - Need More Auto like -
|
||||
// addUnk2700ELJPLMIHNIP to addNewUnlockedBgmIdList (this should be found inside gen proto)
|
||||
// setUnk2700BJHAMKKECEI to setBgmId
|
||||
if (r.match("Unk")) {
|
||||
//console.log(r);
|
||||
var x = r.split("_");
|
||||
var tr = x.join("");
|
||||
var realneed = tr;
|
||||
|
||||
if (tr.match("ServerNotify")) {
|
||||
//console.log("found: "+tr);
|
||||
let re = new RegExp(`${tr}`, "g");
|
||||
tr = tr.replace(re, `${s.name}OuterClass`);
|
||||
//console.log("found: " + tr);
|
||||
} else if (tr.match("ServerRsp")) {
|
||||
let re = new RegExp(`${tr}`, "g");
|
||||
tr = tr.replace(re, `${s.name}OuterClass`);
|
||||
} else {
|
||||
let re = new RegExp(`${tr}`, "g");
|
||||
tr = tr.replace(re, s.name);
|
||||
//console.log("found: " + tr);
|
||||
}
|
||||
let re = new RegExp(`${realneed}`, "g");
|
||||
real = real.replace(re, tr);
|
||||
}
|
||||
let re = new RegExp(`${r}`, "g");
|
||||
real = real.replace(re, s.name);
|
||||
}
|
||||
});
|
||||
|
||||
// simpel rename
|
||||
//let re = new RegExp(`${found_old.name}`, "g");
|
||||
//real = real.replace(re, found_new.name);
|
||||
|
||||
//console.log(real);
|
||||
if (saveit) {
|
||||
save(real, f);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
index_file_packet_norename++;
|
||||
//console.log("Same name "+name);
|
||||
}
|
||||
} else {
|
||||
index_file_packet_nofound++;
|
||||
console.log("No found " + name);
|
||||
}
|
||||
|
||||
//return;
|
||||
index_file_packet++;
|
||||
});
|
||||
save_json(file_gc_need, file_gc_needed); // This only applies to PacketOpcodes
|
||||
|
||||
save_json(file_gc_need, file_gc_needed);
|
||||
console.log(
|
||||
"Index file: " +
|
||||
index_file_packet +
|
||||
" | found " +
|
||||
index_file_packet_found +
|
||||
" | No found " +
|
||||
index_file_packet_nofound +
|
||||
" | Rename " +
|
||||
index_file_packet_rename +
|
||||
" | NoRename " +
|
||||
index_file_packet_norename
|
||||
index_file_packet
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -476,18 +395,15 @@ function getAllFiles(dirPath, arrayOfFiles) {
|
|||
}
|
||||
|
||||
function getPacketOpcodes(raw) {
|
||||
var r = raw.match(/\(.*?\)/g).map((x) => x.replace(/[()]/g, ""));
|
||||
var name;
|
||||
r.forEach(function (s, index) {
|
||||
if (s.match("PacketOpcodes.")) {
|
||||
name = s.split("PacketOpcodes.")[1];
|
||||
if (name.match(",")) {
|
||||
name = name.split(",")[0];
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
const packetOpcodesRegex = /PacketOpcodes\.\w+/g;
|
||||
const packetOpcodesMatches = raw.match(packetOpcodesRegex);
|
||||
|
||||
if (packetOpcodesMatches) {
|
||||
return packetOpcodesMatches.map(match => match.replace('PacketOpcodes.', ''));
|
||||
} else {
|
||||
console.log('No PacketOpcodes.* found in the file.', raw);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// C:\Users\Administrator\Desktop\Projek\Docker\GS\gs\GSServer-GC\src\main\java\emu\grasscutter
|
||||
|
@ -556,17 +472,22 @@ function find_import(file) {
|
|||
return torequire;
|
||||
}
|
||||
|
||||
// Read the skip list
|
||||
const skipFilePath = './skip.txt';
|
||||
let skipList;
|
||||
try {
|
||||
const skipFileContent = fs.readFileSync(skipFilePath, 'utf-8');
|
||||
skipList = skipFileContent.split('\n').map(line => line.trim()).filter(line => line.length > 0);
|
||||
} catch (err) {
|
||||
console.error('Error reading skip file:', err);
|
||||
skipList = [];
|
||||
}
|
||||
|
||||
function clean_proto_gen() {
|
||||
//const files = getAllFiles(folder_proto_gc_gen);
|
||||
|
||||
const files = getAllFiles("./proto");
|
||||
const unimplemented = "./unimplemented/";
|
||||
|
||||
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);
|
||||
|
||||
//AbilityInvokeArgument
|
||||
console.log(
|
||||
"File proto: " + files.length + " | Need " + json_gc_needed.length
|
||||
);
|
||||
|
@ -574,11 +495,9 @@ function clean_proto_gen() {
|
|||
// find all file import
|
||||
files.forEach(function (file) {
|
||||
var name_file = path.parse(file).name;
|
||||
|
||||
var toaddfile = new Object();
|
||||
toaddfile["file"] = name_file;
|
||||
toaddfile["import"] = find_import(file);
|
||||
|
||||
file_proto.push(toaddfile);
|
||||
});
|
||||
|
||||
|
@ -592,6 +511,7 @@ function clean_proto_gen() {
|
|||
|
||||
var found_proto = file_proto.find((j) => name_file === j.file); // must same file
|
||||
if (found_proto) {
|
||||
|
||||
// if found import
|
||||
if (found_proto.import) {
|
||||
found_proto.import.forEach(function (s) {
|
||||
|
@ -619,8 +539,6 @@ function clean_proto_gen() {
|
|||
return noe;
|
||||
}
|
||||
|
||||
//console.log(find_json_proto("ActivityInfo"));
|
||||
|
||||
// try with proto json
|
||||
var filedonotdelete = [];
|
||||
files.forEach(function (file) {
|
||||
|
@ -636,16 +554,6 @@ function clean_proto_gen() {
|
|||
// skip
|
||||
}
|
||||
|
||||
// find miss scan
|
||||
var found2 = json_gc_needed2.find((j) => name_file.match(j.name));
|
||||
if (found2) {
|
||||
findme = true;
|
||||
} else {
|
||||
// skip
|
||||
}
|
||||
|
||||
// ModifierDurability >AbilityAppliedModifier -> AbilitySyncStateInfo -> AvatarEnterSceneInfo and multi file
|
||||
|
||||
// main file
|
||||
if (findme) {
|
||||
var tosub = find_json_proto(name_file);
|
||||
|
@ -665,6 +573,7 @@ function clean_proto_gen() {
|
|||
if (file.match("ChannelerSlabChallenge")) {
|
||||
console.log(file);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -678,16 +587,19 @@ function clean_proto_gen() {
|
|||
if (toskip) {
|
||||
found_noclean++;
|
||||
} else {
|
||||
found_needclean++;
|
||||
// ActivityInfo
|
||||
if (file.match("ChannelerSlabChallenge")) {
|
||||
console.log("ChannelerSlabChallenge");
|
||||
|
||||
if (skipList.includes(name_file)) {
|
||||
console.log('Skipping file:', file);
|
||||
found_noclean++;
|
||||
return;
|
||||
}
|
||||
//console.log(name_file);
|
||||
//console.log("Remove file: " + file);
|
||||
|
||||
found_needclean++;
|
||||
console.log("Move file: " + file);
|
||||
const destinationFile = path.join(unimplemented, path.basename(file));
|
||||
|
||||
try {
|
||||
fs.unlinkSync(file);
|
||||
//file removed
|
||||
fs.renameSync(file, destinationFile);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
@ -698,11 +610,11 @@ function clean_proto_gen() {
|
|||
|
||||
console.log(
|
||||
"No clean: " +
|
||||
found_noclean +
|
||||
" | Need to clean: " +
|
||||
found_needclean +
|
||||
" | Related " +
|
||||
found_maybe_related
|
||||
found_noclean +
|
||||
" | Need to clean: " +
|
||||
found_needclean +
|
||||
" | Related " +
|
||||
found_maybe_related
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -727,7 +639,7 @@ function clean_proto_gen_v2() {
|
|||
if (messageName === messageName.toUpperCase()) {
|
||||
console.log("Remove: " + file);
|
||||
try {
|
||||
fs.unlinkSync(file);
|
||||
//fs.unlinkSync(file);
|
||||
//file removed
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
@ -781,7 +693,7 @@ function scan_gc() {
|
|||
}
|
||||
});
|
||||
|
||||
save_json(g_todump, file_gc_needed2); // This only applies to PacketOpcodes
|
||||
//save_json(g_todump, file_gc_needed); // This only applies to PacketOpcodes
|
||||
|
||||
//console.log(g_todump);
|
||||
}
|
||||
|
@ -855,7 +767,7 @@ function clean_proto_event() {
|
|||
found_needclean++;
|
||||
//console.log(name_file);
|
||||
try {
|
||||
fs.unlinkSync(file);
|
||||
//fs.unlinkSync(file);
|
||||
console.log("Remove file: " + file);
|
||||
//file removed
|
||||
} catch (err) {
|
||||
|
@ -868,11 +780,11 @@ function clean_proto_event() {
|
|||
|
||||
console.log(
|
||||
"No clean: " +
|
||||
found_noclean +
|
||||
" | Need to clean: " +
|
||||
found_needclean +
|
||||
" | Related " +
|
||||
found_maybe_related
|
||||
found_noclean +
|
||||
" | Need to clean: " +
|
||||
found_needclean +
|
||||
" | Related " +
|
||||
found_maybe_related
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -948,7 +860,7 @@ function clean_proto_event_v2() {
|
|||
found_needclean++;
|
||||
console.log(name_file);
|
||||
try {
|
||||
fs.unlinkSync(file);
|
||||
//fs.unlinkSync(file);
|
||||
console.log("Remove file: " + file);
|
||||
//file removed
|
||||
} catch (err) {
|
||||
|
@ -962,11 +874,11 @@ function clean_proto_event_v2() {
|
|||
|
||||
console.log(
|
||||
"No clean: " +
|
||||
found_noclean +
|
||||
" | Need to clean: " +
|
||||
found_needclean +
|
||||
" | Related " +
|
||||
found_maybe_related
|
||||
found_noclean +
|
||||
" | Need to clean: " +
|
||||
found_needclean +
|
||||
" | Related " +
|
||||
found_maybe_related
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -988,17 +900,23 @@ function cmdid_json_to_csv() {
|
|||
|
||||
// cmdid_json_to_csv();
|
||||
// Update GC Proto
|
||||
// get_cmdid_gc(); // 1. get cmd old gc
|
||||
//read_cmdid_ht_json(); // 2 or
|
||||
// get_cmdid_json(); // 2. get last cmdid.csv to json
|
||||
// now we have cmdid_gc.json and cmdid.json
|
||||
// update_cmdid_gc(); // 3. update gc cmdid (mode by id)
|
||||
cmdid_to_op(); // 4. update op
|
||||
// npx prettier --write PacketOpcodes.java
|
||||
// scan_gc(); // 5. scan gc
|
||||
// clean_proto_event(); // 6. clean event, need manual
|
||||
// clean_proto_gen(); // 6. clean proto
|
||||
// clean_proto_gen_v2();
|
||||
|
||||
//console.log(skipList)
|
||||
// TODO: clean DungeonSettleNotify
|
||||
// clean_proto_event_v2();
|
||||
|
||||
// 1
|
||||
//fix_packet();
|
||||
// 2
|
||||
//get_cmdid_gc();
|
||||
// 3
|
||||
//cmdid_to_op();
|
||||
// 4
|
||||
//clean_proto_gen();
|
|
@ -0,0 +1,36 @@
|
|||
Retcode
|
||||
PacketHead
|
||||
AttackResult
|
||||
HitCollision
|
||||
AttackHitEffectResult
|
||||
AbilityMetaAddAbility
|
||||
AbilityMetaReInitOverrideMap
|
||||
AbilityMetaSetKilledState
|
||||
AbilityMetaModifierChange
|
||||
ModifierAction
|
||||
EntityMoveInfo
|
||||
AbilityActionGenerateElemBall
|
||||
AbilityActionCreateGadget
|
||||
AbilityActionSetRandomOverrideMapValue
|
||||
AbilityActionSummon
|
||||
AbilityIdentifier
|
||||
EvtBeingHitInfo
|
||||
EvtAnimatorParameterInfo
|
||||
TrialAvatarActivityDetailInfo
|
||||
TrialAvatarActivityRewardDetailInfo
|
||||
ForceUpdateInfo
|
||||
QueryCurrRegionHttpRsp
|
||||
QueryRegionListHttpRsp
|
||||
RegionInfo
|
||||
RegionSimpleInfo
|
||||
StopServerInfo
|
||||
QuickUseWidgetReq
|
||||
QuickUseWidgetRsp
|
||||
WidgetCameraInfo
|
||||
WidgetThunderBirdFeatherInfo
|
||||
WidgetSorushInfo
|
||||
SkyCrystalDetectorQuickUseResult
|
||||
SetPlayerBornDataReq
|
||||
CancelCoopTaskRsp
|
||||
WidgetGadgetAllDataNotify
|
||||
ModifierProperty
|
Loading…
Reference in New Issue