Tuesday, June 3, 2014

FMod - Refactor by Triage

As I said last post, it's time to migrate to the new reflection-based configuration system. I did a little modification of the deserialization routine, moving the duplicated type branch into one method, like the serializer. I also added support for null values, which will make things a lot easier with actual use.

Abiathar has two configuration files loaded at any given time: the general editor view settings and the file-specific settings. Today, I changed the signature of the file-specific configuration file to the new config tree and deleted the XML initializer in the dependency binder class. This led, as one might imagine, to a lot of errors in the code, though not as many as I expected. Most of them appeared in the Level Inspector and Resource Accountant methods, which comprise some of the most convoluted code I've ever written. I ripped out the terrible hierarchy of classes and the deserialization from super-opaque strings in the XML configuration. It was replaced with a complicated, but very easy to modify, system of configuration compounds.

Before all that, though, I tried to fix the memory-related error that caused loading of large level sets to fail. I tried various strategies to allocate more memory for Abiathar (specifically the unmanaged graphics part), including AllocHGlobal. That didn't work - threw OutOfMemoryException - so I tried P/Invoke with SetProcessWorkingSize. That also failed with some overflow error inside IntPtr. Eventually, I noticed that I had set the compiler to create a x86-only binary. After changing it to use x64 if possible, I threw in a helpful error message (instead of "error creating dependency file") to the New window and called it OK.

Tomorrow, I'm going to create some sort of event bus-based system for creating new configuration compounds (since extensions can no longer just look around the XML document and tack on entries). If that works, I may also go ahead and change everything to use FrofConf.

No comments:

Post a Comment