补充错误码比对工具

main
XieXiaoxin 2026-01-08 13:57:00 +08:00
parent edcda49f6e
commit 1f15171bb0
2 changed files with 61 additions and 5 deletions

View File

@ -12,18 +12,74 @@ using UnityEngine;
using System.IO;
using System.Xml;
using System.Text;
using cfg.ErrorCfg;
using System;
public static class DBTools
{
private static string SERVER_DIR = Application.dataPath + $"/../../../NLDServer";
private static string DB_DEF_PATH = SERVER_DIR + "/common/db/db_def.go";
static string PROTO_DIR = Application.dataPath + "/../../../NLDMisc/proto/";
[MenuItem("Tools/*配置工具/生成数据库代码", false, (int)NLDMenuID.DBCodeExport)]
public static void DBCodeExport()
[MenuItem("Tools/*配置工具/错误码比对", false, (int)NLDMenuID.ErrorCodeCompare)]
public static void ErrorCodeCompare()
{
ExportRedisCode();
ExportMongoCode();
var text = File.ReadAllText(Application.dataPath + "/Config/Data/errorcfg_errorlogcfg.json");
var json = SimpleJSON.JSON.Parse(text);
var ecfg = new ErrorLogCfg(json);
var protoText = File.ReadAllLines(PROTO_DIR + "common.proto");
var outString = "";
bool Check = false;
for(int i = 0; i < protoText.Length; i ++) {
if(!Check) {
if(protoText[i].Contains("enum OpResult {")) {
Check = true;
}
} else {
if(protoText[i].Contains("}")) {
break;
}
var txt = protoText[i].Replace(" ", "");
if(txt.Contains("=") && txt.Contains(";")) {
int start = txt.IndexOf("=");
int end = txt.IndexOf(";");
var code = txt.Substring(start+1, end-start-1);
var nCode = Convert.ToInt32(code);
bool Skip = false;
for(int J = 0; J < ecfg.DataList.Count; J ++) {
var d = ecfg.DataList[J];
if(d.ErrorID == nCode) {
Skip = true;
break;
}
}
if(Skip) {
continue;
}
outString += code;
int start2 = txt.IndexOf("//");
if(start2 != -1) {
var desc = txt.Substring(start2+2);
outString += "\t\t" + desc;
}
outString += "\n";
}
}
}
Debug.Log(outString);
}
private static void ExportRedisCode()

View File

@ -17,7 +17,7 @@ public enum NLDMenuID
PBExportGO, // /Tools/proto/导出pb到go
// 配置工具 - 150序列
DBCodeExport = 150, // /Tools/生成数据库代码
ErrorCodeCompare = 150, // /Tools/错误码比对
ConfigExport = 151, // /Tools/配置工具
TableValidation = 152, // /Tools/资源检查/配置表资源检查