Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
1.fix cocoon drop Equipment
2.fix Challenge Kill Monster Num
  • Loading branch information
gucooing committed Sep 2, 2024
1 parent 6bf45a0 commit 4fcd5b2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 32 deletions.
56 changes: 30 additions & 26 deletions gameserver/model/db_battle.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,36 +718,40 @@ func (g *PlayerData) GetBattleDropData(mappingInfoID uint32, addPileItem []*Mate
itemConfMap := gdconf.GetItemConfigMap()
for _, displayItem := range conf.DisplayItemList {
itemConf := itemConfMap.Item[displayItem.ItemID]
if itemConf == nil {
continue
}
switch itemConf.ItemSubType {
case constant.ItemSubTypeRelicSetShowOnly:
for _, id := range itemConf.CustomDataList {
relicConf := gdconf.GetRelicBySetID(id, itemConf.Rarity)
if relicConf != nil {
uniqueId := g.AddRelic(relicConf.ID, 0, nil)
itemList = append(itemList, g.GetRelicItem(uniqueId))
allSync.RelicList = append(allSync.RelicList, uniqueId)
if itemConf != nil {
switch itemConf.ItemSubType {
case constant.ItemSubTypeRelicSetShowOnly:
for _, id := range itemConf.CustomDataList {
relicConf := gdconf.GetRelicBySetID(id, itemConf.Rarity)
if relicConf != nil {
uniqueId := g.AddRelic(relicConf.ID, 0, nil)
itemList = append(itemList, g.GetRelicItem(uniqueId))
allSync.RelicList = append(allSync.RelicList, uniqueId)
}
}
continue
}
itemNum := displayItem.ItemNum
if displayItem.ItemID == Scoin {
itemNum = 1500 + worldLevel*300
}
if itemNum == 0 {
itemNum = 1 + worldLevel
}
addPileItem = append(addPileItem, &Material{
Tid: displayItem.ItemID,
Num: itemNum,
})
itemList = append(itemList, &proto.Item{
ItemId: displayItem.ItemID,
Num: itemNum,
})
continue
} else if itemConfMap.Equipment[displayItem.ItemID] != nil {
uniqueId := g.AddEquipment(displayItem.ItemID)
itemList = append(itemList, g.GetEquipmentItem(uniqueId))
allSync.EquipmentList = append(allSync.EquipmentList, uniqueId)
}
itemNum := displayItem.ItemNum
if displayItem.ItemID == Scoin {
itemNum = 1500 + worldLevel*300
}
if itemNum == 0 {
itemNum = 1 + worldLevel
}
addPileItem = append(addPileItem, &Material{
Tid: displayItem.ItemID,
Num: itemNum,
})
itemList = append(itemList, &proto.Item{
ItemId: displayItem.ItemID,
Num: itemNum,
})
}
return itemList
}
Expand Down
4 changes: 2 additions & 2 deletions gameserver/player/player_battle.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ func (g *GamePlayer) PVEBattleResultCsReq(payloadMsg pb.Message) {

switch g.GetPd().GetBattleStatus() {
case spb.BattleType_Battle_CHALLENGE:
g.ChallengePVEBattleResultCsReq(req)
g.ChallengePVEBattleResultCsReq(req, battleBin)
case spb.BattleType_Battle_CHALLENGE_Story:
g.ChallengePVEBattleResultCsReq(req)
g.ChallengePVEBattleResultCsReq(req, battleBin)
case spb.BattleType_Battle_ROGUE:
teleportToAnchor = false
g.RoguePVEBattleResultCsReq(req, sce)
Expand Down
6 changes: 4 additions & 2 deletions gameserver/player/player_challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (g *GamePlayer) LeaveChallengeCsReq(payloadMsg pb.Message) {

// 忘却之庭世界战斗结算事件

func (g *GamePlayer) ChallengePVEBattleResultCsReq(req *proto.PVEBattleResultCsReq) {
func (g *GamePlayer) ChallengePVEBattleResultCsReq(req *proto.PVEBattleResultCsReq, battleBin *model.BattleBackup) {
db := g.GetPd().GetCurChallenge()
if db == nil {
return
Expand All @@ -191,7 +191,9 @@ func (g *GamePlayer) ChallengePVEBattleResultCsReq(req *proto.PVEBattleResultCsR
case proto.BattleEndStatus_BATTLE_END_QUIT: // 退出战斗
return
}
g.GetPd().AddCurChallengeKillMonster(1) // TODO 默认一次战斗一个怪物
if battleBin != nil && battleBin.Sce != nil {
g.GetPd().AddCurChallengeKillMonster(uint32(len(battleBin.Sce.MonsterEntityIdList)))
}
// 场景上是否还有未处理敌人
if g.GetPd().GetCurChallengeMonsterNum() > g.GetPd().GetCurChallengeKillMonster() {
return // 还有就不更新状态,继续进行
Expand Down
1 change: 1 addition & 0 deletions hkrpg-go-pe/new_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func NewServer(cfg *Config) *HkRpgGoServer {
// 启动kcp
addr := cfg.GameServer.InnerAddr + ":" + cfg.GameServer.InnerPort
logger.Info("KCP监听地址:%s", addr)
logger.Info("KCP对外地址:%s", cfg.GameServer.OuterAddr+":"+cfg.GameServer.OuterPort)
kcpListener, err := kcp.ListenWithOptions(addr)
if err != nil {
log.Printf("listen kcp err: %v\n", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kcp/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"encoding/binary"
"errors"
"io"
rand2 "math/rand"
"net"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -706,10 +707,8 @@ func (l *Listener) EnetHandle() {
}
var conv uint32
var sessionId uint32
// relogin := false
if enetNotify.Conv != 0 {
conv = enetNotify.Conv
// relogin = true
} else {
_ = binary.Read(rand.Reader, binary.LittleEndian, &conv)
}
Expand Down Expand Up @@ -953,6 +952,7 @@ func serveConn(conn net.PacketConn, ownConn bool) (*Listener, error) {
l.die = make(chan struct{})
l.chSocketReadError = make(chan struct{})
l.enetNotifyChan = make(chan *Enet, 1000)
l.sessionIdCounter = uint32(rand2.Intn(1000) + 1)

if _, ok := l.conn.(*net.UDPConn); ok {
addr, err := net.ResolveUDPAddr("udp", l.conn.LocalAddr().String())
Expand Down

0 comments on commit 4fcd5b2

Please sign in to comment.