mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
map language to server instead of session
This commit is contained in:
@@ -142,7 +142,6 @@ func handleMsgSysLogin(s *Session, p mhfpacket.MHFPacket) {
|
||||
s.token = pkt.LoginTokenString
|
||||
s.Unlock()
|
||||
|
||||
s.dict = getLangStrings(s)
|
||||
updateRights(s)
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) // Unix timestamp
|
||||
|
||||
@@ -89,7 +89,7 @@ func handleMsgMhfGetCafeDuration(s *Session, p mhfpacket.MHFPacket) {
|
||||
}
|
||||
bf.WriteUint32(cafeTime) // Total cafe time
|
||||
bf.WriteUint16(0)
|
||||
ps.Uint16(bf, fmt.Sprintf(s.dict["cafeReset"], int(cafeReset.Month()), cafeReset.Day()), true)
|
||||
ps.Uint16(bf, fmt.Sprintf(s.server.dict["cafeReset"], int(cafeReset.Month()), cafeReset.Day()), true)
|
||||
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
package channelserver
|
||||
|
||||
import "go.uber.org/zap"
|
||||
|
||||
func getLangStrings(s *Session) map[string]string {
|
||||
var lang string
|
||||
func getLangStrings(s *Server) map[string]string {
|
||||
strings := make(map[string]string)
|
||||
err := s.server.db.QueryRow(`SELECT language FROM users, characters WHERE characters.id = $1 AND users.id = characters.user_id`, s.charID).Scan(&lang)
|
||||
if err != nil {
|
||||
s.logger.Warn("No language set for user", zap.Uint32("CID", s.charID))
|
||||
}
|
||||
switch lang {
|
||||
switch s.erupeConfig.Language {
|
||||
case "jp":
|
||||
strings["language"] = "日本語"
|
||||
strings["cafeReset"] = "%d/%dにリセット"
|
||||
|
||||
@@ -52,6 +52,9 @@ type Server struct {
|
||||
stagesLock sync.RWMutex
|
||||
stages map[string]*Stage
|
||||
|
||||
// Used to map different languages
|
||||
dict map[string]string
|
||||
|
||||
// UserBinary
|
||||
userBinaryPartsLock sync.RWMutex
|
||||
userBinaryParts map[userBinaryPartID][]byte
|
||||
@@ -164,6 +167,8 @@ func NewServer(config *Config) *Server {
|
||||
// MezFes
|
||||
s.stages["sl1Ns462p0a0u0"] = NewStage("sl1Ns462p0a0u0")
|
||||
|
||||
s.dict = getLangStrings(s)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ type Session struct {
|
||||
kqf []byte
|
||||
kqfOverride bool
|
||||
|
||||
dict map[string]string
|
||||
|
||||
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
||||
|
||||
// A stack containing the stage movement history (push on enter/move, pop on back)
|
||||
|
||||
Reference in New Issue
Block a user