Skip to content

Commit 7f8bcd0

Browse files
committed
添加点数修正的配置项
1 parent 40dfecd commit 7f8bcd0

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ auto_reg: true
120120
# - 1.1.1.1
121121
# - 127.0.0.1
122122
#
123+
#点数修正, 在查询点数时,显示的值多1点或者少1点时才需要配置此值, 正常情况设置为0
124+
#如果显示的点数少1点则配置为1(这是临时方案,一般是lua脚本有问题,lua脚本不应该把返回的数值减一,建议修改客户端查询点数的脚本)
125+
#如果显示的点数多一点则配置为-1(一般不可能发生)
126+
point_fix: 0
123127
#登录的玩家总数量限制,如果为0则表示无上限
124128
max_client_count: 500
125129
#
@@ -141,6 +145,7 @@ pc_max_client_count: 3
141145
"allow_old_password": false,
142146
"auto_reg": true,
143147
"allow_ips": [],
148+
"point_fix": 0,
144149
"max_client_count": 500,
145150
"pc_max_client_count": 3
146151
}
@@ -157,10 +162,6 @@ pc_max_client_count: 3
157162

158163
```ini
159164
#........
160-
[World]
161-
IP=127.0.0.1
162-
Port=777
163-
164165
[Billing]
165166
Number=1
166167
#billing服务器的ip

bhandler/query_point_handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
// QueryPointHandler 查询点数
1212
type QueryPointHandler struct {
1313
Resource *common.HandlerResource
14+
PointFix int //用于点数修正
1415
}
1516

1617
// GetType 可以处理的消息类型
@@ -58,7 +59,7 @@ func (h *QueryPointHandler) GetResponse(request *common.BillingPacket) *common.B
5859
opData := make([]byte, 0, usernameLength+5)
5960
opData = append(opData, usernameLength)
6061
opData = append(opData, username...)
61-
accountPoint *= 1000
62+
accountPoint = (accountPoint + h.PointFix) * 1000
6263
for i := 0; i < 4; i++ {
6364
tmpValue := accountPoint
6465
movePos := (3 - i) * 8

common/server_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type ServerConfig struct {
1212
AllowOldPassword bool `json:"allow_old_password" yaml:"allow_old_password"` //是否启用oldPassword(除非报这个错误,否则不建议开启)
1313
AutoReg bool `json:"auto_reg" yaml:"auto_reg"` //是否开启自动注册
1414
AllowIps []string `json:"allow_ips" yaml:"allow_ips"` //允许连接billing的服务端IP,为空则表示不限制
15+
PointFix int `json:"point_fix" yaml:"point_fix"` //用于查询点数时少1或者多1点的修正(修正值一般为0或者1)
1516
MaxClientCount int `json:"max_client_count" yaml:"max_client_count"` //最多允许进入的用户数量(0表示无限制)
1617
PcMaxClientCount int `json:"pc_max_client_count" yaml:"pc_max_client_count"` //每台电脑最多允许进入的用户数量(0表示无限制)
1718
}

config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ auto_reg: true
1010
#allow_ips:
1111
# - 127.0.0.1
1212
# - 192.168.10.3
13+
point_fix: 0
1314
max_client_count: 500
1415
pc_max_client_count: 3

services/billing/load_handlers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func (s *Server) addHandler(handlers ...common.PacketHandler) {
1313
}
1414
}
1515

16-
//loadHandlers 载入handlers
16+
// loadHandlers 载入handlers
1717
func (s *Server) loadHandlers(cancel context.CancelFunc) {
1818
resource := &common.HandlerResource{
1919
Db: s.database,
@@ -56,6 +56,7 @@ func (s *Server) loadHandlers(cancel context.CancelFunc) {
5656
},
5757
&bhandler.QueryPointHandler{
5858
Resource: resource,
59+
PointFix: s.config.PointFix,
5960
},
6061
&bhandler.RegisterHandler{
6162
Resource: resource,

0 commit comments

Comments
 (0)