build: 更新 go.mod 并添加新依赖
- 在 go.mod 中添加了 github.com/ECUST-XX/xml v1.20.2 依赖 - 更新了 go.sum 文件以包含新依赖的哈希值 - 在 ServerEvent.go
This commit is contained in:
20
common/data/xml/monster_refresh.go
Normal file
20
common/data/xml/monster_refresh.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/ECUST-XX/xml"
|
||||
)
|
||||
|
||||
type SuperMaps struct {
|
||||
XMLName xml.Name `xml:"superMaps"`
|
||||
Text string `xml:",chardata"`
|
||||
Maps []Maps `xml:"maps"`
|
||||
}
|
||||
|
||||
type Maps struct {
|
||||
Text string `xml:",chardata"`
|
||||
ID string `xml:"id,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
X string `xml:"x,attr"`
|
||||
Y string `xml:"y,attr"`
|
||||
// Galaxy string `xml:"galaxy,attr"`
|
||||
}
|
||||
126
common/data/xml/monster_refresh_test.go
Normal file
126
common/data/xml/monster_refresh_test.go
Normal file
@@ -0,0 +1,126 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ECUST-XX/xml"
|
||||
"github.com/antchfx/xmlquery"
|
||||
)
|
||||
|
||||
var s = `
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
多个地图ID归属于一个星球
|
||||
此XML表主要配置一些各个星球有可能需要用到的共用信息, 比如目前在世界地图上显示玩家所在位置
|
||||
-->
|
||||
<superMaps>
|
||||
<maps id="1" name="传送舱" x="" y=""/>
|
||||
<maps id="4" name="船长室" x="" y=""/>
|
||||
<maps id="5" name="实验室" x="" y=""/>
|
||||
<maps id="6" name="动力室" x="" y=""/>
|
||||
<maps id="7" name="瞭望舱" x="" y=""/>
|
||||
<maps id="8" name="机械室" x="" y=""/>
|
||||
<maps id="9" name="资料室" x="" y=""/>
|
||||
<maps id="19" name="太空站" x="" y=""/>
|
||||
<maps id="101" name="教官办公室" x="" y=""/>
|
||||
<maps id="103" name="瞭望露台" x="" y=""/>
|
||||
<maps id="107" name="发明室" x="" y=""/>
|
||||
<!--星球-->
|
||||
<maps id="10 11 12 13" name="克洛斯星" galaxy="1" x="358" y="46"/>
|
||||
<maps id="15 16 17" name="火山星" galaxy="1" x="533" y="46"/>
|
||||
<maps id="20 21 22" name="海洋星" galaxy="1" x="190" y="11"/>
|
||||
<maps id="25 26 27" name="云霄星" galaxy="1" x="652" y="24"/>
|
||||
<maps id="30 31 32 33 34 35 36" name="赫尔卡星" galaxy="1" x="45" y="34"/>
|
||||
<maps id="40 41 42 43" name="塞西利亚星" galaxy="1" x="1012" y="30"/>
|
||||
<maps id="17" name="双子阿尔法星" galaxy="1" x="822" y="96"/>
|
||||
<maps id="47 49" name="双子贝塔星" galaxy="1" x="883" y="63"/>
|
||||
<maps id="51 52 53" name="斯诺星" galaxy="1" x="1290" y="15"/>
|
||||
<maps id="54 55 56" name="露西欧星" galaxy="1" x="1405" y="120"/>
|
||||
<maps id="57 58 59" name="尼古尔星" galaxy="2" x="30" y="50"/>
|
||||
<maps id="60 61 62 63 64" name="塔克星" galaxy="2" x="135" y="44"/>
|
||||
<maps id="325 326 327" name="艾迪星" galaxy="2" x="250" y="30"/>
|
||||
<maps id="328" name="斯科尔星" galaxy="2" x="375" y="40"/>
|
||||
<maps id="333 334" name="普雷空间站" galaxy="2" x="500" y="50"/>
|
||||
<maps id="338 339" name="哈默星" galaxy="2" x="590" y="70"/>
|
||||
<maps id="314" name="拜伦号" galaxy="1" x="1160" y="55"/>
|
||||
</superMaps>`
|
||||
|
||||
func Test_main(t *testing.T) {
|
||||
tt := &SuperMaps{}
|
||||
xml.Unmarshal([]byte(s), tt)
|
||||
|
||||
// tt.Maps = append(tt.Maps, Maps{
|
||||
// ID: "1",
|
||||
// Name: "传送舱",
|
||||
// // Galaxy: "1",
|
||||
// X: "358",
|
||||
// Y: "46",
|
||||
// })
|
||||
// tt.Maps = append(tt.Maps, Maps{
|
||||
// ID: "4",
|
||||
// Name: "船长室",
|
||||
// // Galaxy: "1",
|
||||
// X: "358",
|
||||
// Y: "46",
|
||||
// })
|
||||
tf, _ := xml.MarshalIndentShortForm(tt, " ", " ")
|
||||
fmt.Println(string(tf))
|
||||
}
|
||||
|
||||
func main1() {
|
||||
s := `
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
多个地图ID归属于一个星球
|
||||
此XML表主要配置一些各个星球有可能需要用到的共用信息, 比如目前在世界地图上显示玩家所在位置
|
||||
-->
|
||||
<superMaps>
|
||||
<maps id="1" name="传送舱" x="" y=""/>
|
||||
<maps id="4" name="船长室" x="" y=""/>
|
||||
<maps id="5" name="实验室" x="" y=""/>
|
||||
<maps id="6" name="动力室" x="" y=""/>
|
||||
<maps id="7" name="瞭望舱" x="" y=""/>
|
||||
<maps id="8" name="机械室" x="" y=""/>
|
||||
<maps id="9" name="资料室" x="" y=""/>
|
||||
<maps id="19" name="太空站" x="" y=""/>
|
||||
<maps id="101" name="教官办公室" x="" y=""/>
|
||||
<maps id="103" name="瞭望露台" x="" y=""/>
|
||||
<maps id="107" name="发明室" x="" y=""/>
|
||||
<!--星球-->
|
||||
<maps id="10 11 12 13" name="克洛斯星" galaxy="1" x="358" y="46"/>
|
||||
<maps id="15 16 17" name="火山星" galaxy="1" x="533" y="46"/>
|
||||
<maps id="20 21 22" name="海洋星" galaxy="1" x="190" y="11"/>
|
||||
<maps id="25 26 27" name="云霄星" galaxy="1" x="652" y="24"/>
|
||||
<maps id="30 31 32 33 34 35 36" name="赫尔卡星" galaxy="1" x="45" y="34"/>
|
||||
<maps id="40 41 42 43" name="塞西利亚星" galaxy="1" x="1012" y="30"/>
|
||||
<maps id="17" name="双子阿尔法星" galaxy="1" x="822" y="96"/>
|
||||
<maps id="47 49" name="双子贝塔星" galaxy="1" x="883" y="63"/>
|
||||
<maps id="51 52 53" name="斯诺星" galaxy="1" x="1290" y="15"/>
|
||||
<maps id="54 55 56" name="露西欧星" galaxy="1" x="1405" y="120"/>
|
||||
<maps id="57 58 59" name="尼古尔星" galaxy="2" x="30" y="50"/>
|
||||
<maps id="60 61 62 63 64" name="塔克星" galaxy="2" x="135" y="44"/>
|
||||
<maps id="325 326 327" name="艾迪星" galaxy="2" x="250" y="30"/>
|
||||
<maps id="328" name="斯科尔星" galaxy="2" x="375" y="40"/>
|
||||
<maps id="333 334" name="普雷空间站" galaxy="2" x="500" y="50"/>
|
||||
<maps id="338 339" name="哈默星" galaxy="2" x="590" y="70"/>
|
||||
<maps id="314" name="拜伦号" galaxy="1" x="1160" y="55"/>
|
||||
</superMaps>`
|
||||
|
||||
doc, err := xmlquery.Parse(strings.NewReader(s))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//channel := xmlquery.FindOne(doc, "//superMaps")
|
||||
// if n := channel.SelectElement("maps"); n != nil {
|
||||
// fmt.Printf("title: %s\n", n.InnerText())
|
||||
// }
|
||||
if l := xmlquery.Find(doc, "//maps[@id='9']"); l != nil {
|
||||
t := l[0].Attr
|
||||
fmt.Printf("%v", t[1])
|
||||
}
|
||||
// for i, n := range xmlquery.Find(doc, "//maps/@id") {
|
||||
// fmt.Printf("#%d %s\n", i, n.InnerText())
|
||||
// }
|
||||
}
|
||||
@@ -17,6 +17,7 @@ require (
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.0 // indirect
|
||||
github.com/ECUST-XX/xml v1.20.2
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
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=
|
||||
github.com/antchfx/xmlquery v1.4.4/go.mod h1:AEPEEPYE9GnA2mj5Ur2L5Q5/2PycJ0N9Fusrx9b12fc=
|
||||
github.com/antchfx/xpath v1.3.3 h1:tmuPQa1Uye0Ym1Zn65vxPgfltWb/Lxu2jeqIGteJSRs=
|
||||
|
||||
@@ -58,7 +58,7 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
|
||||
//client := conn.RemoteAddr().String()
|
||||
_ = s.workerPool.Submit(func() {
|
||||
_ = s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复
|
||||
s.parser(conn, data)
|
||||
})
|
||||
|
||||
|
||||
@@ -129,9 +129,10 @@ func processWithReflection(c gnet.Conn, pp handler.TomeeHeader) {
|
||||
|
||||
func callhandler(cmdlister reflect.Value, data []byte, player *entity.Player, cmd cmd.EnumCommandID) {
|
||||
//TODO 待实现返回参数返回客户端???实现直接返回对象进行序列化 传递chan待返回
|
||||
//TODO 已实现,待测试
|
||||
//TODO 已实现,待测试结构体序列化
|
||||
recvchan := make(chan any, 1) //传递自定义chan
|
||||
go func() {
|
||||
|
||||
go func() { //TODO 待实现ants线程池,以及确认是否存在顺序混乱问题https://github.com/lxzan/gws/issues/3
|
||||
retv := <-recvchan
|
||||
|
||||
switch ttt := retv.(type) {
|
||||
|
||||
Reference in New Issue
Block a user