Split ClientConfig off of ServerConfig and synchronize upon joining Server#130
Split ClientConfig off of ServerConfig and synchronize upon joining Server#130skorpnok wants to merge 1 commit into
Conversation
Synchronize runtime ServerConfig with Server when joining fix some behaviours getting added twice
📝 WalkthroughWalkthroughThis PR separates client-side and server-side configuration into distinct structures. A new ChangesConfig Architecture Separation
Sequence Diagram(s)sequenceDiagram
participant Server
participant Client
participant ConfigLoader
participant WorldState
Server->>ConfigLoader: Load ServerConfig from SmithingPlus.json
Client->>ConfigLoader: Load ClientConfig from SmithingPlusClient.json
Server->>Server: Core.Start copies LocalConfig to Config
Server->>WorldState: Serialize Config to world tree attributes
Client->>WorldState: Deserialize Config from world tree attributes
Client->>Client: Use CConfig for display, Config for mechanics
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
SmithingPlus/Util/TreeAttributeSerialize.cs (1)
12-13: ⚡ Quick winGuard against indexers and read-only/write-only properties.
GetProperties()returns every public property. Today the only non-{get;set;}member ofServerConfigis the computedstring[] GetToolRepairForgettableAttributes, which is skipped only because its type isn't matched. If anyone later adds a computedbool/int/float/stringproperty (e.g. a derived flag),FromTreeAttributeswill callSetValueon a get-only property and throw at mod load. Filtering onCanRead/CanWrite(and indexer params) makes this reusable utility safe.♻️ Proposed guard
- foreach (PropertyInfo fi in typeof(T).GetProperties()) - { + foreach (PropertyInfo fi in typeof(T).GetProperties()) + { + if (!fi.CanRead || !fi.CanWrite || fi.GetIndexParameters().Length > 0) continue; var type = fi.PropertyType;Apply the same guard in both
ToTreeAttributesandFromTreeAttributes.Also applies to: 30-31
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@SmithingPlus/Util/TreeAttributeSerialize.cs` around lines 12 - 13, When iterating properties in ToTreeAttributes and FromTreeAttributes, guard against indexers and read-only/write-only properties by only processing properties where PropertyInfo.CanRead and PropertyInfo.CanWrite are true and PropertyInfo.GetIndexParameters().Length == 0; update the foreach over typeof(T).GetProperties() in both methods (and any other similar loops) to skip properties that fail these checks so SetValue/GetValue is never called on indexers or get-only/write-only properties.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@SmithingPlus/Util/TreeAttributeSerialize.cs`:
- Around line 12-13: When iterating properties in ToTreeAttributes and
FromTreeAttributes, guard against indexers and read-only/write-only properties
by only processing properties where PropertyInfo.CanRead and
PropertyInfo.CanWrite are true and PropertyInfo.GetIndexParameters().Length ==
0; update the foreach over typeof(T).GetProperties() in both methods (and any
other similar loops) to skip properties that fail these checks so
SetValue/GetValue is never called on indexers or get-only/write-only properties.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8e6ec8be-7cb3-40d5-a41b-320696a18baf
📒 Files selected for processing (9)
SmithingPlus/CastingTweaks/ToolMoldUnitsPatch.csSmithingPlus/ClientTweaks/AnvilRecipeSelectorPatch.csSmithingPlus/Config/ClientConfig.csSmithingPlus/Config/ConfigLoader.csSmithingPlus/Config/ServerConfig.csSmithingPlus/Core.csSmithingPlus/ToolRecovery/CollectibleBehaviorBrokenToolHead.csSmithingPlus/ToolRecovery/CollectibleBehaviorRepairableTool.csSmithingPlus/Util/TreeAttributeSerialize.cs
💤 Files with no reviewable changes (1)
- SmithingPlus/CastingTweaks/ToolMoldUnitsPatch.cs
Synchronize runtime ServerConfig with Server when joining.
fix some behaviours getting added twice.
Fixes #129 and probably other desync related bugs. Also fixes some of the double tooltip errors.
When no client config is found it tries to load the client values from the old shared SmithingPlus.json to create the new client config.
Summary by CodeRabbit
New Features
Refactor