mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
fix guild meal timer
This commit is contained in:
@@ -60,4 +60,10 @@ ALTER TABLE IF EXISTS public.users
|
|||||||
ALTER TABLE IF EXISTS public.users
|
ALTER TABLE IF EXISTS public.users
|
||||||
ALTER COLUMN return_expires TYPE TIMESTAMP WITH TIME ZONE;
|
ALTER COLUMN return_expires TYPE TIMESTAMP WITH TIME ZONE;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.guild_meals
|
||||||
|
DROP COLUMN expires;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.guild_meals
|
||||||
|
ADD COLUMN created_at TIMESTAMP WITH TIME ZONE;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
@@ -1732,10 +1732,10 @@ func handleMsgMhfCancelGuildMissionTarget(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GuildMeal struct {
|
type GuildMeal struct {
|
||||||
ID uint32 `db:"id"`
|
ID uint32 `db:"id"`
|
||||||
MealID uint32 `db:"meal_id"`
|
MealID uint32 `db:"meal_id"`
|
||||||
Level uint32 `db:"level"`
|
Level uint32 `db:"level"`
|
||||||
Expires uint32 `db:"expires"`
|
CreatedAt time.Time `db:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfLoadGuildCooking(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfLoadGuildCooking(s *Session, p mhfpacket.MHFPacket) {
|
||||||
@@ -1755,12 +1755,12 @@ func handleMsgMhfLoadGuildCooking(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if mealData.Expires > uint32(TimeAdjusted().Unix()) {
|
if mealData.CreatedAt.Add(90 * time.Minute).After(TimeAdjusted()) {
|
||||||
count++
|
count++
|
||||||
temp.WriteUint32(mealData.ID)
|
temp.WriteUint32(mealData.ID)
|
||||||
temp.WriteUint32(mealData.MealID)
|
temp.WriteUint32(mealData.MealID)
|
||||||
temp.WriteUint32(mealData.Level)
|
temp.WriteUint32(mealData.Level)
|
||||||
temp.WriteUint32(mealData.Expires)
|
temp.WriteUint32(uint32(mealData.CreatedAt.Unix()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
@@ -1772,17 +1772,19 @@ func handleMsgMhfLoadGuildCooking(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
func handleMsgMhfRegistGuildCooking(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfRegistGuildCooking(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfRegistGuildCooking)
|
pkt := p.(*mhfpacket.MsgMhfRegistGuildCooking)
|
||||||
guild, _ := GetGuildInfoByCharacterId(s, s.charID)
|
guild, _ := GetGuildInfoByCharacterId(s, s.charID)
|
||||||
|
currentTime := TimeAdjusted().Unix()
|
||||||
if pkt.OverwriteID != 0 {
|
if pkt.OverwriteID != 0 {
|
||||||
_, err := s.server.db.Exec("DELETE FROM guild_meals WHERE id = $1", pkt.OverwriteID)
|
s.server.db.Exec("UPDATE guild_meals SET meal_id = $1, level = $2, created_at = $3 WHERE id = $4", pkt.MealID, pkt.Success, currentTime, pkt.OverwriteID)
|
||||||
if err != nil {
|
} else {
|
||||||
s.logger.Error("Failed to delete meal in db", zap.Error(err))
|
s.server.db.QueryRow("INSERT INTO guild_meals (guild_id, meal_id, level, created_at) VALUES ($1, $2, $3, $4) RETURNING id", guild.ID, pkt.MealID, pkt.Success, currentTime).Scan(&pkt.OverwriteID)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_, err := s.server.db.Exec("INSERT INTO guild_meals (guild_id, meal_id, level, expires) VALUES ($1, $2, $3, $4)", guild.ID, pkt.MealID, pkt.Success, TimeAdjusted().Unix())
|
bf := byteframe.NewByteFrame()
|
||||||
if err != nil {
|
bf.WriteUint16(1)
|
||||||
s.logger.Error("Failed to register meal in db", zap.Error(err))
|
bf.WriteUint32(pkt.OverwriteID)
|
||||||
}
|
bf.WriteUint32(uint32(pkt.MealID))
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, []byte{0x01, 0x00})
|
bf.WriteUint32(uint32(pkt.Success))
|
||||||
|
bf.WriteUint32(uint32(currentTime))
|
||||||
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfGetGuildWeeklyBonusMaster(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfGetGuildWeeklyBonusMaster(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
|||||||
Reference in New Issue
Block a user