mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-17 09:24:50 +01:00
Merge branch 'main' into feature/event-tent
This commit is contained in:
@@ -852,26 +852,29 @@ func handleMsgMhfGetCogInfo(s *Session, p mhfpacket.MHFPacket) {}
|
||||
|
||||
func handleMsgMhfCheckWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfCheckWeeklyStamp)
|
||||
weekCurrentStart := TimeWeekStart()
|
||||
weekNextStart := TimeWeekNext()
|
||||
var total, redeemed, updated uint16
|
||||
var nextClaim time.Time
|
||||
err := s.server.db.QueryRow(fmt.Sprintf("SELECT %s_next FROM stamps WHERE character_id=$1", pkt.StampType), s.charID).Scan(&nextClaim)
|
||||
var lastCheck time.Time
|
||||
err := s.server.db.QueryRow(fmt.Sprintf("SELECT %s_checked FROM stamps WHERE character_id=$1", pkt.StampType), s.charID).Scan(&lastCheck)
|
||||
if err != nil {
|
||||
s.server.db.Exec("INSERT INTO stamps (character_id, hl_next, ex_next) VALUES ($1, $2, $2)", s.charID, weekNextStart)
|
||||
nextClaim = weekNextStart
|
||||
lastCheck = TimeAdjusted()
|
||||
s.server.db.Exec("INSERT INTO stamps (character_id, hl_checked, ex_checked) VALUES ($1, $2, $2)", s.charID, TimeAdjusted())
|
||||
} else {
|
||||
s.server.db.Exec(fmt.Sprintf(`UPDATE stamps SET %s_checked=$1 WHERE character_id=$2`, pkt.StampType), TimeAdjusted(), s.charID)
|
||||
}
|
||||
if nextClaim.Before(weekCurrentStart) {
|
||||
s.server.db.Exec(fmt.Sprintf("UPDATE stamps SET %s_total=%s_total+1, %s_next=$1 WHERE character_id=$2", pkt.StampType, pkt.StampType, pkt.StampType), weekNextStart, s.charID)
|
||||
|
||||
if lastCheck.Before(TimeWeekStart()) {
|
||||
s.server.db.Exec(fmt.Sprintf("UPDATE stamps SET %s_total=%s_total+1 WHERE character_id=$1", pkt.StampType, pkt.StampType), s.charID)
|
||||
updated = 1
|
||||
}
|
||||
|
||||
s.server.db.QueryRow(fmt.Sprintf("SELECT %s_total, %s_redeemed FROM stamps WHERE character_id=$1", pkt.StampType, pkt.StampType), s.charID).Scan(&total, &redeemed)
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint16(total)
|
||||
bf.WriteUint16(redeemed)
|
||||
bf.WriteUint16(updated)
|
||||
bf.WriteUint32(0) // Unk
|
||||
bf.WriteUint32(uint32(weekCurrentStart.Unix()))
|
||||
bf.WriteUint16(0)
|
||||
bf.WriteUint16(0)
|
||||
bf.WriteUint32(uint32(TimeWeekStart().Unix()))
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
@@ -879,7 +882,7 @@ func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfExchangeWeeklyStamp)
|
||||
var total, redeemed uint16
|
||||
var tktStack mhfitem.MHFItemStack
|
||||
if pkt.Unk1 == 0xA { // Yearly Sub Ex
|
||||
if pkt.Unk1 == 10 { // Yearly Sub Ex
|
||||
s.server.db.QueryRow("UPDATE stamps SET hl_total=hl_total-48, hl_redeemed=hl_redeemed-48 WHERE character_id=$1 RETURNING hl_total, hl_redeemed", s.charID).Scan(&total, &redeemed)
|
||||
tktStack = mhfitem.MHFItemStack{Item: mhfitem.MHFItem{ItemID: 2210}, Quantity: 1}
|
||||
} else {
|
||||
@@ -895,7 +898,8 @@ func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf.WriteUint16(total)
|
||||
bf.WriteUint16(redeemed)
|
||||
bf.WriteUint16(0)
|
||||
bf.WriteUint32(0) // Unk, but has possible values
|
||||
bf.WriteUint16(tktStack.Item.ItemID)
|
||||
bf.WriteUint16(tktStack.Quantity)
|
||||
bf.WriteUint32(uint32(TimeWeekStart().Unix()))
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
@@ -1049,9 +1053,11 @@ func handleMsgMhfStampcardStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfStampcardStamp)
|
||||
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)
|
||||
if _config.ErupeConfig.RealClientMode >= _config.G1 {
|
||||
bf.WriteUint16(pkt.GR)
|
||||
}
|
||||
bf.WriteUint16(stamps)
|
||||
stamps += pkt.Stamps
|
||||
bf.WriteUint16(stamps)
|
||||
|
||||
@@ -7,35 +7,47 @@ import (
|
||||
"erupe-ce/network/mhfpacket"
|
||||
)
|
||||
|
||||
// Handler BBS handles all the interactions with the for the screenshot sending to bulitin board functionality. For it to work it requires the API to be hosted somehwere. This implementation supports discord.
|
||||
|
||||
// Checks the status of the user to see if they can use Bulitin Board yet
|
||||
func handleMsgMhfGetBbsUserStatus(s *Session, p mhfpacket.MHFPacket) {
|
||||
//Post Screenshot pauses till this succeedes
|
||||
pkt := p.(*mhfpacket.MsgMhfGetBbsUserStatus)
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(200)
|
||||
bf.WriteUint32(200) //HTTP Status Codes //200 Success //404 You wont be able to post for a certain amount of time after creating your character //401/500 A error occured server side
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(0)
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
// Checks the status of Bultin Board Server to see if authenticated
|
||||
func handleMsgMhfGetBbsSnsStatus(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetBbsSnsStatus)
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(200)
|
||||
bf.WriteUint32(401)
|
||||
bf.WriteUint32(401)
|
||||
bf.WriteUint32(200) //200 Success //4XX Authentication has expired Please re-authenticate //5XX
|
||||
bf.WriteUint32(401) //unk http status?
|
||||
bf.WriteUint32(401) //unk http status?
|
||||
bf.WriteUint32(0)
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
// Tells the game client what host port and gives the bultin board article a token
|
||||
func handleMsgMhfApplyBbsArticle(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfApplyBbsArticle)
|
||||
bf := byteframe.NewByteFrame()
|
||||
articleToken := token.Generate(40)
|
||||
bf.WriteUint32(200)
|
||||
bf.WriteUint32(80)
|
||||
|
||||
bf.WriteUint32(200) //http status //200 success //4XX An error occured server side
|
||||
bf.WriteUint32(s.server.erupeConfig.Screenshots.Port)
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteBytes(stringsupport.PaddedString(articleToken, 64, false))
|
||||
bf.WriteBytes(stringsupport.PaddedString(s.server.erupeConfig.ScreenshotAPIURL, 64, false))
|
||||
bf.WriteBytes(stringsupport.PaddedString(s.server.erupeConfig.Screenshots.Host, 64, false))
|
||||
//pkt.unk1[3] == Changes sometimes?
|
||||
if s.server.erupeConfig.Screenshots.Enabled && s.server.erupeConfig.Discord.Enabled {
|
||||
s.server.DiscordScreenShotSend(pkt.Name, pkt.Title, pkt.Description, articleToken)
|
||||
}
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func getPointers() map[SavePointer]int {
|
||||
pointers[pHR] = 94550
|
||||
pointers[pGRP] = 94556
|
||||
pointers[pHouseData] = 94561
|
||||
pointers[pBookshelfData] = 103928
|
||||
pointers[pBookshelfData] = 89118 // TODO: fix bookshelf data pointer
|
||||
pointers[pGalleryData] = 104064
|
||||
pointers[pGardenData] = 106424
|
||||
pointers[pRP] = 106614
|
||||
@@ -93,7 +93,7 @@ func getPointers() map[SavePointer]int {
|
||||
pointers[pToreData] = 62228
|
||||
pointers[pHR] = 62550
|
||||
pointers[pHouseData] = 62561
|
||||
pointers[pBookshelfData] = 57118 // This pointer only half works
|
||||
pointers[pBookshelfData] = 57118 // TODO: fix bookshelf data pointer
|
||||
pointers[pGalleryData] = 72064
|
||||
pointers[pGardenData] = 74424
|
||||
pointers[pRP] = 74614
|
||||
@@ -104,7 +104,7 @@ func getPointers() map[SavePointer]int {
|
||||
pointers[pToreData] = 14228
|
||||
pointers[pHR] = 14550
|
||||
pointers[pHouseData] = 14561
|
||||
pointers[pBookshelfData] = 9118 // Probably same here
|
||||
pointers[pBookshelfData] = 9118 // TODO: fix bookshelf data pointer
|
||||
pointers[pGalleryData] = 24064
|
||||
pointers[pGardenData] = 26424
|
||||
pointers[pRP] = 26614
|
||||
|
||||
@@ -311,7 +311,7 @@ func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) {
|
||||
bf.WriteBool(true)
|
||||
}
|
||||
bf.WriteUint16(0) // Unk
|
||||
if _config.ErupeConfig.RealClientMode >= _config.G1 {
|
||||
if _config.ErupeConfig.RealClientMode >= _config.G2 {
|
||||
bf.WriteUint32(mark)
|
||||
}
|
||||
bf.WriteUint16(0) // Unk
|
||||
@@ -609,7 +609,7 @@ func handleMsgMhfEnumerateQuest(s *Session, p mhfpacket.MHFPacket) {
|
||||
tuneValues = temp
|
||||
|
||||
tuneLimit := 770
|
||||
if _config.ErupeConfig.RealClientMode <= _config.F5 {
|
||||
if _config.ErupeConfig.RealClientMode <= _config.G1 {
|
||||
tuneLimit = 256
|
||||
} else if _config.ErupeConfig.RealClientMode <= _config.G3 {
|
||||
tuneLimit = 283
|
||||
|
||||
@@ -150,6 +150,9 @@ func removeSessionFromStage(s *Session) {
|
||||
|
||||
func isStageFull(s *Session, StageID string) bool {
|
||||
if stage, exists := s.server.stages[StageID]; exists {
|
||||
if _, exists := stage.reservedClientSlots[s.charID]; exists {
|
||||
return false
|
||||
}
|
||||
return len(stage.reservedClientSlots)+len(stage.clients) >= int(stage.maxPlayers)
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -367,6 +367,14 @@ func (s *Server) DiscordChannelSend(charName string, content string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) DiscordScreenShotSend(charName string, title string, description string, articleToken string) {
|
||||
if s.erupeConfig.Discord.Enabled && s.discordBot != nil {
|
||||
imageUrl := fmt.Sprintf("%s:%d/api/ss/bbs/%s", s.erupeConfig.Screenshots.Host, s.erupeConfig.Screenshots.Port, articleToken)
|
||||
message := fmt.Sprintf("**%s**: %s - %s %s", charName, title, description, imageUrl)
|
||||
s.discordBot.RealtimeChannelSend(message)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) FindSessionByCharID(charID uint32) *Session {
|
||||
for _, c := range s.Channels {
|
||||
for _, session := range c.sessions {
|
||||
|
||||
Reference in New Issue
Block a user