From bcfa601efca42c44ae22cb2b67418ad880c39d32 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 00:27:08 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E9=9A=8F=E6=9C=BAid=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/随机id生成 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 help/随机id生成 diff --git a/help/随机id生成 b/help/随机id生成 new file mode 100644 index 00000000..b509dd8f --- /dev/null +++ b/help/随机id生成 @@ -0,0 +1,24 @@ +-- 生成 8 位随机不重复 ID 函数 +CREATE OR REPLACE FUNCTION next_8digit_rand_id(seq_name regclass) +RETURNS integer AS $$ +DECLARE + base_val bigint; + rand8id integer; +BEGIN + base_val := nextval(seq_name); + rand8id := (10000000 + ((base_val * 1234567 # floor(random() * 99999999))::bigint % 90000000))::integer; + RETURN rand8id; +END; +$$ LANGUAGE plpgsql VOLATILE; + +-- 给 base_sys_user 绑定 8 位随机ID +ALTER TABLE base_sys_user +ALTER COLUMN id +SET DEFAULT next_8digit_rand_id('base_sys_user_id_seq'); + + + + +ALTER TABLE base_sys_user +ALTER COLUMN id +SET DEFAULT nextval('base_sys_user_id_seq'); From 9cda69c23f012be823720c38dfeb77c7d0cc0590 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 00:53:55 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=A2=9Eid.sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/修改自增id.sql | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/help/修改自增id.sql b/help/修改自增id.sql index 1890b7c0..76150767 100644 --- a/help/修改自增id.sql +++ b/help/修改自增id.sql @@ -1 +1,26 @@ -select setval('base_sys_user_id_seq', 10000000, false); \ No newline at end of file +select setval('base_sys_user_id_seq', 10000000, false); + + +-- 1. 恢复原自增,解除依赖 +ALTER TABLE base_sys_user +ALTER COLUMN id SET DEFAULT nextval('base_sys_user_id_seq'); + +-- 2. 清理旧函数 +DROP FUNCTION IF EXISTS next_8digit_rand_id() CASCADE; + +-- 3. 【终极版】不重复 + 乱序 + 固定8位 +CREATE OR REPLACE FUNCTION next_8digit_rand_id() +RETURNS bigint +LANGUAGE plpgsql VOLATILE +AS $$ +DECLARE + seq_val bigint; +BEGIN + seq_val := nextval('base_sys_user_id_seq'); + RETURN 10000000 + ((seq_val * 1103515245 + 12345) # 58329) % 90000000; +END; +$$; + +-- 4. 启用 +ALTER TABLE base_sys_user +ALTER COLUMN id SET DEFAULT next_8digit_rand_id(); From 835e816b0492244cffd91025d129367671796419 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 01:08:43 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E9=9A=8F=E6=9C=BAid=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/随机id生成 | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/help/随机id生成 b/help/随机id生成 index b509dd8f..c99d43bc 100644 --- a/help/随机id生成 +++ b/help/随机id生成 @@ -1,20 +1,37 @@ --- 生成 8 位随机不重复 ID 函数 -CREATE OR REPLACE FUNCTION next_8digit_rand_id(seq_name regclass) -RETURNS integer AS $$ -DECLARE - base_val bigint; - rand8id integer; -BEGIN - base_val := nextval(seq_name); - rand8id := (10000000 + ((base_val * 1234567 # floor(random() * 99999999))::bigint % 90000000))::integer; - RETURN rand8id; -END; -$$ LANGUAGE plpgsql VOLATILE; - --- 给 base_sys_user 绑定 8 位随机ID +-- 先恢复 ALTER TABLE base_sys_user -ALTER COLUMN id -SET DEFAULT next_8digit_rand_id('base_sys_user_id_seq'); +ALTER COLUMN id SET DEFAULT nextval('base_sys_user_id_seq'); + +DROP FUNCTION IF EXISTS next_8digit_shuffle_id() CASCADE; + +-- 8位自增 → 洗牌 → 仍然8位 → 绝对不重复 +CREATE OR REPLACE FUNCTION next_8digit_shuffle_id() +RETURNS bigint +LANGUAGE plpgsql +VOLATILE +AS $$ +DECLARE + seq bigint; + a int; + b int; +BEGIN + seq := nextval('base_sys_user_id_seq'); + + -- 把 8 位数字拆开洗牌 + a := (seq / 10000)::int; -- 前4位 + b := (seq % 10000)::int; -- 后4位 + + -- 前后互换 + 简单扰乱,保证: + -- 1. 还是8位 + -- 2. seq 不同 → 结果一定不同 + return ((b * 9871) % 10000) * 10000 + + ((a * 1237) % 10000); +END; +$$; + +-- 启用 +ALTER TABLE base_sys_user +ALTER COLUMN id SET DEFAULT next_8digit_shuffle_id(); From d545093124c759e6706c7c36a14f0cb48e799fd6 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 01:16:26 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=A2=9Eid.sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/修改自增id.sql | 53 ++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/help/修改自增id.sql b/help/修改自增id.sql index 76150767..362d8d4e 100644 --- a/help/修改自增id.sql +++ b/help/修改自增id.sql @@ -1,26 +1,49 @@ select setval('base_sys_user_id_seq', 10000000, false); --- 1. 恢复原自增,解除依赖 +-- 清理旧函数 ALTER TABLE base_sys_user ALTER COLUMN id SET DEFAULT nextval('base_sys_user_id_seq'); --- 2. 清理旧函数 -DROP FUNCTION IF EXISTS next_8digit_rand_id() CASCADE; +DROP FUNCTION IF EXISTS shuffle_8digit() CASCADE; --- 3. 【终极版】不重复 + 乱序 + 固定8位 -CREATE OR REPLACE FUNCTION next_8digit_rand_id() +-- 8位自增 → 纯数字位置互换 → 依旧8位 → 100%不重复 +CREATE OR REPLACE FUNCTION shuffle_8digit() RETURNS bigint -LANGUAGE plpgsql VOLATILE +LANGUAGE plpgsql +VOLATILE AS $$ DECLARE - seq_val bigint; -BEGIN - seq_val := nextval('base_sys_user_id_seq'); - RETURN 10000000 + ((seq_val * 1103515245 + 12345) # 58329) % 90000000; -END; -$$; + seq bigint; + d0 int; d1 int; d2 int; d3 int; + d4 int; d5 int; d6 int; d7 int; + BEGIN + seq := nextval('base_sys_user_id_seq'); -- 原本就是8位 --- 4. 启用 -ALTER TABLE base_sys_user -ALTER COLUMN id SET DEFAULT next_8digit_rand_id(); + -- 把 8 位数字拆出来:d7 d6 d5 d4 d3 d2 d1 d0 + d7 := (seq / 10000000) % 10; + d6 := (seq / 1000000) % 10; + d5 := (seq / 100000) % 10; + d4 := (seq / 10000) % 10; + d3 := (seq / 1000) % 10; + d2 := (seq / 100) % 10; + d1 := (seq / 10) % 10; + d0 := seq % 10; + + -- 固定位置互换(一对一置换,绝对不重复) + RETURN + d3*10000000 + + d7*1000000 + + d1*100000 + + d5*10000 + + d2*1000 + + d6*100 + + d0*10 + + d4; + END; + $$; + + -- 启用 + ALTER TABLE base_sys_user + ALTER COLUMN id SET DEFAULT shuffle_8digit(); + \ No newline at end of file From f434d88f292d0fc87f71e385f79bc63f16339548 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 01:26:49 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E9=9A=8F=E6=9C=BAid=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- help/随机id生成 | 58 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/help/随机id生成 b/help/随机id生成 index c99d43bc..68c88e85 100644 --- a/help/随机id生成 +++ b/help/随机id生成 @@ -1,39 +1,57 @@ --- 先恢复 +-- 清理旧的 ALTER TABLE base_sys_user ALTER COLUMN id SET DEFAULT nextval('base_sys_user_id_seq'); +DROP FUNCTION IF EXISTS shuffle_9digit() CASCADE; -DROP FUNCTION IF EXISTS next_8digit_shuffle_id() CASCADE; - --- 8位自增 → 洗牌 → 仍然8位 → 绝对不重复 -CREATE OR REPLACE FUNCTION next_8digit_shuffle_id() +-- 9位乱序:首尾互换 + 中间全部打乱 +-- 纯数字换位,100% 不重复,速度极快 +CREATE OR REPLACE FUNCTION shuffle_9digit() RETURNS bigint LANGUAGE plpgsql VOLATILE AS $$ DECLARE - seq bigint; - a int; - b int; + seq bigint; + d0 int; -- 原最后一位 + d1 int; + d2 int; + d3 int; + d4 int; + d5 int; + d6 int; + d7 int; -- 原第一位 BEGIN - seq := nextval('base_sys_user_id_seq'); + seq := nextval('base_sys_user_id_seq'); -- 8位自增 - -- 把 8 位数字拆开洗牌 - a := (seq / 10000)::int; -- 前4位 - b := (seq % 10000)::int; -- 后4位 + -- 拆分 8 位:d7 d6 d5 d4 d3 d2 d1 d0 + d7 := (seq / 10000000) % 10; + d6 := (seq / 1000000) % 10; + d5 := (seq / 100000) % 10; + d4 := (seq / 10000) % 10; + d3 := (seq / 1000) % 10; + d2 := (seq / 100) % 10; + d1 := (seq / 10) % 10; + d0 := seq % 10; - -- 前后互换 + 简单扰乱,保证: - -- 1. 还是8位 - -- 2. seq 不同 → 结果一定不同 - return ((b * 9871) % 10000) * 10000 - + ((a * 1237) % 10000); + -- 构造成 9 位,规则: + -- 1. 首尾互换(原最后一位放第1位,原第1位放最后) + -- 2. 中间全部打乱位置 + RETURN + d0 * 100000000 + -- 原最后一位 → 第1位 + d3 * 10000000 + + d1 * 1000000 + + d5 * 100000 + + d2 * 10000 + + d6 * 1000 + + d4 * 100 + + d7 * 10 + + d0; -- 原第一位 → 第9位 END; $$; -- 启用 ALTER TABLE base_sys_user -ALTER COLUMN id SET DEFAULT next_8digit_shuffle_id(); - - +ALTER COLUMN id SET DEFAULT shuffle_9digit(); ALTER TABLE base_sys_user From e7d85133c376fdade895cd8d187e2205726d929b Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 08:11:03 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20fi?= =?UTF-8?q?ght=5Fboss=E9=87=8E=E6=80=AA=E5=92=8C=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=80=AA.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_boss野怪和地图怪.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index ed89c661..61fbf3e6 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -175,7 +175,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf p.AddPetExp(foi.Winpet, int64(addexp)) - if monster.IsShiny() && p.CanGetXUAN() { + if monster.IsShiny() && p.CanGetXUAN() &&xmlres.PetMAP[int(refref.GeGet()].Type<16{ xuan := 400686 + int64(xmlres.PetMAP[int(refPet.GetID())].Type) ok := p.ItemAdd(xuan, 1) if ok { From bc16ef6860763307c6f93c472283cc53bec518ac Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 08:12:49 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20fi?= =?UTF-8?q?ght=5Fboss=E9=87=8E=E6=80=AA=E5=92=8C=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=80=AA.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_boss野怪和地图怪.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index 61fbf3e6..6c612560 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -175,7 +175,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf p.AddPetExp(foi.Winpet, int64(addexp)) - if monster.IsShiny() && p.CanGetXUAN() &&xmlres.PetMAP[int(refref.GeGet()].Type<16{ + if monster.IsShiny() && p.CanGetXUAN() &&xmlres.PetMAP[int(refref.GeGet())].Type<16{ xuan := 400686 + int64(xmlres.PetMAP[int(refPet.GetID())].Type) ok := p.ItemAdd(xuan, 1) if ok { From 49f8de8661d5b3b28a2c28a92fec380b67e3294e Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 08:15:42 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20fi?= =?UTF-8?q?ght=5Fboss=E9=87=8E=E6=80=AA=E5=92=8C=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=80=AA.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_boss野怪和地图怪.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index 6c612560..b99a007a 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -175,7 +175,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf p.AddPetExp(foi.Winpet, int64(addexp)) - if monster.IsShiny() && p.CanGetXUAN() &&xmlres.PetMAP[int(refref.GeGet())].Type<16{ + if monster.IsShiny() && p.CanGetXUAN() &&xmlres.PetMAP[int(refPet.GetID())].Type<16{ xuan := 400686 + int64(xmlres.PetMAP[int(refPet.GetID())].Type) ok := p.ItemAdd(xuan, 1) if ok { From f1a5b90ca5b196846e2580edfe62b4a896c56446 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 08:59:39 +0800 Subject: [PATCH 09/21] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E7=B1=BB=E5=9E=8B=E5=8F=98=E9=87=8F=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=B9=B6=E7=AE=80=E5=8C=96=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_boss野怪和地图怪.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index b99a007a..78704664 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -174,9 +174,9 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf items.ADDitem(3, uint32(poolexp)) p.AddPetExp(foi.Winpet, int64(addexp)) - - if monster.IsShiny() && p.CanGetXUAN() &&xmlres.PetMAP[int(refPet.GetID())].Type<16{ - xuan := 400686 + int64(xmlres.PetMAP[int(refPet.GetID())].Type) + pettype := int64(xmlres.PetMAP[int(refPet.GetID())].Type) + if monster.IsShiny() && p.CanGetXUAN() && pettype < 16 { + xuan := 400686 + pettype ok := p.ItemAdd(xuan, 1) if ok { items.ADDitem(uint32(xuan), 1) From 3656e43d3cb8116633905d264fa58a552aafa389 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 09:28:00 +0800 Subject: [PATCH 10/21] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E6=8F=90=E7=A4=BA=E6=8E=A5=E5=8F=A3=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=B6=E9=97=B4=E5=9C=B0=E5=9B=BE=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增地图提示接口/maptip,同时将/timemap接口的请求方法从POST改为GET --- modules/config/controller/admin/map.go | 12 +++++++++++- modules/config/service/map.go | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/config/controller/admin/map.go b/modules/config/controller/admin/map.go index 2fbcf31a..8b0a0965 100644 --- a/modules/config/controller/admin/map.go +++ b/modules/config/controller/admin/map.go @@ -25,7 +25,7 @@ func init() { } type TimeMapReq struct { - g.Meta `path:"/timemap" method:"POST"` + g.Meta `path:"/timemap" method:"GET"` } func (this *MapController) TimeMap(ctx context.Context, req *TimeMapReq) (res *cool.BaseRes, err error) { @@ -33,3 +33,13 @@ func (this *MapController) TimeMap(ctx context.Context, req *TimeMapReq) (res *c res.Data = service.NewMapService().GetTimeMap() return res, nil } + +type MapTipReq struct { + g.Meta `path:"/maptip" method:"GET"` +} + +func (this *MapController) MapTip(ctx context.Context, req *MapTipReq) (res *cool.BaseRes, err error) { + res = &cool.BaseRes{} + res.Data = service.NewMapService().GetTimeMap() + return res, nil +} diff --git a/modules/config/service/map.go b/modules/config/service/map.go index 6240a22f..c6dbe6a5 100644 --- a/modules/config/service/map.go +++ b/modules/config/service/map.go @@ -39,3 +39,12 @@ func (s *MapService) GetTimeMap() (ret []model.MapConfig) { return } +func (s *MapService) GetTimeTip() (ret []model.MapConfig) { + //cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":") + m := dbm_notenable(s.Model) + + m.Where(`is_time_space`, 1).Scan(&ret) + + return + +} From 9b344d3753613c00407b6d07383c0c2e6c256d83 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 10:44:31 +0800 Subject: [PATCH 11/21] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E7=83=AD=E5=BA=A6=E4=BF=A1=E6=81=AF=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=9C=B0=E5=9B=BE=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将地图热度信息从简单的计数器改为包含提示信息的结构体 添加矿物、BOSS、宠物和掉落等提示信息的收集功能 优化地图进入和离开时的计数逻辑 --- logic/service/space/hot.go | 29 +++++++++++++++++-- logic/service/space/in_out.go | 10 ++++--- logic/service/space/space.go | 15 ++++++++-- modules/config/controller/admin/map.go | 21 +++++++++----- modules/config/model/map_pit.go | 2 +- modules/config/service/map.go | 13 +++++---- modules/config/service/map_node.go | 15 ++++++++++ modules/config/service/map_pit.go | 15 ++++++++++ modules/config/service/talkconfig.go | 15 ++++++++++ modules/config/service/task.go | 1 + ...t.core.config.xml.EggsXMLInfo_xmlClass.bin | 10 ------- 11 files changed, 112 insertions(+), 34 deletions(-) delete mode 100644 public/config/72_com.robot.core.config.xml.EggsXMLInfo_xmlClass.bin diff --git a/logic/service/space/hot.go b/logic/service/space/hot.go index d12f21ae..46786858 100644 --- a/logic/service/space/hot.go +++ b/logic/service/space/hot.go @@ -5,15 +5,40 @@ type MapHotInfo struct { MapID uint32 `json:"mapId"` // 地图ID Count int32 `struc:"uint32" json:"count"` // 地图里的人数 } +type MapTip struct { + Count int `struc:"uint32" json:"count"` // 地图里的人数 + TipInfoS map[uint32]*TipInfo `json:"tipInfoS"` +} -var maphot = make(map[uint32]*int32, 0) +type TipInfo struct { + Talk []uint32 `json:"talk"` //矿物 + Boss []uint32 `json:"boss"` //boss + Pet []uint32 `json:"pet"` //宠物 + Diao []uint32 `json:"diao"` //掉落 +} + +func (m *MapTip) GetCount(t int) int { + + switch { + case t < 0: + if m.Count > 0 { + m.Count -= t + } + case t > 0: + m.Count += t + } + + return m.Count +} + +var maphot = make(map[uint32]*MapTip, 0) func GetMapHot() []MapHotInfo { ret := make([]MapHotInfo, 0) for k, v := range maphot { ret = append(ret, MapHotInfo{ MapID: k, - Count: *v, + Count: int32(v.GetCount(0)), }) } diff --git a/logic/service/space/in_out.go b/logic/service/space/in_out.go index 81734fbd..9c6ecc9c 100644 --- a/logic/service/space/in_out.go +++ b/logic/service/space/in_out.go @@ -36,8 +36,9 @@ func (s *Space) LeaveMap(c common.PlayerI) { s.Broadcast(c, 2002, info) current, ok := maphot[s.Super] - if ok && *current > 0 { - atomic.AddInt32(maphot[s.Super], -1) + if ok { + current.GetCount(-1) + } if atomic.CompareAndSwapUint32(&s.Owner.UserID, c.GetInfo().UserID, 0) { @@ -57,9 +58,10 @@ func (s *Space) EnterMap(c common.PlayerI) { s.Broadcast(c, 2001, out) s.User.Store(c.GetInfo().UserID, c) s.UserInfo.Store(c.GetInfo().UserID, *out) - _, ok := maphot[s.Super] + curmaps, ok := maphot[s.Super] if ok { - atomic.AddInt32(maphot[s.Super], 1) + curmaps.GetCount(1) + //atomic.AddInt32(maphot[s.Super], 1) } } diff --git a/logic/service/space/space.go b/logic/service/space/space.go index 12bf9486..e4c37fd0 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -80,10 +80,19 @@ func GetSpace(id uint32) *Space { _, ok := maphot[ret.Super] if !ok { - var t1 int32 - maphot[ret.Super] = &t1 - } + maphot[ret.Super] = &MapTip{} + maphot[ret.Super].TipInfoS = make(map[uint32]*TipInfo, 0) + } + _, ok = maphot[ret.Super].TipInfoS[ret.ID] + if !ok { + tips := &TipInfo{} + tips.Diao = service.NewMapService().GetData(ret.ID).DropItemIds + tips.Pet = service.NewMapPitService().GetDataALL(ret.ID) + tips.Talk = service.NewTalkConfigService().GetTip(ret.ID) + tips.Boss = service.NewMapNodeService().GetTip(ret.ID) + maphot[ret.Super].TipInfoS[ret.ID] = tips + } ret.Name = v.Name break } diff --git a/modules/config/controller/admin/map.go b/modules/config/controller/admin/map.go index 8b0a0965..98dddd1e 100644 --- a/modules/config/controller/admin/map.go +++ b/modules/config/controller/admin/map.go @@ -31,15 +31,20 @@ type TimeMapReq struct { func (this *MapController) TimeMap(ctx context.Context, req *TimeMapReq) (res *cool.BaseRes, err error) { res = &cool.BaseRes{} res.Data = service.NewMapService().GetTimeMap() + // re := service.NewMapService().GetTimeMap() + // for _, v := range re { + // v. + + // } return res, nil } -type MapTipReq struct { - g.Meta `path:"/maptip" method:"GET"` -} +// type MapTipReq struct { +// g.Meta `path:"/maptip" method:"GET"` +// } -func (this *MapController) MapTip(ctx context.Context, req *MapTipReq) (res *cool.BaseRes, err error) { - res = &cool.BaseRes{} - res.Data = service.NewMapService().GetTimeMap() - return res, nil -} +// func (this *MapController) MapTip(ctx context.Context, req *MapTipReq) (res *cool.BaseRes, err error) { +// res = &cool.BaseRes{} +// res.Data = service.NewMapService().GetTimeMap() +// return res, nil +// } diff --git a/modules/config/model/map_pit.go b/modules/config/model/map_pit.go index 0b7788fd..6d1ad40c 100644 --- a/modules/config/model/map_pit.go +++ b/modules/config/model/map_pit.go @@ -30,7 +30,7 @@ type MapPit struct { // 复用通用基础配置(ID/创建时间/更新时间等) MapID int32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"` - RefreshID []int `gorm:"type:int[];comment:'精灵ID列表'" json:"refresh_id"` + RefreshID []uint32 `gorm:"type:int[];comment:'精灵ID列表'" json:"refresh_id"` Pos []int `gorm:"type:int[];comment:'坑位位置'" json:"pos"` //最小等级 MinLevel int `gorm:"type:int;not null;default:1;comment:'最小等级'" json:"min_level"` diff --git a/modules/config/service/map.go b/modules/config/service/map.go index c6dbe6a5..b746a63b 100644 --- a/modules/config/service/map.go +++ b/modules/config/service/map.go @@ -39,12 +39,13 @@ func (s *MapService) GetTimeMap() (ret []model.MapConfig) { return } -func (s *MapService) GetTimeTip() (ret []model.MapConfig) { - //cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":") - m := dbm_notenable(s.Model) - m.Where(`is_time_space`, 1).Scan(&ret) +// func (s *MapService) GetTimeTip() (ret []model.MapConfig) { +// //cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":") +// m := dbm_notenable(s.Model) - return +// m.Where(`is_time_space`, 1).Scan(&ret) -} +// return + +// } diff --git a/modules/config/service/map_node.go b/modules/config/service/map_node.go index 828f6645..abca3636 100644 --- a/modules/config/service/map_node.go +++ b/modules/config/service/map_node.go @@ -3,6 +3,8 @@ package service import ( "blazing/cool" "blazing/modules/config/model" + + "github.com/samber/lo" ) type MapNodeService struct { @@ -44,3 +46,16 @@ func (s *MapNodeService) GetDataNode(mapid, node uint32) *model.MapNode { return pet } +func (s *MapNodeService) GetTip(mapid uint32) []uint32 { + + var pet []model.MapNode //一个特性应该是唯一的,但是我们要获取默认随机特性 + dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet) + var ret []uint32 + for _, v := range pet { + ret = append(ret, v.TriggerID) + + } + + return lo.Union(ret) + +} diff --git a/modules/config/service/map_pit.go b/modules/config/service/map_pit.go index 0a68fb23..55b6402c 100644 --- a/modules/config/service/map_pit.go +++ b/modules/config/service/map_pit.go @@ -3,6 +3,8 @@ package service import ( "blazing/cool" "blazing/modules/config/model" + + "github.com/samber/lo" ) type MapPitService struct { @@ -28,3 +30,16 @@ func (s *MapPitService) GetData(mapid, pos uint32) []model.MapPit { return pet } +func (s *MapPitService) GetDataALL(mapid uint32) []uint32 { + + var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性 + dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet) + var ret []uint32 + for _, v := range pet { + + ret = append(ret, v.RefreshID...) + } + + return lo.Union(ret) + +} diff --git a/modules/config/service/talkconfig.go b/modules/config/service/talkconfig.go index 45cc71ad..9812b39c 100644 --- a/modules/config/service/talkconfig.go +++ b/modules/config/service/talkconfig.go @@ -3,6 +3,8 @@ package service import ( "blazing/cool" "blazing/modules/config/model" + + "github.com/samber/lo" ) type TalkConfigService struct { @@ -25,3 +27,16 @@ func (s *TalkConfigService) GetCache(flag int) model.MineralCollectionConfig { return config } + +func (s *TalkConfigService) GetTip(mapid uint32) []uint32 { + var item []model.TaskConfig + dbm_enable(s.Model).Where("map_id", mapid).Scan(&item) + var res []uint32 + for _, v := range item { + res = append(res, v.ItemRewardIds...) + + } + + return lo.Union(res) + +} diff --git a/modules/config/service/task.go b/modules/config/service/task.go index 2ff1b5b8..aee82d4a 100644 --- a/modules/config/service/task.go +++ b/modules/config/service/task.go @@ -57,3 +57,4 @@ func (s *TaskService) IsAcceptable(taskid uint32) (out *model.TaskConfig) { return } + \ No newline at end of file diff --git a/public/config/72_com.robot.core.config.xml.EggsXMLInfo_xmlClass.bin b/public/config/72_com.robot.core.config.xml.EggsXMLInfo_xmlClass.bin deleted file mode 100644 index d93bab56..00000000 --- a/public/config/72_com.robot.core.config.xml.EggsXMLInfo_xmlClass.bin +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - From 74ede45d9232eb0956a41546d267fc53c084ce4b Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 11:25:30 +0800 Subject: [PATCH 12/21] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E8=BF=9B=E5=8C=96=E7=AD=89=E7=BA=A7=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8D=E9=99=8D=E7=BA=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/pet_elo.go | 7 +++---- modules/player/model/pet.go | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/logic/controller/pet_elo.go b/logic/controller/pet_elo.go index f0957afb..02fa9718 100644 --- a/logic/controller/pet_elo.go +++ b/logic/controller/pet_elo.go @@ -11,10 +11,6 @@ import ( "github.com/jinzhu/copier" ) -// PetEVDiy 自定义分配宠物努力值(EV) -// data: 包含宠物捕获时间和EV分配数据的输入信息 -// c: 当前玩家对象 -// 返回: 分配结果和错误码 func (h Controller) PetELV(data *pet.C2S_PET_EVOLVTION, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { _, currentPet, found := c.FindPet(data.CacthTime) if !found { @@ -26,6 +22,9 @@ func (h Controller) PetELV(data *pet.C2S_PET_EVOLVTION, c *player.Player) (resul if flag == 0 { return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady } + if xmlres.PetMAP[int(currentPet.ID)].EvolvingLv > int(currentPet.Level) { +return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady + } evinfo := xmlres.EVOLVMAP[flag].Branches[data.Index-1] if c.Service.Item.CheakItem(uint32(evinfo.EvolvItem)) < int64(evinfo.EvolvItemCount) { diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index 2ca11900..8f348b44 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -313,7 +313,8 @@ func (pet *PetInfo) Downgrade(level uint32) { if ok { - if basic.EvolvesFrom != 0 { + if basic.EvolvesFrom != 0 && xmlres.PetMAP[int(basic.EvolvesFrom)].EvolvFlag == 0 { + pet.ID = uint32(basic.EvolvesFrom) } From 6758483ab26477c45b9dda76bbd601caac08646e Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 11:47:39 +0800 Subject: [PATCH 13/21] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=9C=B0=E5=9B=BE=E6=95=B0=E6=8D=AE=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/space/space.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/logic/service/space/space.go b/logic/service/space/space.go index e4c37fd0..f47ddaf6 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -87,7 +87,11 @@ func GetSpace(id uint32) *Space { _, ok = maphot[ret.Super].TipInfoS[ret.ID] if !ok { tips := &TipInfo{} - tips.Diao = service.NewMapService().GetData(ret.ID).DropItemIds + r := service.NewMapService().GetData(ret.ID) + if r != nil { + tips.Diao = service.NewMapService().GetData(ret.ID).DropItemIds + } + tips.Pet = service.NewMapPitService().GetDataALL(ret.ID) tips.Talk = service.NewTalkConfigService().GetTip(ret.ID) tips.Boss = service.NewMapNodeService().GetTip(ret.ID) From 7a12aa44eb2b3e70b6783664f7b1969754c71042 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 13:47:56 +0800 Subject: [PATCH 14/21] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Go=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E5=B7=A5=E5=85=B7=E5=B9=B6=E9=87=8D=E6=9E=84=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E6=9C=8D=E5=8A=A1=E5=88=9D=E5=A7=8B=E5=8C=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在Dockerfile中添加多个Go开发工具 将空间服务的初始化逻辑从GetSpace方法提取到独立的init方法 优化代码结构并修复导入顺序 --- .ide/Dockerfile | 5 +- logic/service/space/space.go | 119 ++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 58 deletions(-) diff --git a/.ide/Dockerfile b/.ide/Dockerfile index b1750b38..e9308939 100644 --- a/.ide/Dockerfile +++ b/.ide/Dockerfile @@ -36,7 +36,10 @@ ENV GOPATH /root/go ENV PATH="${PATH}:${GOPATH}/bin" RUN go install -v golang.org/x/tools/gopls@latest - +RUN go install -v github.com/cweill/gotests/gotests@latest +RUN go install -v github.com/josharian/impl@latestD +RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest +RUN go install -v github.com/go-delve/delve/cmd/dlv@latest # install goreleaser RUN go install github.com/goreleaser/goreleaser/v2@latest diff --git a/logic/service/space/space.go b/logic/service/space/space.go index f47ddaf6..fb4bf4d4 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -4,7 +4,6 @@ import ( "blazing/common/data/xmlres" "blazing/common/utils" "blazing/cool" - "blazing/modules/config/service" "strconv" "strings" "sync/atomic" @@ -13,6 +12,7 @@ import ( "blazing/logic/service/common" "blazing/logic/service/space/info" + "blazing/modules/config/service" infomodel "blazing/modules/player/model" "github.com/gogf/gf/v2/util/grand" @@ -66,11 +66,70 @@ func GetSpace(id uint32) *Space { return planet } ret := NewSpace() + ret.ID = id + defer ret.init() - if id < 10000 { //说明是玩家地图GetSpace + planetmap.Store(id, ret) + return ret +} + +var planetmap = csmap.New[uint32, *Space]() + +func ParseCoordinateString(s string) []infomodel.Pos { + // 存储解析后的坐标 + var points []infomodel.Pos + + // 空字符串处理 + if strings.TrimSpace(s) == "" { + return points + } + + // 第一步:按竖线分割成单个坐标字符串 + coordStrs := strings.Split(s, "|") + for _, coordStr := range coordStrs { + // 去除首尾空格(兼容可能的格式不规范) + coordStr = strings.TrimSpace(coordStr) + if coordStr == "" { + return nil + } + + // 第二步:按逗号分割X、Y值 + xy := strings.Split(coordStr, ",") + if len(xy) != 2 { + return nil + } + + // 第三步:转换为整数 + xStr := strings.TrimSpace(xy[0]) + yStr := strings.TrimSpace(xy[1]) + + x, err := strconv.Atoi(xStr) + if err != nil { + return nil + } + + y, err := strconv.Atoi(yStr) + if err != nil { + return nil + } + + // 添加到切片 + points = append(points, infomodel.Pos{X: uint32(x), Y: uint32(y)}) + } + + return points +} +func (t *Space) Next(time.Time) time.Time { + + return time.Now().Add(grand.D(6*time.Second, 30*time.Second)) + +} +func (ret *Space) init() { + + if ret.ID < 10000 { //说明是玩家地图GetSpace for _, v := range xmlres.MapConfig.Maps { - if v.ID == int(id) { //找到这个地图 + if v.ID == int(ret.ID) { //找到这个地图 ret.Super = uint32(v.Super) if ret.Super == 0 { @@ -139,60 +198,6 @@ func GetSpace(id uint32) *Space { } - planetmap.Store(id, ret) - return ret -} - -var planetmap = csmap.New[uint32, *Space]() - -func ParseCoordinateString(s string) []infomodel.Pos { - // 存储解析后的坐标 - var points []infomodel.Pos - - // 空字符串处理 - if strings.TrimSpace(s) == "" { - return points - } - - // 第一步:按竖线分割成单个坐标字符串 - coordStrs := strings.Split(s, "|") - for _, coordStr := range coordStrs { - // 去除首尾空格(兼容可能的格式不规范) - coordStr = strings.TrimSpace(coordStr) - if coordStr == "" { - return nil - } - - // 第二步:按逗号分割X、Y值 - xy := strings.Split(coordStr, ",") - if len(xy) != 2 { - return nil - } - - // 第三步:转换为整数 - xStr := strings.TrimSpace(xy[0]) - yStr := strings.TrimSpace(xy[1]) - - x, err := strconv.Atoi(xStr) - if err != nil { - return nil - } - - y, err := strconv.Atoi(yStr) - if err != nil { - return nil - } - - // 添加到切片 - points = append(points, infomodel.Pos{X: uint32(x), Y: uint32(y)}) - } - - return points -} -func (t *Space) Next(time.Time) time.Time { - - return time.Now().Add(grand.D(6*time.Second, 30*time.Second)) - } func (ret *Space) GenBoss() { From de4617cd6b54da86b529468bc52ff1e3fc3d2ce6 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 16:14:59 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20pl?= =?UTF-8?q?ayer.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/player/player.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 5f66f583..82aaf2a2 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -57,7 +57,7 @@ func (o *OgrePetInfo) GetLevel() int { // handleNPCFightSpecial 处理NPC战斗特殊情况 func (o *OgrePetInfo) HandleNPCFightSpecial(can int) { - if can == 0 && o.Ext != 0 { + if can == 0 && o.Ext == 0 {//不能抓并且不是尼尔 o.IsCapture = 0 return } From 911c1d7ec275f39dc1c679404825d19bf3efd6dc Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 17:26:00 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20it?= =?UTF-8?q?em=5Fuse.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/item_use.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/controller/item_use.go b/logic/controller/item_use.go index 0f8d1b9d..cf6821a2 100644 --- a/logic/controller/item_use.go +++ b/logic/controller/item_use.go @@ -97,7 +97,7 @@ func (h Controller) handleNeuronItem(currentPet *model.PetInfo, c *player.Player // 炫彩碎片 处理神300212 func (h Controller) handlexuancaiItem(currentPet *model.PetInfo, c *player.Player) errorcode.ErrorCode { - r, _ := element.Calculator.GetCombination(int(currentPet.ID)) + r, _ := element.Calculator.GetCombination(int(xmlres.PetMAP[int(currentPet.ID)].Type)) if r.Secondary != nil { return errorcode.ErrorCodes.ErrItemUnusable } From 49c15e26d383c4b9431bd60c088817bdacc96d5c Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 1 Mar 2026 19:16:38 +0800 Subject: [PATCH 17/21] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=20QuitSelf?= =?UTF-8?q?=20=E5=87=BD=E6=95=B0=E4=B8=AD=E7=9A=84=20goroutine=20=E9=80=80?= =?UTF-8?q?=E5=87=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/socket/kick.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/socket/kick.go b/common/socket/kick.go index 300cf612..6883ee27 100644 --- a/common/socket/kick.go +++ b/common/socket/kick.go @@ -50,6 +50,7 @@ func (s *Server) QuitSelf(a int) error { return false }) } else { + go func() { player.Mainplayer.Range(func(key uint32, value *player.Player) bool { if value != nil { @@ -63,9 +64,10 @@ func (s *Server) QuitSelf(a int) error { if value != nil { value.Kick(true) } - os.Exit(0) + return false }) + os.Exit(0) }() } From 6b2ca1d510ff6cad64205d438733bd8ad180bc33 Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 2 Mar 2026 15:44:42 +0800 Subject: [PATCH 18/21] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20Dockerfile=20?= =?UTF-8?q?=E4=B8=AD=20impl=20=E5=AE=89=E8=A3=85=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=9A=84=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ide/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ide/Dockerfile b/.ide/Dockerfile index e9308939..7c0466e8 100644 --- a/.ide/Dockerfile +++ b/.ide/Dockerfile @@ -37,7 +37,7 @@ ENV PATH="${PATH}:${GOPATH}/bin" RUN go install -v golang.org/x/tools/gopls@latest RUN go install -v github.com/cweill/gotests/gotests@latest -RUN go install -v github.com/josharian/impl@latestD +RUN go install -v github.com/josharian/impl@latest RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest RUN go install -v github.com/go-delve/delve/cmd/dlv@latest # install goreleaser From 75dd3af9bd238a94946e01de6de886edc8181f03 Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 2 Mar 2026 15:50:59 +0800 Subject: [PATCH 19/21] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=20Go=20=E5=BC=80=E5=8F=91=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ide/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ide/Dockerfile b/.ide/Dockerfile index 7c0466e8..42a5a451 100644 --- a/.ide/Dockerfile +++ b/.ide/Dockerfile @@ -36,9 +36,9 @@ ENV GOPATH /root/go ENV PATH="${PATH}:${GOPATH}/bin" RUN go install -v golang.org/x/tools/gopls@latest -RUN go install -v github.com/cweill/gotests/gotests@latest -RUN go install -v github.com/josharian/impl@latest -RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest +# RUN go install -v github.com/cweill/gotests/gotests@latest +# RUN go install -v github.com/josharian/impl@latest +# RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest RUN go install -v github.com/go-delve/delve/cmd/dlv@latest # install goreleaser RUN go install github.com/goreleaser/goreleaser/v2@latest From ae06d18aa2aa3431f54963affde021cf108ca79e Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 2 Mar 2026 15:54:21 +0800 Subject: [PATCH 20/21] feat: --- .ide/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ide/Dockerfile b/.ide/Dockerfile index 42a5a451..7c0466e8 100644 --- a/.ide/Dockerfile +++ b/.ide/Dockerfile @@ -36,9 +36,9 @@ ENV GOPATH /root/go ENV PATH="${PATH}:${GOPATH}/bin" RUN go install -v golang.org/x/tools/gopls@latest -# RUN go install -v github.com/cweill/gotests/gotests@latest -# RUN go install -v github.com/josharian/impl@latest -# RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest +RUN go install -v github.com/cweill/gotests/gotests@latest +RUN go install -v github.com/josharian/impl@latest +RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest RUN go install -v github.com/go-delve/delve/cmd/dlv@latest # install goreleaser RUN go install github.com/goreleaser/goreleaser/v2@latest From 47bc680889e177b01e6ddad341f6960030264c10 Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 2 Mar 2026 18:34:20 +0800 Subject: [PATCH 21/21] =?UTF-8?q?refactor:=20=E5=B0=86=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E5=92=8C=E5=9C=A8=E7=BA=BFID=E7=B1=BB=E5=9E=8B=E4=BB=8Euint16?= =?UTF-8?q?=E6=94=B9=E4=B8=BAuint32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cool/coolconfig/config.go | 6 +++--- common/cool/rpc.go | 4 ++-- common/data/share/user.go | 10 +++++----- common/rpc/client.go | 4 ++-- common/rpc/rpc.go | 12 ++++++------ common/socket/ServerEvent.go | 2 +- common/socket/ServerOption.go | 4 ++-- logic/controller/Controller.go | 4 ++-- logic/main.go | 2 +- logic/server.go | 8 ++++---- modules/config/controller/admin/server.go | 4 ++-- modules/config/service/server.go | 10 +++++----- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/common/cool/coolconfig/config.go b/common/cool/coolconfig/config.go index 1b56773a..8f4a8ed7 100644 --- a/common/cool/coolconfig/config.go +++ b/common/cool/coolconfig/config.go @@ -13,18 +13,18 @@ type sConfig struct { File *file `json:"file,omitempty"` // 文件上传配置 Name string `json:"name"` // 项目名称 // LoginPort string `json:"port"` - GameOnlineID uint16 `json:"port_bl"` //这个是命令行输入的参数 + GameOnlineID uint32 `json:"port_bl"` //这个是命令行输入的参数 ServerInfo ServerList Address string //rpc端口 } type ServerList struct { - OnlineID uint16 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"` + OnlineID uint32 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"` //服务器名称Desc Name string `gorm:"comment:'服务器名称'" json:"name"` IP string `gorm:"type:string;comment:'服务器IP'" json:"ip"` - Port uint16 `gorm:"comment:'端口号,通常是小整数'" json:"port"` + Port uint32 `gorm:"comment:'端口号,通常是小整数'" json:"port"` IsOpen uint8 `gorm:"default:0;not null;comment:'是否开启'" json:"is_open"` //登录地址 LoginAddr string `gorm:"type:string;comment:'登录地址'" json:"login_addr"` diff --git a/common/cool/rpc.go b/common/cool/rpc.go index 8d55dcca..7a8bf2e8 100644 --- a/common/cool/rpc.go +++ b/common/cool/rpc.go @@ -1,13 +1,13 @@ package cool // 存值示例 -func AddClient(id uint16, client *ClientHandler) { +func AddClient(id uint32, client *ClientHandler) { // 普通map:Clientmap[id] = client Clientmap.Store(id, client) // sync.Map存值 } // 取值示例 -func GetClient(id uint16) (*ClientHandler, bool) { +func GetClient(id uint32) (*ClientHandler, bool) { // 普通map:client, ok := Clientmap[id] val, ok := Clientmap.Load(id) // sync.Map取值 if !ok { diff --git a/common/data/share/user.go b/common/data/share/user.go index 2bcd59f8..531a7c82 100644 --- a/common/data/share/user.go +++ b/common/data/share/user.go @@ -20,8 +20,8 @@ func newSessionStore() *cacheStore[uint32] { } // newUserOnlineStore 创建用户在线状态缓存实例 -func newUserOnlineStore() *cacheStore[uint16] { - return &cacheStore[uint16]{ +func newUserOnlineStore() *cacheStore[uint32] { + return &cacheStore[uint32]{ manager: cool.CacheManager, prefix: "blazing:useronline:", } @@ -38,7 +38,7 @@ func newEmailCodeStore() *cacheStore[int] { // sessionManager 会话管理器 type sessionManager struct { sessionStore *cacheStore[uint32] // 会话缓存 - userOnlineStore *cacheStore[uint16] // 用户在线状态缓存 + userOnlineStore *cacheStore[uint32] // 用户在线状态缓存 emailCodeStore *cacheStore[int] // 邮件注册码缓存 } @@ -52,12 +52,12 @@ func newSessionManager() *sessionManager { } // SetUserOnline 设置用户在线状态 -func (m *sessionManager) SetUserOnline(userID uint32, serverID uint16) error { +func (m *sessionManager) SetUserOnline(userID uint32, serverID uint32) error { return m.userOnlineStore.Set(gctx.New(), gconv.String(userID), serverID, 0) } // GetUserOnline 获取用户在线状态 -func (m *sessionManager) GetUserOnline(userID uint32) (uint16, error) { +func (m *sessionManager) GetUserOnline(userID uint32) (uint32, error) { return m.userOnlineStore.Get(context.Background(), gconv.String(userID)) } diff --git a/common/rpc/client.go b/common/rpc/client.go index 77b215ab..57449756 100644 --- a/common/rpc/client.go +++ b/common/rpc/client.go @@ -33,7 +33,7 @@ func GetServerInfoList(isdebug int32) []ServerInfo { } tt.Name = v.Name - tt.Port = v.Port + tt.Port =uint16( v.Port) ret1 = append(ret1, *tt) } @@ -89,7 +89,7 @@ type ServerInfo struct { // 服务器IP, 16字节UTF-8, 不足16补齐到16 IP string `struc:"[16]byte"` // 定长模式:16字节 // 端口 - Port uint16 + Port uint16 // 好友在线的个数 Friends uint32 } diff --git a/common/rpc/rpc.go b/common/rpc/rpc.go index 4abc8bc4..5560e3b3 100644 --- a/common/rpc/rpc.go +++ b/common/rpc/rpc.go @@ -34,7 +34,7 @@ func (*ServerHandler) Kick(_ context.Context, userid uint32) error { } // 注册logic服务器 -func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) error { +func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint32) error { fmt.Println("注册logic服务器", id, port) //TODO 待修复滚动更新可能导致的玩家可以同时在旧服务器和新服务器同时在线的bug @@ -44,11 +44,11 @@ func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) error } t := config.NewServerService().GetServerID((id)) - aa, ok := cool.GetClient(t.Port) + aa, ok := cool.GetClient(t.OnlineID*100000 + t.Port) if ok && aa != nil { //如果已经存在且这个端口已经被存过 aa.QuitSelf(0) } - cool.AddClient(port, &revClient) + cool.AddClient(100000*id+port, &revClient) //Refurh() return nil @@ -67,10 +67,10 @@ func CServer() *jsonrpc.RPCServer { var closer jsonrpc.ClientCloser -func StartClient(id, port uint16, callback any) *struct { +func StartClient(id, port uint32, callback any) *struct { Kick func(uint32) error - RegisterLogic func(uint16, uint16) error + RegisterLogic func(uint32, uint32) error } { // cool.Config.File.Domain = "127.0.0.1" var rpcaddr = "ws://" + cool.Config.File.Domain + gconv.String(cool.Config.Address) + "/rpc" @@ -99,7 +99,7 @@ func StartClient(id, port uint16, callback any) *struct { var RPCClient struct { Kick func(uint32) error //踢人 - RegisterLogic func(uint16, uint16) error + RegisterLogic func(uint32, uint32) error // UserLogin func(int32, int32) error //用户登录事件 // UserLogout func(int32, int32) error //用户登出事件 diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index d1354617..93c70af9 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -20,7 +20,7 @@ import ( "github.com/panjf2000/gnet/v2" ) -func (s *Server) Boot(serverid, port uint16) error { +func (s *Server) Boot(serverid, port uint32) error { // go s.bootws() s.serverid = serverid s.port = port diff --git a/common/socket/ServerOption.go b/common/socket/ServerOption.go index 8e1f6659..c2d24328 100644 --- a/common/socket/ServerOption.go +++ b/common/socket/ServerOption.go @@ -25,8 +25,8 @@ type Server struct { discorse bool quit bool // batchRead int - serverid uint16 - port uint16 + serverid uint32 + port uint32 } type Option func(*Server) diff --git a/logic/controller/Controller.go b/logic/controller/Controller.go index 90ca764c..f17bbb16 100644 --- a/logic/controller/Controller.go +++ b/logic/controller/Controller.go @@ -23,11 +23,11 @@ var Maincontroller = &Controller{} //注入service // Controller 分发cmd逻辑实现 type Controller struct { - Port uint16 + Port uint32 RPCClient *struct { Kick func(uint32) error - RegisterLogic func(uint16, uint16) error + RegisterLogic func(uint32, uint32) error } } diff --git a/logic/main.go b/logic/main.go index 3e5fadc6..e86a6843 100644 --- a/logic/main.go +++ b/logic/main.go @@ -97,7 +97,7 @@ func main() { // go cool.ListenFunc(gctx.New()) // } // 解析命令行参数 - cool.Config.GameOnlineID = gcmd.GetOpt("id", "1").Uint16() + cool.Config.GameOnlineID = gcmd.GetOpt("id", "1").Uint32() go Start() //注入service // if cool.Config.GameOnlineID == 2 { //只分析1服务器的 // go PprofWeb() diff --git a/logic/server.go b/logic/server.go index b89bf232..04828b5d 100644 --- a/logic/server.go +++ b/logic/server.go @@ -66,7 +66,7 @@ func Start() { } port, err := determinePort(cool.Config.ServerInfo.CanPort) - cool.Config.ServerInfo.Port = uint16(port) + cool.Config.ServerInfo.Port = uint32(port) if err != nil { log.Fatalf("Failed to determine port: %v", err) } @@ -75,12 +75,12 @@ func Start() { socket.WithPort(port), ) - rpcClient := rpc.StartClient(serverID, uint16(port), server) //连接rpc + rpcClient := rpc.StartClient(serverID, uint32(port), server) //连接rpc controller.Maincontroller.RPCClient = rpcClient //将RPC赋值Start - controller.Maincontroller.Port = uint16(port) //赋值服务器ID + controller.Maincontroller.Port = uint32(port) //赋值服务器ID controller.Init(true) xmlres.Initfile() - server.Boot(serverID, gconv.Uint16(port)) + server.Boot(serverID, gconv.Uint32(port)) } diff --git a/modules/config/controller/admin/server.go b/modules/config/controller/admin/server.go index 82f297a3..15944306 100644 --- a/modules/config/controller/admin/server.go +++ b/modules/config/controller/admin/server.go @@ -34,9 +34,9 @@ type QuitSReq struct { func (this *ServerController) Quit(ctx context.Context, req *QuitSReq) (res *cool.BaseRes, err error) { res = &cool.BaseRes{} - serv := service.NewServerService().GetServerID(uint16(req.ID)) + serv := service.NewServerService().GetServerID(req.ID) - aa, ok := cool.GetClient(serv.Port) + aa, ok := cool.GetClient(serv.OnlineID*100000 + serv.Port) if ok && aa != nil { //如果已经存在且这个端口已经被存过 aa.QuitSelf(req.Code) } diff --git a/modules/config/service/server.go b/modules/config/service/server.go index 684c965f..5ae2ec57 100644 --- a/modules/config/service/server.go +++ b/modules/config/service/server.go @@ -29,7 +29,7 @@ func NewServerService() *ServerService { var rr []g.MapStrAny r, _ := gconv.Map(data)["list"].(gdb.Result) for i := 0; i < len(r); i++ { - t, ok := cool.GetClient(gconv.Uint16(r[i].Map()["port"])) + t, ok := cool.GetClient(10000*gconv.Uint32(r[i].Map()["online_id"])+gconv.Uint32(r[i].Map()["port"])) // tt.Friends = v.Friends subm := r[i].GMap() @@ -74,7 +74,7 @@ func (s *ServerService) GetPort(DepartmentID uint) gdb.List { var res gdb.Result m := cool.DBM(s.Model).Where("is_open", 1).Fields("ip", "port", "online_id", "is_vip", "name") if DepartmentID != 1 { - + res, _ = m.All() } else { @@ -107,7 +107,7 @@ func (s *ServerService) StartUPdate(OnlineID uint16, isinstall int) model.Server return tttt } -func (s *ServerService) SetServerID(OnlineID uint16, Port uint16) error { +func (s *ServerService) SetServerID(OnlineID uint32, Port uint32) error { m := cool.DBM(s.Model).Where("online_id", OnlineID) @@ -122,7 +122,7 @@ func (s *ServerService) SetServerID(OnlineID uint16, Port uint16) error { return nil } -func (s *ServerService) GetServerID(OnlineID uint16) model.ServerList { +func (s *ServerService) GetServerID(OnlineID uint32) model.ServerList { var tttt model.ServerList cool.DBM(s.Model).Where("online_id", OnlineID).Scan(&tttt) @@ -131,7 +131,7 @@ func (s *ServerService) GetServerID(OnlineID uint16) model.ServerList { } // 保存版本号 -func (s *ServerService) SetServerScreen(id uint16, name string) { +func (s *ServerService) SetServerScreen(id uint32, name string) { cool.DBM(s.Model).Where("online_id", id).Data("old_screen", name).Update()