From 279d8b4aa036d8eab207250e064e91c4217387f5 Mon Sep 17 00:00:00 2001 From: Houmgaor Date: Fri, 30 Jan 2026 01:08:37 +0100 Subject: [PATCH] feat(config): add RealClientMode infrastructure for multi-version support Add client version mode support to enable version-specific behavior: - Add Mode type with constants for all game versions (S1.0 through ZZ) - Add ClientMode (string) and RealClientMode (Mode) to Config - Add ClanMemberLimits to GameplayOptions for configurable clan sizes - Add MaximumFP to GameplayOptions for festa points cap - Parse ClientMode string to RealClientMode enum in LoadConfig - Set sensible defaults (ZZ for mode, standard limits for clans) - Update config.example.json with new fields This enables cherry-picking version-specific fixes from main branch. --- config.example.json | 2 + config/config.go | 102 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 95 insertions(+), 9 deletions(-) diff --git a/config.example.json b/config.example.json index d0da91dc9..58677bc20 100644 --- a/config.example.json +++ b/config.example.json @@ -12,6 +12,7 @@ "ScreenshotAPIURL": "", "DeleteOnSaveCorruption": false, "DevMode": true, + "ClientMode": "ZZ", "DevModeOptions": { "AutoCreateAccount": true, "CleanDB": false, @@ -39,6 +40,7 @@ "DisableBoostTime": false, "BoostTimeDuration": 120, "ClanMealDuration": 3600, + "ClanMemberLimits": [[0, 30], [3, 40], [7, 50], [10, 60]], "BonusQuestAllowance": 3, "DailyQuestAllowance": 1 }, diff --git a/config/config.go b/config/config.go index 49ef92431..231185ca8 100644 --- a/config/config.go +++ b/config/config.go @@ -11,6 +11,68 @@ import ( "github.com/spf13/viper" ) +// Mode represents the client version/mode +type Mode int + +// Client version constants +const ( + S1 Mode = iota + 1 + S15 + S2 + S25 + S3 + S35 + S4 + S5 + S55 + S6 + S7 + S8 + S85 + S9 + S10 + F1 + F2 + F3 + F4 + F5 + G1 + G2 + G3 + G31 + G32 + GG + G5 + G51 + G52 + G6 + G61 + G7 + G8 + G81 + G9 + G91 + G10 + G101 + Z1 + Z2 + ZZ +) + +var versionStrings = []string{ + "S1.0", "S1.5", "S2.0", "S2.5", "S3.0", "S3.5", "S4.0", "S5.0", "S5.5", "S6.0", + "S7.0", "S8.0", "S8.5", "S9.0", "S10", "FW.1", "FW.2", "FW.3", "FW.4", "FW.5", + "G1", "G2", "G3", "G3.1", "G3.2", "GG", "G5", "G5.1", "G5.2", "G6", "G6.1", + "G7", "G8", "G8.1", "G9", "G9.1", "G10", "G10.1", "Z1", "Z2", "ZZ", +} + +func (m Mode) String() string { + if m < 1 || int(m) > len(versionStrings) { + return "Unknown" + } + return versionStrings[m-1] +} + // Config holds the global server-wide config. type Config struct { Host string `mapstructure:"Host"` @@ -24,6 +86,8 @@ type Config struct { ScreenshotAPIURL string // Destination for screenshots uploaded to BBS DeleteOnSaveCorruption bool // Attempts to save corrupted data will flag the save for deletion DevMode bool + ClientMode string // Client version string (e.g., "ZZ", "G10", "S6.0") + RealClientMode Mode // Parsed client mode for version checks DevModeOptions DevModeOptions GameplayOptions GameplayOptions @@ -63,15 +127,17 @@ type SaveDumpOptions struct { // GameplayOptions has various gameplay modifiers type GameplayOptions struct { - FeaturedWeapons int // Number of Active Feature weapons to generate daily - MaximumNP int // Maximum number of NP held by a player - MaximumRP uint16 // Maximum number of RP held by a player - DisableLoginBoost bool // Disables the Login Boost system - DisableBoostTime bool // Disables the daily NetCafe Boost Time - BoostTimeDuration int // The number of minutes NetCafe Boost Time lasts for - ClanMealDuration int // Seconds that a Clan Meal can be activated for after cooking - BonusQuestAllowance uint32 // Number of Bonus Point Quests to allow daily - DailyQuestAllowance uint32 // Number of Daily Quests to allow daily + FeaturedWeapons int // Number of Active Feature weapons to generate daily + MaximumNP int // Maximum number of NP held by a player + MaximumRP uint16 // Maximum number of RP held by a player + MaximumFP uint32 // Maximum number of Festa Points held by a player + DisableLoginBoost bool // Disables the Login Boost system + DisableBoostTime bool // Disables the daily NetCafe Boost Time + BoostTimeDuration int // The number of minutes NetCafe Boost Time lasts for + ClanMealDuration int // Seconds that a Clan Meal can be activated for after cooking + ClanMemberLimits [][]uint8 // Array of maximum Clan Members -> [[Rank, Members], ...] + BonusQuestAllowance uint32 // Number of Bonus Point Quests to allow daily + DailyQuestAllowance uint32 // Number of Daily Quests to allow daily } // Logging holds the logging configuration. @@ -232,6 +298,24 @@ func LoadConfig() (*Config, error) { c.Host = getOutboundIP4().To4().String() } + // Parse ClientMode string to RealClientMode + c.RealClientMode = ZZ // Default to ZZ + if c.ClientMode != "" { + clientModeUpper := strings.ToUpper(c.ClientMode) + for i, vs := range versionStrings { + if clientModeUpper == vs { + c.RealClientMode = Mode(i + 1) + c.ClientMode = vs // Normalize the string + break + } + } + } + + // Set default ClanMemberLimits if not configured + if len(c.GameplayOptions.ClanMemberLimits) == 0 { + c.GameplayOptions.ClanMemberLimits = [][]uint8{{0, 30}, {3, 40}, {7, 50}, {10, 60}} + } + return c, nil }