Merge branch 'main' into feature/gacha-enum

This commit is contained in:
wish
2023-01-23 22:55:22 +11:00
8 changed files with 131 additions and 51 deletions

View File

@@ -1502,25 +1502,74 @@ func handleMsgMhfInfoScenarioCounter(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfGetEtcPoints(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetEtcPoints)
resp := byteframe.NewByteFrame()
resp.WriteUint8(0x3) // Maybe a count of uint32(s)?
resp.WriteUint32(0) // Point bonus quests
resp.WriteUint32(0) // Daily quests
resp.WriteUint32(0) // HS promotion points
var dailyTime time.Time
_ = s.server.db.QueryRow("SELECT COALESCE(daily_time, $2) FROM characters WHERE id = $1", s.charID, time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)).Scan(&dailyTime)
if Time_Current_Adjusted().After(dailyTime) {
s.server.db.Exec("UPDATE characters SET bonus_quests = 0, daily_quests = 0 WHERE id=$1", s.charID)
}
var bonusQuests, dailyQuests, promoPoints uint32
_ = s.server.db.QueryRow(`SELECT bonus_quests, daily_quests, promo_points FROM characters WHERE id = $1`, s.charID).Scan(&bonusQuests, &dailyQuests, &promoPoints)
resp := byteframe.NewByteFrame()
resp.WriteUint8(3) // Maybe a count of uint32(s)?
resp.WriteUint32(bonusQuests)
resp.WriteUint32(dailyQuests)
resp.WriteUint32(promoPoints)
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
}
func handleMsgMhfUpdateEtcPoint(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfUpdateEtcPoint)
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
var column string
switch pkt.PointType {
case 0:
column = "bonus_quests"
case 1:
column = "daily_quests"
case 2:
column = "promo_points"
}
var value int
err := s.server.db.QueryRow(fmt.Sprintf(`SELECT %s FROM characters WHERE id = $1`, column), s.charID).Scan(&value)
if err == nil {
if value-int(pkt.Delta) < 0 {
s.server.db.Exec(fmt.Sprintf(`UPDATE characters SET %s = 0 WHERE id = $1`, column), s.charID)
} else {
s.server.db.Exec(fmt.Sprintf(`UPDATE characters SET %s = %s + $1 WHERE id = $2`, column, column), pkt.Delta, s.charID)
}
}
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
}
func handleMsgMhfStampcardStamp(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfStampcardStamp)
// TODO: Work out where it gets existing stamp count from, its format and then
// update the actual sent values to be correct
doAckBufSucceed(s, pkt.AckHandle, []byte{0x03, 0xe7, 0x03, 0xe7, 0x02, 0x99, 0x02, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x14, 0xf8, 0x69, 0x54})
bf := byteframe.NewByteFrame()
bf.WriteUint16(pkt.HR)
bf.WriteUint16(pkt.GR)
var stamps uint16
_ = s.server.db.QueryRow(`SELECT stampcard FROM characters WHERE id = $1`, s.charID).Scan(&stamps)
bf.WriteUint16(stamps)
stamps += pkt.Stamps
bf.WriteUint16(stamps)
s.server.db.Exec(`UPDATE characters SET stampcard = $1 WHERE id = $2`, stamps, s.charID)
if stamps%30 == 0 {
bf.WriteUint16(2)
bf.WriteUint16(pkt.Reward2)
bf.WriteUint16(pkt.Item2)
bf.WriteUint16(pkt.Quantity2)
addWarehouseGift(s, "item", mhfpacket.WarehouseStack{ItemID: pkt.Item2, Quantity: pkt.Quantity2})
} else if stamps%15 == 0 {
bf.WriteUint16(1)
bf.WriteUint16(pkt.Reward1)
bf.WriteUint16(pkt.Item1)
bf.WriteUint16(pkt.Quantity1)
addWarehouseGift(s, "item", mhfpacket.WarehouseStack{ItemID: pkt.Item1, Quantity: pkt.Quantity1})
} else {
bf.WriteBytes(make([]byte, 8))
}
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
}
func handleMsgMhfStampcardPrize(s *Session, p mhfpacket.MHFPacket) {}

View File

@@ -52,20 +52,20 @@ func handleMsgMhfCheckDailyCafepoint(s *Session, p mhfpacket.MHFPacket) {
s.logger.Fatal("Failed to get daily_time savedata from db", zap.Error(err))
}
var bondBonus, pointBonus, dailyQuests uint32
var bondBonus, bonusQuests, dailyQuests uint32
bf := byteframe.NewByteFrame()
if t.After(dailyTime) {
addPointNetcafe(s, 5)
s.server.db.Exec("UPDATE characters SET daily_time=$1 WHERE id=$2", midday, s.charID)
bondBonus = 5 // Bond point bonus quests
bonusQuests = 3 // HRP bonus quests?
dailyQuests = 1 // Daily quests
s.server.db.Exec("UPDATE characters SET daily_time=$1, bonus_quests = $2, daily_quests = $3 WHERE id=$4", midday, bonusQuests, dailyQuests, s.charID)
bf.WriteBool(true) // Success?
bondBonus = 5 // Bond point bonus quests
pointBonus = 3 // HRP bonus quests?
dailyQuests = 1 // Daily quests
} else {
bf.WriteBool(false)
}
bf.WriteUint32(bondBonus)
bf.WriteUint32(pointBonus)
bf.WriteUint32(bonusQuests)
bf.WriteUint32(dailyQuests)
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
}

File diff suppressed because one or more lines are too long

View File

@@ -158,7 +158,9 @@ func handleMsgSysEnterStage(s *Session, p mhfpacket.MHFPacket) {
if s.stageID == "" {
s.stageMoveStack.Set(pkt.StageID)
} else {
s.stage.Lock()
s.stage.reservedClientSlots[s.charID] = false
s.stage.Unlock()
s.stageMoveStack.Push(s.stageID)
s.stageMoveStack.Lock()
}