peter1138 wrote:DaleStan wrote:Why is that action 2 so much harder than any other? I'm pretty sure I haven't had to change the Varaction 2 parser in NFORenum (except for adding more variables and/or operations) since July of 2005.
NFORenum doesn't have to do anything with the data.
In basically the same sense that Open doesn't have to do anything with the data. Actually executing the thing is blasted easy. Parsing it is the hard part. This is, after all, why Open parses the actions into its own internal format, isn't it?
NFORenum has to find all the <set-id> entities, as well as <default>. To do this, it has to first find <nvar>, to determine how many <set-id>s to read before reading <default>. And <nvar> isn't at all easy to find:
1) Check <var> to determine if it is followed by <param> or <shift>.
2) Check <shift> and <type> to determine the width of <varadjust>.
3) Check <shift> again, to determine whether <varadjust> is followed by <nvar> or <op>.
4) If followed by <op>, go to the next byte and proceed at 1.
While all this is going on, NFORenum also checks all <var>s, <param>s, and <op>s for validity, even to the extent of disallowing the operation 10 for varactions that are neither type 81/85/89 industry 2s nor type 82/86/8A industry tile 2s and checking that the parameter for var 7E is a defined ID. It also objects if it finds extraneous trailing bytes.
Except for the different variables, there's nothing in those var action 2s that wouldn't be valid for vehicles or stations. Yeah, one of them's 226 bytes long, but that's just long, not invalid.
peter1138 wrote:NewSignals also doesn't appear to follow the usual action 1/2/3 format and relies on action 5...
Well, the action 2 returns a callback result, not a sprite. This is not unprecedented. There are, in fact, several other generic callbacks: 18, 33, 34, and 144. The index-into-action-5-block is strange, but doesn't seem like it's the end of the world. I'll grant the multiple action-5 blocks thing is interesting, though.
JGR wrote:Another issue is that the parametrised vars basically dump bits of L5 and L3 (and I'm not sure about OTTD<-->TTDP compatibility there).
Pretty good, I expect. The information all still has to be there, after all. Surely it can't be as bad as the 80+x vehicle variables.