mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
guild enumeration improvements
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -1710,11 +1709,7 @@ func handleMsgMhfEnumerateGuildMessageBoard(s *Session, p mhfpacket.MHFPacket) {
|
||||
} else {
|
||||
bf.WriteUint32(uint32(len(likedBySlice)))
|
||||
}
|
||||
if stringsupport.CSVContains(postData.LikedBy, int(s.charID)) {
|
||||
bf.WriteBool(true)
|
||||
} else {
|
||||
bf.WriteBool(false)
|
||||
}
|
||||
bf.WriteBool(stringsupport.CSVContains(postData.LikedBy, int(s.charID)))
|
||||
bf.WriteUint32(postData.StampID)
|
||||
ps.Uint32(bf, postData.Title, true)
|
||||
ps.Uint32(bf, postData.Body, true)
|
||||
@@ -1799,24 +1794,13 @@ func handleMsgMhfUpdateGuildMessageBoard(s *Session, p mhfpacket.MHFPacket) {
|
||||
s.logger.Fatal("Failed to get guild message like data from db", zap.Error(err))
|
||||
} else {
|
||||
if likeState {
|
||||
if len(likedBy) == 0 {
|
||||
likedBy = strconv.Itoa(int(s.charID))
|
||||
} else {
|
||||
likedBy += "," + strconv.Itoa(int(s.charID))
|
||||
}
|
||||
likedBy = stringsupport.CSVAdd(likedBy, int(s.charID))
|
||||
_, err := s.server.db.Exec("UPDATE guild_posts SET liked_by = $1 WHERE post_type = $2 AND (EXTRACT(epoch FROM created_at)::int) = $3 AND guild_id = $4", likedBy, int(postType), int(timestamp), guild.ID)
|
||||
if err != nil {
|
||||
s.logger.Fatal("Failed to like guild message in db", zap.Error(err))
|
||||
}
|
||||
} else {
|
||||
likedBySlice := strings.Split(likedBy, ",")
|
||||
for i, e := range likedBySlice {
|
||||
if e == strconv.Itoa(int(s.charID)) {
|
||||
likedBySlice[i] = likedBySlice[len(likedBySlice) - 1]
|
||||
likedBySlice = likedBySlice[:len(likedBySlice) - 1]
|
||||
}
|
||||
}
|
||||
likedBy = strings.Join(likedBySlice, ",")
|
||||
likedBy = stringsupport.CSVRemove(likedBy, int(s.charID))
|
||||
_, err := s.server.db.Exec("UPDATE guild_posts SET liked_by = $1 WHERE post_type = $2 AND (EXTRACT(epoch FROM created_at)::int) = $3 AND guild_id = $4", likedBy, int(postType), int(timestamp), guild.ID)
|
||||
if err != nil {
|
||||
s.logger.Fatal("Failed to unlike guild message in db", zap.Error(err))
|
||||
@@ -1834,7 +1818,7 @@ func handleMsgMhfUpdateGuildMessageBoard(s *Session, p mhfpacket.MHFPacket) {
|
||||
if err != nil {
|
||||
s.logger.Fatal("Failed to update guild post check timestamp in db", zap.Error(err))
|
||||
} else {
|
||||
err = s.server.db.QueryRow("SELECT COUNT(*) FROM guild_posts WHERE guild_id = $1 AND (EXTRACT(epoch FROM created_at)::int) > $2", guild.ID, timeChecked).Scan(&newPosts)
|
||||
err = s.server.db.QueryRow("SELECT COUNT(*) FROM guild_posts WHERE guild_id = $1 AND (EXTRACT(epoch FROM created_at)::int) > $2 AND author_id != $3", guild.ID, timeChecked, s.charID).Scan(&newPosts)
|
||||
if err != nil {
|
||||
s.logger.Fatal("Failed to check for new guild posts in db", zap.Error(err))
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package channelserver
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"erupe-ce/common/stringsupport"
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network/mhfpacket"
|
||||
"go.uber.org/zap"
|
||||
@@ -40,20 +39,7 @@ func handleMsgMhfLoadGuildAdventure(s *Session, p mhfpacket.MHFPacket) {
|
||||
temp.WriteUint32(adventureData.Charge)
|
||||
temp.WriteUint32(adventureData.Depart)
|
||||
temp.WriteUint32(adventureData.Return)
|
||||
collected := false
|
||||
collectedBySlice := strings.Split(adventureData.CollectedBy, ",")
|
||||
for i := 0; i < len(collectedBySlice); i++ {
|
||||
j, _ := strconv.ParseInt(collectedBySlice[i], 10, 64)
|
||||
if int(j) == int(s.charID) {
|
||||
collected = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if collected {
|
||||
temp.WriteBool(true)
|
||||
} else {
|
||||
temp.WriteBool(false)
|
||||
}
|
||||
temp.WriteBool(stringsupport.CSVContains(adventureData.CollectedBy, int(s.charID)))
|
||||
}
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint8(uint8(count))
|
||||
@@ -78,11 +64,7 @@ func handleMsgMhfAcquireGuildAdventure(s *Session, p mhfpacket.MHFPacket) {
|
||||
if err != nil {
|
||||
s.logger.Fatal("Error parsing adventure collected by", zap.Error(err))
|
||||
} else {
|
||||
if len(collectedBy) == 0 {
|
||||
collectedBy = strconv.Itoa(int(s.charID))
|
||||
} else {
|
||||
collectedBy += "," + strconv.Itoa(int(s.charID))
|
||||
}
|
||||
collectedBy = stringsupport.CSVAdd(collectedBy, int(s.charID))
|
||||
_, err := s.server.db.Exec("UPDATE guild_adventures SET collected_by = $1 WHERE id = $2", collectedBy, pkt.ID)
|
||||
if err != nil {
|
||||
s.logger.Fatal("Failed to collect adventure in db", zap.Error(err))
|
||||
@@ -109,4 +91,4 @@ func handleMsgSysReserve205(s *Session, p mhfpacket.MHFPacket) {
|
||||
s.logger.Fatal("Failed to register guild adventure", zap.Error(err))
|
||||
}
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user