Repository navigation
Fix ACE.Adapter conversion bugs and add round-trip tests - #4551
Merged
Merged
Conversation
Converting content out to Lifestoned/GDLE JSON and back lost or changed data in six places: - Weenie export threw NullReferenceException, and failed the whole weenie, when any attribute or max vital was missing. Each is now looked up once and left null when absent; import already skips nulls. - Emote item details were exported only when DestinationType was set. They are now exported when WeenieClassId is set too. - FloatStat.Value, EmoteAction.FMin/FMax/Percent and Skill.LastUsed were float in the GDLE models but double in ACE. They are now double and the narrowing casts are gone. - Duplicate DID keys imported as duplicate rows when correctForEnumShift was false. - Bool recipe requirement messages were not exported. - Recipe mods with no typed rows had no slot and were dropped on export. They now take the first free slot for their ExecutesOnSuccess value, after mods with typed rows are placed. Adds ACE.Adapter.Tests: a reflection-driven round-trip sweep over the six two-way converter pairs, run with bools seeded true and false, plus one probe per fix and a JSON round trip. 23 tests pass; 15 fail against the unfixed converters. Adds the project to ACE.sln and the AppVeyor test script, and references Appveyor.TestLogger from ACE.DatLoader.Tests like the other test projects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LtRipley36706
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix ACE.Adapter conversion bugs and add round-trip tests
The problem
ACE.Adapterconverts world content between ACE's database models and the Lifestoned and GDLE JSON formats. The Developer commands/import-json,/export-jsonand/export-json-foldersuse it. Every converter ends incatch { return false; }, so when one fails the command reports only "Failed to convert", with no reason.Converting content out and back in again loses or changes data in several places:
FirstOrDefault(...).InitLeveland no null check. A missing one threw aNullReferenceException, and the whole weenie failed. Doors and chests that carry only MaxHealth are typical.DestinationType. The export only wrote the item's WCID, stack size, palette and shade when a destination was set, but the import reads them whenever they are present.FloatStat.Value,EmoteAction.FMin/FMax/PercentandSkill.LastUsedasfloat, while ACE stores all of them asdouble. A value of 0.1 comes back as 0.10000000149. ForInqFloatStatemotes this can flip a boundary check:EmoteManagertestsstat >= MinDbl, so a property of exactly 0.1 fails a minimum that was 0.1 before the round trip.correctForEnumShiftwas true.BoolRequirement.Message; the export never wrote it.The fix
LifestonedConverter): two helpers,ToAttributeandToVital, find each row once and returnnullwhen it is absent. The import already skips null entries, so an absent attribute comes back absent instead of as a zero row. This also replaces 27 list searches per weenie with 9.LifestonedConverter): item details are exported whenWeenieClassIdorDestinationTypeis set.FloatStat,EmoteAction,Skill,LifestonedConverter): the four model properties are nowdouble/double?, and the casts to float on export are removed. JSON numbers carry no type, so existing files load unchanged. No code outsideACE.Adapteruses these properties.LifestonedConverter): thecorrectForEnumShift == falsepath skips a key that is already present, like the other path and every other stat list.GDLEConverter): exported.GDLEConverter): a mod with no typed rows takes the first free slot for itsExecutesOnSuccessvalue (0-3 on success, 4-7 on failure). Mods with typed rows are placed first, so an untyped mod cannot take a slot a typed mod needs.One behaviour change in the export: a weenie with attributes but no vitals used to export
health,staminaandmanaobjects full of zeros. It now leaves them out. Importing the JSON gives the same result as before, becauseAttributeSetcreates default vitals when they are absent. That default, which gives such a weenie three zero-valued vital rows on import, is unchanged here. Changing it would alter how existing Lifestoned files import.Tests
New project
Source/ACE.Adapter.Tests(MSTest, no database or dat files needed, about 200 ms):RoundTripTests): for each of the six converter pairs that exist in both directions (Weenie, Quest, Recipe, CookBook, combined recipe, landblock), the test fills an object by reflection with a distinctive non-default value in every field. It then converts the object to the external format and back, and compares the two field by field. Each pair runs twice, with every bool seeded true and then false, so a dropped flag can't hide behind its default. Doubles are seeded as N+0.1, so any narrowing to float shows up.ProbeTests): one targeted test per fix above, plus a full JSON round trip throughTryConvertACEWeenieToLSDJSONandLifestonedLoader. Two further probes cover landblock GUID reassignment and the exception recorder itself.Results:
Quest.MaxSolvesand emoteProbability). The sweep caught both.ACE.Server.Tests,ACE.Database.TestsandACE.DatLoader.Testswere not re-run; this PR doesn't change any code they test./import-jsonand/export-jsonagainst a live server and world database.Other changes
ACE.sln: addsACE.Adapter.Tests.AppVeyor/AppVeyorTestScript.bat: runsACE.Adapter.Tests.ACE.DatLoader.Tests.csproj: referencesAppveyor.TestLogger, like the other test projects. This only takes effect once DatLoader tests are added to the CI script, which this PR doesn't do, because they need retail dat files.Files
Source/ACE.Adapter/GDLE/GDLEConverter.csSource/ACE.Adapter/GDLE/Models/EmoteAction.csSource/ACE.Adapter/GDLE/Models/FloatStat.csSource/ACE.Adapter/GDLE/Models/Skill.csSource/ACE.Adapter/Lifestoned/LifestonedConverter.csSource/ACE.Adapter.Tests/(new)Source/ACE.DatLoader.Tests/ACE.DatLoader.Tests.csprojSource/ACE.slnAppVeyor/AppVeyorTestScript.bat🤖 Generated with Claude Code