Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

New SGA API #18

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft

New SGA API #18

wants to merge 19 commits into from

Conversation

ModernMAK
Copy link
Owner

No description provided.

ModernMAK added 18 commits June 8, 2022 14:26
To reduce the tight coupling of 'Versioned' classes and their Unversioned base; the unversioned base no longer contains any version lookups.

Instead; the APIvX protocol should be used to get/specify types that each version is expected to have

This refactoring breaks alot of the old codebase; which expected most versioned types to 'figure it out' by being passed the version and the stream

The new APIvX format should ensure that
A) modules that want to be vX compatible define their 'version' of the vX classes (vX defines a helper to determine if a module has been properly defined as an API)
A.1) While modules can be apis, the preferred method is to use APIvX objects; while following the vX module syntax format for imports
B) 'Simple' to define their own arbitrary vX formats: Simply create a class with classvars and set the classes to their appropriate hook.
C) Registering versions is done in a single location; before each individual class needed to update a lookup table with the versioned classes & there was only one global table (per class), meaning swapping the version contexts was impossible. Now, we still have one global lookup table; but it's easier to pass a version lookup table and avoid worrying about ensuring other tables are up to date

This is kinda a rant, but this is a massive API change
With tests not fully implemented for SGA, alot of functionality is broken; and the tests created need to be refactored to account for the changes
tests pass but the other archive tests should be PRd first; then cherry-picked merged into this one, and fixed for the new API
Before I was rewriting to keep versioned code together; which ill still do; but now that I see that the SGA follows a pretty straightforward layout (for v2-v9)

I think I can refactor a lot of excess code out
It still really sucks; but to avoid the problem that the OFFICIAL RELIC ARCHIVE TOOL has; each `version` reimplements it's own codebase

I get around this as much as I can with ABCs but it is ugly.

Ranting about official Archive Viewer; admittedly, they are distributed with CoH2 (and DowIII) so as long as it works for those formats; great! But then why bother supporting past formats?

Dow II (v5) is among the formats which is supported (v4 is the earliest supported according to their version-assertion logic; COH1 I assume) but the checks to support that format don't seem to line up with my own research

I'd have assumed this was because the switch to the Essence Engine (over whatever DOW1 uses) but COH2 and DOW2  both use the new Essence engine; so... ?

As an aside; that explains why DOW1's enumerations for FileStorageType are different.

I pray this is the last time I rewrite this API; I moved away from the clunky 'make no assumptions' strategy I had done before (which was very straightforward, but a lot of boilerplate) with a simple read/write at the archive level; with unpack/pack for helpers used for serializing data .

I need to get better at typing (figuring out generics of some kind) to make ArchiveABC  auto-type things like Folder/File/Drive definitions and their respective pack-aware helpers.

We also stop using those nifty ptr objects; as much as I liked the idea of 'slicing' a binary stream; it's annoying to debug, and only hides where a stream is pointing:

perhaps using a slice which only warns/errors when reading/writing outside the bounds (allowing seeks); and will only read to the 'end of the slice'
A lot of code is 'rewritten' instead of shared between versions; but I consider this a 'feature' for the most part.

I'm sure I could hack something together, but this looks much cleaner then my previous two rewrites.

Unfortunately, unlike the previous rewrites, tests were extremely broken; as 'headers' are replaced by metadata or ignored (due to being redundant).

Rather than fix them in this commit; I added the ability to test against file sources on the local machine; in other words, I can test against REAL data. Unfortunately, unless I build my own dataset, this won't be used in CI to avoid distributing relic's assets.
Most of them are going to be rewritten completely;
@ModernMAK ModernMAK changed the title Refactoring sga New SGA API Jun 12, 2022
Fix setup.cfg not using find_namespace for new 'relic' namespace package
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant