How arakne/swflangloader works
Project type and purpose
• This is a Java library (not a full-stack app or microservice) whose sole purpose is to load and parse language files (SWF assets and version manifests) for the Dofus retro game. It exposes a simple API (LangLoader) that clients use to fetch typed representations of map, hint, class, NPC, etc., data.
File structure
• Top-level files: pom.xml, CI workflows, license, README.
• assets/: sample SWF and version files for each supported language.
• src/main/java/fr/arakne/swf…:
• LangLoader.java: entry point.
• loader/: strategy implementations for loading version manifests (TxtVersionsLoader, VersionsLoader) and SWF files (SwfFileLoader, AbstractSwfFile).
• parser/: low-level parser for ActionScript assignations (AssignationParser, types).
• parser/mapper/: annotation-driven hydrator that maps parsed variables to Java fields (@SwfVariable, MapperHydrator, PropertyHydrator).
• lang/…: domain-specific file models (MapsFile, HintsFile, ClassesFile, etc.) and their value objects.
• src/test/: unit tests mirroring the main packages.
README for additional insights
• Describes the high-level API: how to instantiate LangLoader, choose a language, fetch domain files, optionally configure caching or custom SWF structures.
• Mentions use of FFDec Library (external SWF decompiler) under LGPLv3.
Components
a. Main components
• LangLoader (Facade/API)
• Version Loader (TxtVersionsLoader implements VersionsLoader)
• SWF File Loader (SwfFileLoader + FFDec decompiler)
• Parser (AssignationParser)
• Mapper/Hydrator (MapperHydrator + PropertyHydrator)
• Domain Models (BaseLangFile and subtypes: MapsFile, HintsFile, ClassesFile, etc.)
• Cache Store (local filesystem)
• Remote Lang CDN (HTTP server hosting versions_xx.txt + swf/ folder)
b. Relationships & data flow
1. Client calls LangLoader →
2. LangLoader asks VersionsLoader to fetch and parse versions_<lang>.txt from the CDN →
3. For each asset SWF URL, LangLoader delegates to SwfFileLoader →
• SwfFileLoader downloads SWF → passes it to FFDec → obtains ActionScript code → returns raw assignations →
4. AssignationParser consumes raw code → emits Assignation objects →
5. MapperHydrator reads Java annotations → hydrates an instance of the appropriate BaseLangFile subtype (MapsFile, HintsFile, etc.) →
6. LangLoader returns the fully populated domain file to client.
7. Optionally, caching layer intercepts SWF downloads and/or decompiled AS files.
c. Architectural patterns & design principles
• Facade (LangLoader)
• Strategy (VersionsLoader interface, SwfFileLoader configuration)
• Annotation-driven mapping (MapperHydrator uses reflection to bind variables)
• Separation of concerns: transport (HTTP, FS), parsing, mapping, domain modeling
• Testability: clear package separation mirrors test packages.
d. Key technologies & libraries
• Java 8+; Maven
• FFDec JPEXS decompiler (external SWF parser)
• JUnit for tests; Codecov, GitHub Actions for CI.
• “Client Application”
• “LangLoader (Facade)”
• “VersionsLoader (TxtVersionsLoader)”
• “SwfFileLoader + FFDec”
• “AssignationParser”
• “MapperHydrator”
• “Domain Models (MapsFile, HintsFile, …)”
• “Local Cache (FS)”
• “Remote Lang CDN (HTTP Server)”
• API/Facade (e.g. blue)
• Loader/transport (green)
• Parsing & mapping (yellow)
• Domain models (orange)
• External systems (grey)
Final advice
• Every module in the fr.arakne.swflangloader package hierarchy.