The existing Borderlands mod file formats kind of suck, so let's come up with a new one.
- They look like xml, but have completely custom escape logic (see here)
- Due to the above, very easy to "corrupt" files if you start getting into edge cases
- Not the most human readable
- Overly restrictive about what is and isn't allowed to be in a command (to try avoid the above edge cases, though it fails)
- Does not allow commands other than
set
- Treats
exec
andsay
as commands despite storing them in comments - Forces commands stored in comments to always be active
- Duplicates all enabled commands - once in the mod structure, once at the bottom
- Always saves files in system encoding - i.e. does not use utf8 (on Windows)
- No built in support for AoDK, BL3, or WL
- Very little file metadata
- Very little structure
- No built in supported game
- No built in file metadata
- No categories
- No encoding standardization
BLIMP Tags were created to address the lack of mod file metadata, and work with both formats. It could be considered an extension of these file formats, but it's not part an inherent part of them.
There are three types of programs which interact with mod files.
Consumers are the programs that take a mod files and apply it to the game. These include:
- BL2/TPS/AoDK themseleves, via
exec
commands - CommandExtensions
- OpenHotfixLoader
- BL3HM
All existing consumers parse though a mod file line by line, looking for commands. Commands are usually considered to be a line that starts with particular English words, optionally followed by some seperator character(s) and arguments. The ordering of commands may be important.
Parsers are programs which look through mod files for some more in depth data than simply the commands, but do not write back to them. These include:
- CommandExtensions
- TextModLoader
- ModCabinet
Parsers must understand the underlying mod file format, but do not need to parse it perfectly, they can discard data which is irrelevant or too difficult to parse. Parsers also need to be able to tell the difference between the existing file formats, so that they can apply the appropriate logic. All existing parsers do this by looking at the inital bytes of the file.
Editors are the programs used to create mod files. These include:
- BLCMM
- bl3hotfixmod
Strictly speaking, editors do not also need to be parsers, they simply need to be able to output a mod file. Editors must have the highest level understanding of their mod file format, so that they create them in the correct format.
Dealing with text encoding properly is complex. Unreal Engine uses utf16-le internally.
exec
commands in BL2/TPS/AoDK treat file encodings as follows. This was tested on a machine with default system encoding cp1252, so it's possible all references to that simply check the default instead.
FName
fields are ascii only, but accept utf16 as long as it's within that range.FString
fields accept accept ascii, utf16 and cp1252.- UTF8 gets interpreted as cp1252 where possible (80 -> 20AC), otherwise it's zero-padded (9D -> 009D).
- UTF16 files must contain a BOM, but can be either endianness.
CommandExtensions and TextModLoader use the system default encoding.
OpenHotfixLoader treats all files as utf8, and converts them to utf16-le in memory.
Given the above background, here are a number of proposed requirements for a new universal mod file format. These are not ordered by importance, nor are they all expected to be implemented.
- Has magic bytes at the start to identify it
- Contains explicit file encoding
- Supports UTF-16
- Based closely/entirely on existing structured data formats, such that a parser (but not necessarily an editor) can always use an existing library
- Does not get ruined by a formatter for that format
- Human readable/writeable
- Minimal formatting required for structuring - minimize extra filesize
- Expandable for future improvements
- Has BLCMM's full category system
- Contains explicit metadata section, which may contain arbitrary values
- Explicit comment/command seperation, so you can turn a comment into a command and vice versa
- Allows for arbitrary commands
- Consumers can parse commands inline
- Individual commands have an enabled state
- Supports commands which the editor converts into more complex ones rather than enabling inline (e.g. willow hotfixes, exec importing files)