feat(build): 更新构建脚本添加资源打包和proto编译

更新build.bat脚本,添加proto文件编译和资源打包功能,调整资源打包顺序。

BREAKING CHANGE: 构建流程发生变化,需要重新生成proto文件和打包资源。

---

refactor(xmlres): 使用gres替换gfile读取资源文件

将xmlres模块中文件读取方式从gfile.GetBytes改为gres.GetContent,
使
This commit is contained in:
2026-01-01 19:57:39 +08:00
parent d88a2d19ea
commit dd28d48ca4
23 changed files with 270 additions and 138 deletions

View File

@@ -1,5 +1,9 @@
gf pack modules/base/resource modules/base/packed/packed.go -p modules/base/resource
protoc --go_out=./ --go-grpc_out=./ manifest\proto\rpc.proto
gox -os "linux" -arch amd64 -output "logic"
gox -os "linux" -arch amd64 -output "logic"
gf pack modules/base/resource modules/base/packed/packed.go -p modules/base/resource
gf pack manifest,public/config common/data/xmlres/packed/packed.go

View File

@@ -3,6 +3,7 @@ package xmlres
import (
"blazing/common/utils"
_ "blazing/common/data/xmlres/packed"
"encoding/json"
"os"
@@ -11,6 +12,7 @@ import (
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gfsnotify"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/os/gres"
"github.com/gogf/gf/v2/util/gconv"
)
@@ -20,7 +22,8 @@ func getXml[T any](path string) T {
// 解析XML到结构体
var xmls T
t1 := gfile.GetBytes(path)
t1 := gres.GetContent(path)
xml.Unmarshal(t1, &xmls)
return xmls
@@ -29,7 +32,7 @@ func getJson[T any](path string) T {
// 解析XML到结构体
var xmls T
t1 := gfile.GetBytes(path)
t1 := gres.GetContent(path)
json.Unmarshal(t1, &xmls)
return xmls
@@ -58,8 +61,10 @@ var (
)
func Initfile() {
//gres.Dump()
path1, _ := os.Getwd()
path = path1 + "/public/config/"
path = "config/"
MapConfig = getXml[Maps](path + "210.xml")
EffectArgs = make(map[int]int)

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
E:/newcode/sun/public

View File

@@ -1,10 +1,10 @@
module blazing/common
go 1.20
go 1.23.0
require github.com/panjf2000/gnet v1.6.7
require github.com/gogf/gf/v2 v2.8.0
require github.com/gogf/gf/v2 v2.9.7
require github.com/antchfx/xmlquery v1.4.4
@@ -14,22 +14,22 @@ require (
github.com/butoften/array v1.0.9 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/stretchr/testify v1.11.1 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.uber.org/ratelimit v0.3.1 // indirect
)
require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/ECUST-XX/xml v1.20.2
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/magiconair/properties v1.8.10 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/panjf2000/ants/v2 v2.11.3 // indirect
@@ -37,12 +37,12 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect
github.com/tnnmigga/enum v1.0.2
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.25.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
)

View File

@@ -1,6 +1,7 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/ECUST-XX/xml v1.20.2 h1:xqg5JaYfcGtkXtLcAN0H1sbTWwRdIHjmU/ZRPmtj+8k=
github.com/ECUST-XX/xml v1.20.2/go.mod h1:AHwv/5bl6dD2mohWd7efbLVKEF+SllOsrynpQVhWM0o=
github.com/antchfx/xmlquery v1.4.4 h1:mxMEkdYP3pjKSftxss4nUHfjBhnMk4imGoR96FRY2dg=
@@ -20,18 +21,23 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/gogf/gf/v2 v2.9.7 h1:Vp3VGZ7drPs89tZslT6j6BKBTaw7Xs3DMGWx4MlVtMA=
github.com/gogf/gf/v2 v2.9.7/go.mod h1:Svl1N+E8G/QshU2DUbh/3J/AJauqCgUnxHurXWR4Qx0=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -39,13 +45,17 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v1.1.0 h1:N0LHrshF4T39KvI96fn6GT8HEjXRXYNDrDjKFDB7RIY=
github.com/panjf2000/ants/v2 v2.4.7/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A=
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
@@ -72,12 +82,20 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
@@ -118,6 +136,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -128,6 +148,8 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -147,6 +169,8 @@ golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -167,6 +191,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

View File

@@ -2,13 +2,11 @@ package rpc
import (
"blazing/cool"
"blazing/modules/base/service"
"blazing/modules/config/model"
"context"
"github.com/butoften/array"
"github.com/samber/lo"
)
func GetServerInfoList() []ServerInfo {
@@ -18,17 +16,17 @@ func GetServerInfoList() []ServerInfo {
cool.DBM(dictInfoModel1).Scan(&ret)
//fmt.Println(t)
var ret1 []ServerInfo
ip, _ := service.NewBaseSysParamService().DataByKey(context.Background(), "server_ip")
testip, _ := service.NewBaseSysParamService().DataByKey(context.Background(), "test_ip")
// ip, _ := service.NewBaseSysParamService().DataByKey(context.Background(), "server_ip")
// testip, _ := service.NewBaseSysParamService().DataByKey(context.Background(), "test_ip")
for _, v := range ret {
tt := newServerInfo()
tt.OnlineID = uint32(v.OnlineID)
tt.IP = ip
if tt.OnlineID == 2 {
tt.IP = v.IP
if v.IsVip != 0 {
tt.UserCnt = 300
tt.IP = testip
}
tt.Port = v.Port
@@ -50,9 +48,9 @@ func GetServerInfoList() []ServerInfo {
array.Sort(&ret1, func(a ServerInfo, b ServerInfo) bool {
return a.OnlineID < b.OnlineID
})
ret1 = lo.UniqBy(ret1, func(s ServerInfo) int {
return int(s.Port)
})
// ret1 = lo.UniqBy(ret1, func(s ServerInfo) int {
// return int(s.Port)
// })
//fmt.Printf("升序 Sort: %v\n", ret1)
return ret1

View File

@@ -50,8 +50,8 @@ func (h *ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) erro
if !ok {
return fmt.Errorf("no reverse client")
}
t, _ := blservice.NewLoginServiceService().GetServerID(id)
aa, ok := cool.GetClient(t)
t := blservice.NewLoginServiceService().GetServerID(id)
aa, ok := cool.GetClient(t.Port)
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(0)
}

View File

@@ -8,7 +8,6 @@ import (
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/logic/service/task"
"blazing/logic/service/player"
"blazing/modules/blazing/model"
@@ -138,33 +137,7 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *pla
fight.NewFight(p, ai, func(foi *info.FightOverInfo) {
if taskID != 0 {
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
if p.Info.GetTask(taskID) == model.Unaccepted {
p.Info.SetTask(taskID, model.Completed) //设置完成任务
gift := task.GetTaskInfo(uint32(taskID), 0)
if gift != nil {
res := &info.S2C_GET_BOSS_MONSTER{
BonusID: uint32(taskID),
}
if gift.Pet != nil {
p.Service.Pet.PetAdd(gift.Pet)
res.PetID = gift.Pet.ID
res.CaptureTm = gift.Pet.CatchTime
}
for _, item := range gift.ItemList {
success := p.ItemAdd(item.ItemId, item.ItemCnt)
if success {
res.ItemList = append(res.ItemList, item)
}
}
p.SendPackCmd(8004, res)
}
}
p.CompletedTask(taskID, 0)
}
}

View File

@@ -13,6 +13,7 @@ import (
configservice "blazing/modules/config/service"
"sync/atomic"
"github.com/gogf/gf/v2/util/gconv"
"github.com/jinzhu/copier"
)
@@ -38,6 +39,7 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
c.Info.CurrentFreshStage = uint32((data.Level-1)*10) + 1
case 2414: //勇者之塔
c.Info.CurrentStage = uint32((data.Level-1)*10) + 1
}
}
@@ -51,7 +53,7 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
case 2414: //勇者之塔
result.CurFightLevel = uint(c.Info.CurrentStage)
boss = service.NewTower500Service().Boss(c.Info.CurrentFreshStage)
boss = service.NewTower500Service().Boss(c.Info.CurrentStage)
//next := service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
}
@@ -95,13 +97,6 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
case 2429: //试炼之塔
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
next = service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
if next != nil {
for _, v := range next.BossIds {
r := configservice.NewBossService().Get(v)
result.BossID = append(result.BossID, uint32(r.MonID))
}
}
result.CurFightLevel = uint32(c.Info.CurrentFreshStage)
case 2415: //勇者之塔
@@ -111,7 +106,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
result.CurFightLevel = uint32(c.Info.CurrentStage)
}
if next == nil {
if next != nil {
for _, v := range next.BossIds {
r := configservice.NewBossService().Get(v)
result.BossID = append(result.BossID, uint32(r.MonID))
@@ -122,15 +117,17 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
r := configservice.NewBossService().Get(v)
if r != nil {
monster := model.GenPetInfo(int(r.MonID), int(r.Lv), int(r.Nature), 0, int(r.Lv), nil)
monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil)
if r.Hp != 0 {
monster.Hp = uint32(r.Hp)
monster.MaxHp = uint32(r.Hp)
}
if len(r.Prop) != 0 {
copy(monster.Prop[:], r.Prop)
for i, v := range r.Prop {
if v != 0 {
monster.Prop[i] = v
}
}
@@ -144,6 +141,20 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
}
//todo 特性填装
if len(r.Effect) != 0 {
for _, v := range r.Effect {
EID, args := service.NewEffectService().Args(v)
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
Idx: uint16(v),
EID: gconv.Uint16(EID),
Args: gconv.Ints(args),
})
}
}
monster.CatchTime = uint32(i)
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
}
@@ -155,11 +166,22 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID { //我放获胜
switch data.Head.CMD {
case 2429: //试炼之塔
for _, v := range boss.TaskIds {
c.CompletedTask(int(v), 500)
}
c.Info.CurrentFreshStage++
if c.Info.CurrentFreshStage >= c.Info.MaxFreshStage {
c.Info.MaxFreshStage = c.Info.CurrentFreshStage
}
case 2415: //勇者之塔
for _, v := range boss.TaskIds {
c.CompletedTask(int(v), 600)
}
c.Info.CurrentStage++
if c.Info.CurrentStage >= c.Info.MaxStage {
c.Info.MaxStage = c.Info.CurrentStage
}
}
}

View File

@@ -3,6 +3,7 @@ package controller
import (
"blazing/common/data"
"blazing/common/socket/errorcode"
"fmt"
"blazing/logic/service/player"
"blazing/logic/service/task"
@@ -15,7 +16,9 @@ func (h Controller) AcceptTask(data *task.AcceptTaskInboundInfo, c *player.Playe
// if data.Head.CMD != 2201 { //判断是每日任务
// //isdaliy = true
// }
if c.Info.GetTask(int(data.TaskId)) == model.Completed {
return result, 0
}
if c.Info.GetTask(int(data.TaskId)) == model.Unaccepted {
c.Info.SetTask(int(data.TaskId), model.Accepted)
@@ -49,9 +52,12 @@ func (h Controller) AddTaskBuf(data *task.AddTaskBufInboundInfo, c *player.Playe
// 返回: 任务完成结果和错误码
func (h Controller) CompleteTask(data1 *task.CompleteTaskInboundInfo, c *player.Player) (result *task.CompleteTaskOutboundInfo, err errorcode.ErrorCode) {
if c.Info.GetTask(int(data1.TaskId)) != model.Accepted {
return result, errorcode.ErrorCodes.ErrAwardAlreadyClaimed
}
if data1.OutState > 10 {
fmt.Println("error", data1.OutState, c.Info.UserID, "分支溢出")
return result, 0
}
c.Info.SetTask(int(data1.TaskId), model.Completed)
result = &task.CompleteTaskOutboundInfo{
@@ -68,6 +74,7 @@ func (h Controller) CompleteTask(data1 *task.CompleteTaskInboundInfo, c *player.
c.Service.Pet.PetAdd(taskInfo.Pet)
result.CaptureTime = taskInfo.Pet.CatchTime
result.PetTypeId = taskInfo.Pet.ID
}
for _, item := range taskInfo.ItemList {

View File

@@ -52,10 +52,10 @@ func main() {
// }
// 解析命令行参数
cool.Config.PortBL = gcmd.GetOpt("port", "1").Uint16()
go Start(cool.Config.PortBL) //注入service
if cool.Config.PortBL == 1 || cool.Config.PortBL == 2 { //只分析1服务器的
go PprofWeb()
}
go Start(cool.Config.PortBL) //注入service
// if cool.Config.PortBL == 1 || cool.Config.PortBL == 2 { //只分析1服务器的
// go PprofWeb()
// }
fmt.Println("Process start, pid:", os.Getpid())
@@ -85,4 +85,4 @@ func loadAccounts() {
blservice.NewUserService(uint32(t.ID)).Info.Reg(t.Username, 0)
}
//fmt.Printf("加载 %d 个账号\n", len(accounts))
}
}

View File

@@ -5,7 +5,6 @@ import (
"blazing/common/rpc"
"blazing/common/socket"
"blazing/cool"
"blazing/logic/controller"
blservice "blazing/modules/blazing/service"
@@ -23,14 +22,12 @@ const (
maxPortRetryCount = 5
)
var candidatePorts = cool.Config.GamePort
// determinePort 确定服务器使用的端口
func determinePort() (int, error) {
func determinePort(ports []uint32) (int, error) {
// 尝试从指定端口列表中找可用端口最多尝试maxPortRetryCount轮
for i := 0; i < maxPortRetryCount; i++ {
// 遍历指定的端口列表
for _, port := range candidatePorts {
for _, port := range ports {
if isPortAvailable(port) {
return int(port), nil
}
@@ -43,7 +40,7 @@ func determinePort() (int, error) {
}
// isPortAvailable 检查端口是否可用
func isPortAvailable(port uint64) bool {
func isPortAvailable(port uint32) bool {
address := fmt.Sprintf(":%d", port)
listener, err := net.Listen("tcp", address)
if err != nil {
@@ -57,7 +54,8 @@ func isPortAvailable(port uint64) bool {
// 如果id是0,那就是login server
func Start(serverID uint16) {
// 确定端口
port, err := determinePort()
r := blservice.NewLoginServiceService().GetServerID(serverID)
port, err := determinePort(r.CanPort)
if err != nil {
log.Fatalf("Failed to determine port: %v", err)
}
@@ -68,10 +66,10 @@ func Start(serverID uint16) {
// go func() {
rpcClient := rpc.StartClient(serverID, uint16(port), server)
controller.Maincontroller.RPCClient = *rpcClient //将RPC赋值Start
controller.Maincontroller.Port = uint16(port) //赋值服务器ID
controller.Maincontroller.RPCClient = *rpcClient //将RPC赋值Start
controller.Maincontroller.Port = uint16(port) //赋值服务器ID
controller.Init(true)
xmlres.Initfile()
blservice.NewLoginServiceService().SetServerID(serverID, gconv.Uint16(port))
server.Boot()
}
}

View File

@@ -0,0 +1,38 @@
package player
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/task"
"blazing/modules/blazing/model"
)
func (p *Player) CompletedTask(taskID int, ot uint32) {
if p.Info.GetTask(taskID) == model.Unaccepted {
p.Info.SetTask(taskID, model.Completed) //设置完成任务
gift := task.GetTaskInfo(uint32(taskID), 0)
if gift != nil {
res := &info.S2C_GET_BOSS_MONSTER{
BonusID: uint32(taskID),
}
if gift.Pet != nil {
p.Service.Pet.PetAdd(gift.Pet)
res.PetID = gift.Pet.ID
res.CaptureTm = gift.Pet.CatchTime
}
for _, item := range gift.ItemList {
success := p.ItemAdd(item.ItemId, item.ItemCnt)
if success {
res.ItemList = append(res.ItemList, item)
}
}
p.SendPackCmd(8004, res)
}
}
}

View File

@@ -80,6 +80,7 @@ func (lw *Player) CompleteLogin() {
lw.Info.SetTask(4, model.Completed) //设置新手任务默认完成
lw.Info.MapID = 8
if len(lw.Info.PetList) == 0 {
//这个是添加后防止卡死
rr := lw.Service.Pet.PetInfo(0)
if len(rr) > 0 {
lw.Info.PetList = append(lw.Info.PetList, rr[0].Data)

View File

@@ -3,7 +3,6 @@ server:
address: ":8080" #前台服务器地址
port: 53388 #后台服务器端口
rpc: 56409 #rpc服务端口
game: [27000, 27778]
openapiPath: "/api.json"
swaggerPath: "/swagger"
clientMaxBodySize:

View File

@@ -153,28 +153,28 @@ type PlayerInfo struct {
GraduationCount uint32 `struc:"uint32" default:"0" json:"graduation_count"` // 毕业人数
}
MaxPuniLv uint32 `struc:"uint32" default:"0" json:"max_puni_lv"` // 默认0, 虚无 元素 能量 生命 轮回 永恒 圣洁 最高为8
PetMaxLevel uint32 `struc:"uint32" json:"pet_max_level"` // 精灵最高等级
AllPetNumber uint32 `struc:"uint32" json:"all_pet_number"` // 精灵数量
MonKingWin uint32 `struc:"uint32" json:"mon_king_win"` // 精灵王胜场
MessWin uint32 `struc:"skip" json:"mess_win"` // 大乱斗胜场
CurrentStage uint32 `struc:"uint32" default:"1" json:"current_stage"` // 勇者之塔层数
MaxStage uint32 `struc:"uint32" json:"max_stage"` // 试炼之塔最高层
CurrentFreshStage uint32 `struc:"uint32" json:"current_fresh_stage"` // 当前试炼层数
MaxFreshStage uint32 `struc:"uint32" json:"max_fresh_stage"` // 最高试炼层
MaxArenaWins uint32 `struc:"uint32" json:"max_arena_wins"` // 星际擂台连胜
TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 双倍经验加速器剩余使用次数
ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 三倍经验加速器剩余使用次数
AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 是否自动战斗
AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 自动战斗剩余的场次
EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 能量吸收仪剩余次数
LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 学习力吸收仪剩余次数
MonBattleMedal uint32 `struc:"uint32" default:"0" json:"mon_battle_medal"` // 默认0
RecordCount uint32 `struc:"uint32" default:"0" json:"record_count"` // 默认0
ObtainTm uint32 `struc:"uint32" default:"0" json:"obtain_tm"` // 默认0
SoulBeadItemID uint32 `struc:"uint32" json:"soul_bead_item_id"` // 当前元神珠id
ExpireTm uint32 `struc:"uint32" default:"0" json:"expire_tm"` // 默认0
FuseTimes uint32 `struc:"uint32" default:"0" json:"fuse_times"` // 默认0
MaxPuniLv uint32 `struc:"uint32" default:"0" json:"max_puni_lv"` // 默认0, 虚无 元素 能量 生命 轮回 永恒 圣洁 最高为8
PetMaxLevel uint32 `struc:"uint32" json:"pet_max_level"` // 精灵最高等级
AllPetNumber uint32 `struc:"uint32" json:"all_pet_number"` // 精灵数量
MonKingWin uint32 `struc:"uint32" json:"mon_king_win"` // 精灵王胜场
MessWin uint32 `struc:"skip" json:"mess_win"` // 大乱斗胜场
CurrentStage uint32 `struc:"uint32" default:"1" json:"current_stage"` // 勇者之塔层数
MaxStage uint32 `struc:"uint32" json:"max_stage"` // 试炼之塔最高层
CurrentFreshStage uint32 `struc:"uint32" default:"1" json:"current_fresh_stage"` // 当前试炼层数
MaxFreshStage uint32 `struc:"uint32" json:"max_fresh_stage"` // 最高试炼层
MaxArenaWins uint32 `struc:"uint32" json:"max_arena_wins"` // 星际擂台连胜
TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 双倍经验加速器剩余使用次数
ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 三倍经验加速器剩余使用次数
AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 是否自动战斗
AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 自动战斗剩余的场次
EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 能量吸收仪剩余次数
LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 学习力吸收仪剩余次数
MonBattleMedal uint32 `struc:"uint32" default:"0" json:"mon_battle_medal"` // 默认0
RecordCount uint32 `struc:"uint32" default:"0" json:"record_count"` // 默认0
ObtainTm uint32 `struc:"uint32" default:"0" json:"obtain_tm"` // 默认0
SoulBeadItemID uint32 `struc:"uint32" json:"soul_bead_item_id"` // 当前元神珠id
ExpireTm uint32 `struc:"uint32" default:"0" json:"expire_tm"` // 默认0
FuseTimes uint32 `struc:"uint32" default:"0" json:"fuse_times"` // 默认0
NONO struct {
//fieldDescription:"1为跟随 0为收回 且如果为收回 那么后续结构不需要发送, 不序列化"

View File

@@ -83,25 +83,13 @@ func (s *LoginService) SetServerID(OnlineID uint16, Port uint16) error {
return nil
}
func (s *LoginService) GetServerID(OnlineID uint16) (uint16, error) {
var tttt model.ServerList
func (s *LoginService) GetServerID(OnlineID uint16) *model.ServerList {
var tttt *model.ServerList
err := cool.DBM(s.Model).Where("online_id", OnlineID).Scan(&tttt)
if err != nil {
return 0, err
return nil
}
// record, err := m.One()
// if err != nil {
// return 0, err
// }
// if record == nil {
// //说明是新的服务器
// return 0, fmt.Errorf("未找到服务器")
// }
// var tttt model.ServerList
// record.Struct(&tttt)
return tttt.Port, nil
return tttt
}

View File

@@ -0,0 +1,22 @@
package admin
import (
"blazing/cool"
"blazing/modules/config/service"
)
type ServerController struct {
*cool.Controller
}
func init() {
// 注册路由
cool.RegisterController(&ServerController{
&cool.Controller{
Prefix: "/admin/config/server",
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
Service: service.NewServerService(),
},
})
}

View File

@@ -25,7 +25,7 @@ type PetBaseConfig struct {
// ===================== 战斗核心属性BossMon节点 =====================
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
Nature int32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"`
Lv int32 `gorm:"not null;comment:'BOSS等级LvHpMatchUser非0时此配置无效'" json:"lv"`
Color string `gorm:"comment:'BOSS颜色'" json:"color"`

View File

@@ -10,10 +10,17 @@ const TableNameServerList = "server_list"
// ServerList mapped from table <server_list>
type ServerList struct {
*cool.Model
OnlineID uint16 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"`
//IP string `gorm:"type:varchar(16);comment:'服务器IP'" json:"ip"`
Port uint16 `gorm:"comment:'端口号,通常是小整数'" json:"port"`
//IsOpen bool `gorm:"default:true;not null;comment:'服务器是否开启,默认为开启状态'" json:"is_open"`
OnlineID uint16 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"`
IP string `gorm:"type:string;comment:'服务器IP'" json:"ip"`
Port uint16 `gorm:"comment:'端口号,通常是小整数'" json:"port"`
IsOpen bool `gorm:"default:true;not null;comment:'服务器是否开启,默认为开启状态'" json:"is_open"`
CanPort []uint32 `gorm:"type:jsonb;comment:'可连接端口'" json:"can_port"`
IsVip uint32 `gorm:"default:0;not null;comment:'是否为VIP服务器'" json:"is_vip"`
//服务器异色概率设定ServerList
ShinyRate uint8 `gorm:"default:0;comment:'异色概率'" json:"shiny_rate"`
//服务器天气设定ServerList
WeatherRate uint8 `gorm:"default:0;comment:'天气概率'" json:"weather_rate"`
Desc string `gorm:"comment:'服务器描述'" json:"desc"`
}
// TableName ServerList's table name

View File

@@ -0,0 +1,18 @@
package service
import (
"blazing/cool"
"blazing/modules/config/model"
)
type ServerService struct {
*cool.Service
}
func NewServerService() *ServerService {
return &ServerService{
&cool.Service{
Model: model.NewServerList(),
},
}
}

View File

@@ -15,20 +15,38 @@ func NewTaskService() *TaskService {
return &TaskService{
&cool.Service{
Model: model.NewTaskConfig(),
PageQueryOp: &cool.QueryOp{
FieldEQ: []string{"task_type"},
},
//UniqueKey: map[string]string{"task_id": "索引不能重复"},
},
}
}
func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
var item *model.TaskConfig
cool.DBM(s.Model).Where("task_id", id).Where("out_state", os).
var item []model.TaskConfig
cool.DBM(s.Model).Where("task_id", id).
Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
}).Scan(&item)
var res *model.TaskConfig
if len(item) == 1 { //只有一个直接默认
res = &item[0]
}
if len(item) > 1 { //
return item
for _, v := range item {
if v.OutState == os {
res = &item[os]
return res
}
}
}
return res
}
func (s *TaskService) GetDaily() []model.TaskConfig {