mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
map language to server instead of session
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
Host string `mapstructure:"Host"`
|
Host string `mapstructure:"Host"`
|
||||||
BinPath string `mapstructure:"BinPath"`
|
BinPath string `mapstructure:"BinPath"`
|
||||||
|
Language string
|
||||||
DisableSoftCrash bool // Disables the 'Press Return to exit' dialog allowing scripts to reboot the server automatically
|
DisableSoftCrash bool // Disables the 'Press Return to exit' dialog allowing scripts to reboot the server automatically
|
||||||
FeaturedWeapons int // Number of Active Feature weapons to generate daily
|
FeaturedWeapons int // Number of Active Feature weapons to generate daily
|
||||||
HideLoginNotice bool // Hide the Erupe notice on login
|
HideLoginNotice bool // Hide the Erupe notice on login
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
BEGIN;
|
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS public.users
|
|
||||||
ADD COLUMN IF NOT EXISTS language text NOT NULL DEFAULT 'en';
|
|
||||||
|
|
||||||
END;
|
|
||||||
@@ -142,7 +142,6 @@ func handleMsgSysLogin(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.token = pkt.LoginTokenString
|
s.token = pkt.LoginTokenString
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
|
|
||||||
s.dict = getLangStrings(s)
|
|
||||||
updateRights(s)
|
updateRights(s)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) // Unix timestamp
|
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.WriteUint32(cafeTime) // Total cafe time
|
||||||
bf.WriteUint16(0)
|
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())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
package channelserver
|
package channelserver
|
||||||
|
|
||||||
import "go.uber.org/zap"
|
func getLangStrings(s *Server) map[string]string {
|
||||||
|
|
||||||
func getLangStrings(s *Session) map[string]string {
|
|
||||||
var lang string
|
|
||||||
strings := make(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)
|
switch s.erupeConfig.Language {
|
||||||
if err != nil {
|
|
||||||
s.logger.Warn("No language set for user", zap.Uint32("CID", s.charID))
|
|
||||||
}
|
|
||||||
switch lang {
|
|
||||||
case "jp":
|
case "jp":
|
||||||
strings["language"] = "日本語"
|
strings["language"] = "日本語"
|
||||||
strings["cafeReset"] = "%d/%dにリセット"
|
strings["cafeReset"] = "%d/%dにリセット"
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ type Server struct {
|
|||||||
stagesLock sync.RWMutex
|
stagesLock sync.RWMutex
|
||||||
stages map[string]*Stage
|
stages map[string]*Stage
|
||||||
|
|
||||||
|
// Used to map different languages
|
||||||
|
dict map[string]string
|
||||||
|
|
||||||
// UserBinary
|
// UserBinary
|
||||||
userBinaryPartsLock sync.RWMutex
|
userBinaryPartsLock sync.RWMutex
|
||||||
userBinaryParts map[userBinaryPartID][]byte
|
userBinaryParts map[userBinaryPartID][]byte
|
||||||
@@ -164,6 +167,8 @@ func NewServer(config *Config) *Server {
|
|||||||
// MezFes
|
// MezFes
|
||||||
s.stages["sl1Ns462p0a0u0"] = NewStage("sl1Ns462p0a0u0")
|
s.stages["sl1Ns462p0a0u0"] = NewStage("sl1Ns462p0a0u0")
|
||||||
|
|
||||||
|
s.dict = getLangStrings(s)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ type Session struct {
|
|||||||
kqf []byte
|
kqf []byte
|
||||||
kqfOverride bool
|
kqfOverride bool
|
||||||
|
|
||||||
dict map[string]string
|
|
||||||
|
|
||||||
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
semaphore *Semaphore // Required for the stateful MsgSysUnreserveStage packet.
|
||||||
|
|
||||||
// A stack containing the stage movement history (push on enter/move, pop on back)
|
// A stack containing the stage movement history (push on enter/move, pop on back)
|
||||||
|
|||||||
Reference in New Issue
Block a user