diff --git a/logic/controller/PET_FUSION.go b/logic/controller/PET_FUSION.go new file mode 100644 index 000000000..b0b429f89 --- /dev/null +++ b/logic/controller/PET_FUSION.go @@ -0,0 +1 @@ +package controller diff --git a/logic/controller/item_buy.go b/logic/controller/item_buy.go index 53b4e2084..14a95bab4 100644 --- a/logic/controller/item_buy.go +++ b/logic/controller/item_buy.go @@ -61,9 +61,11 @@ func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, c *player.Playe if !c.UseGold(uint32(data.Count) * uint32(gconv.Uint32(r.Price))) { return nil, errorcode.ErrorCodes.ErrSystemError } - c.ItemAdd(model.ItemInfo{ItemId: uint32(gconv.Uint32(r.ItemID)), ItemCnt: uint32(data.Count)}) - c.Info.GoldBean -= gconv.Uint32(r.Price) - + r1 := c.ItemAdd(model.ItemInfo{ItemId: uint32(gconv.Uint32(r.ItemID)), ItemCnt: uint32(data.Count)}) + if len(r1) == int(data.Count) { + //失败返还 + c.Info.GoldBean += uint32(uint32(data.Count)-uint32(len(r1))) * uint32(gconv.Uint32(r.Price)) + } result = &item.S2C_GoldBuyProductInfo{ Gold: c.Info.GoldBean, PayGold: uint32(data.Count) * uint32(gconv.Uint32(r.Price)), diff --git a/logic/controller/item_use.go b/logic/controller/item_use.go index 9b18208f3..4b1bda0c2 100644 --- a/logic/controller/item_use.go +++ b/logic/controller/item_use.go @@ -58,7 +58,7 @@ func (h Controller) ItemUsePet(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGHT, c *play } c.Service.Item.SubItem(data.ItemID, 1) result = &item.S2C_USE_PET_ITEM_OUT_OF_FIGHT{} - onpet.Update() + onpet.CalculatePetPane() copier.Copy(&result, onpet) return result, 0 @@ -74,6 +74,7 @@ func (h Controller) RESET_NATURE(data *item.C2S_PET_RESET_NATURE, c *player.Play } onpet.Nature = data.Nature + onpet.CalculatePetPane() c.Service.Item.SubItem(data.ItemId, 1) return result, 0 } diff --git a/logic/service/space/hot.go b/logic/service/space/hot.go index 0ed86f562..9665e6317 100644 --- a/logic/service/space/hot.go +++ b/logic/service/space/hot.go @@ -1,9 +1,6 @@ package space import ( - "sync/atomic" - - csmap "github.com/mhmtszr/concurrent-swiss-map" "golang.org/x/sync/singleflight" ) @@ -14,32 +11,18 @@ type MapHotInfo struct { Count int32 `struc:"uint32" json:"count"` // 地图里的人数 } -var maphot = csmap.New[uint32, *int32]( - // set the number of map shards. the default value is 32. - csmap.WithShardCount[uint32, *int32](32), - - // // if don't set custom hasher, use the built-in maphash. - // csmap.WithCustomHasher[string, int](func(key string) uint64 { - // hash := fnv.New64a() - // hash.Write([]byte(key)) - // return hash.Sum64() - // }), - - // set the total capacity, every shard map has total capacity/shard count capacity. the default value is 0. - // csmap.WithSize[string, int](1000), -) +var maphot = make(map[uint32]*int32, 0) func GetMapHot() []MapHotInfo { ret := make([]MapHotInfo, 0) - maphot.Range(func(key uint32, value *int32) (stop bool) { - + for k, v := range maphot { ret = append(ret, MapHotInfo{ - MapID: key, - Count: atomic.LoadInt32(value), + MapID: k, + Count: *v, }) - return true - }) + } + return ret // result1, _, _ := requestGroup.Do("map_hot", func() (interface{}, error) { diff --git a/logic/service/space/in_out.go b/logic/service/space/in_out.go index 2e30f720c..f365aa414 100644 --- a/logic/service/space/in_out.go +++ b/logic/service/space/in_out.go @@ -46,10 +46,8 @@ func (s *Space) LeaveMap(c common.PlayerI) { s.User.Delete(c.GetInfo().UserID) s.UserInfo.Delete(c.GetInfo().UserID) - if s.SuperValue != nil { - atomic.AddInt32(s.SuperValue, -1) - } + atomic.AddInt32(maphot[s.Super], -1) } @@ -62,9 +60,7 @@ func (s *Space) EnterMap(c common.PlayerI) { s.UserInfo.Store(c.GetInfo().UserID, *out) s.Broadcast(c, 2001, out) - if s.SuperValue != nil { - atomic.AddInt32(s.SuperValue, 1) - } + atomic.AddInt32(maphot[s.Super], 1) } func (s *Space) GetInfo() []maps.OutInfo { diff --git a/logic/service/space/space.go b/logic/service/space/space.go index 775e8b192..fe761e942 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -16,7 +16,7 @@ type Space struct { UserInfo *csmap.CsMap[uint32, maps.OutInfo] CanRefresh bool //是否能够刷怪 Super uint32 - SuperValue *int32 + //SuperValue *int32 //ID uint32 // 地图ID Name string //地图名称 Owner ARENA @@ -73,20 +73,20 @@ func GetSpace(id uint32) *Space { for _, v := range xmlres.MapConfig.Maps { if v.ID == int(id) { //找到这个地图 - t := NewSpace() - t.Super = uint32(v.Super) - ok := maphot.Has(t.Super) - if !ok { - var tt int32 = 0 - maphot.Store(uint32(v.Super), &tt) - t.SuperValue = &tt //创建一个 - } else { - t.SuperValue, _ = maphot.Load(uint32(v.Super)) + // t.Super = uint32(v.Super) + // if t.Super == 0 { + // t.Super = uint32(v.ID) + // } + t.Super = uint32(v.ID) + _, ok := maphot[t.Super] + if !ok { + var t1 int32 + maphot[t.Super] = &t1 } t.Name = v.Name - + break } } diff --git a/public/config/210.xml b/public/config/210.xml new file mode 120000 index 000000000..68ceb23b4 --- /dev/null +++ b/public/config/210.xml @@ -0,0 +1 @@ +E:/newcode/flash/out/resource/xml/210.xml \ No newline at end of file diff --git a/public/config/地图配置野怪.xml b/public/config/地图配置野怪.xml index fde98403f..6a3ca148d 100644 --- a/public/config/地图配置野怪.xml +++ b/public/config/地图配置野怪.xml @@ -7827,15 +7827,15 @@ eg: - - - - + + + + + + + + - - - -