-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/finish EMBI, add TGIN internal support, fix EXTN potential crash #76
Conversation
public void Serialize(UndertaleWriter writer) | ||
{ | ||
writer.WriteUndertaleString(GroupName); | ||
uint pointer1 = writer.Position; writer.Write(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stuff like this was kinda supposed to be abstracted away into UndertaleReader/Writer to not clutter up code with manual pointer magic like this... (I also have to kinda fix it a bit to better handle non-standard pointers e.g. messed up by other tools, but that's another story). You can use WriteUndertaleObjectPointer as long as you make the target implement UndertaleObject (also see my note about lists which should handle that)
uint pointer4 = writer.Position; writer.Write(0); | ||
uint pointer5 = writer.Position; writer.Write(0); | ||
|
||
SeekWritePointer(writer, pointer1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite repetitive. How about implementing something like UndertaleSimpleList that handles UndertaleResourceById instead of normal objects? UndertaleSimpleResourcesList? Could probably be used in a couple more places as well, this is not the first time we see a sequence like that.
Ugh, you may run into some problems with that since ResourceById doesn't have a default constructor. I'll try to figure it out tomorrow. |
Yeah, I was worried that was not done the greatest. I tried a bunch of different approaches but I also ran into some problems with ResourceById. |
See 3951aca and 5b036f3, they should help with a cleaner implementation. You will need to update the code as the UndertaleResourceById syntax has changed. You should now be able to simply do: SomeList = reader.ReadUndertaleObjectPointer<UndertaleSimpleResourcesList<SomeObjectType, UndertaleChunkXXXX>>();
//...
var returned = reader.ReadUndertaleObject<UndertaleSimpleResourcesList<SomeObjectType, UndertaleChunkXXXX>>();
if (returned != SomeList) throw new Exception("I need to make it check this automatically somehow but for now do it like this (UndertaleRoom works like that too)"); |
Alright, thanks. That should be pretty helpful. |
So now TGIN serialization is much better looking, thanks to that new class. However there are a few issues that may have to get fixed, for the codebase in general, about how reading of objects are done. Basically, if an object is never referred to as a pointer, then it should probably never be added to the object pool (or have anything to do with it). The reason why is because otherwise if you have an object at the start of another object, they can "overlap", and that causes errors when it tries to convert between the two types. This is easily fixed by manually initializing objects and then calling By the way- the other changes:
|
…kely what the values actually are
(just squeezed that in to satisfy the last couple comments of #70) |
Okay, so hold on a little bit. I may have just discovered a major problem... |
Phew, that's fixed now... It should be fine. |
Yeah, I know, I hit that limitation a couple of times. Having them all in the object map can be useful though, for example it's used for generating the offset map file that lists every single object read, which can aid in comparing hexdumps like we did for the two Switch versions that were almost identical. I'm still thinking of better ways to solve this, one may be to have a separate object map per object type. |
Kerning = reader.ReadUndertaleObject<UndertaleSimpleListShort<GlyphKerning>>(); | ||
} else | ||
{ | ||
Offset = reader.ReadInt32(); // Maybe? I don't really know, but this definitely used to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it was two bytes of data and two bytes of padding, or maybe the list always existed but was empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess maybe it can assume there's always a list? No real harm in doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to tell when we don't even have any examples that make use of it
} | ||
} | ||
|
||
public class GlyphKerning : UndertaleObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I guess the editor needs an update...
How many entries of this do you usually get? I'm just wondering what controls would be best for this, since now every table row can have subrows...
(and font editing for translators just got harder, ugh)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I feel stupid because I just realized none of the things I've tested on use the list at all. It doesn't really seem necessary to allocate too much space for them (if any).
Also, please let me know if I missed anything we already know about bytecode 17 that should be listed on this page: https://github.com/krzys-h/UndertaleModTool/wiki/Bytecode-17 I should probably document other recent changes like the Spine sprites, the new font things and updates do GeneralInfo and Options flags, but I guess none of these are really related to the new bytecode right? Ugh, we should seriously start writing proper documentation of the format like https://pcy.ulyssis.be/undertale/unpacking-corrected (but way more detailed, probably) instead of all these short patch documents |
Co-Authored-By: colinator27 <[email protected]>
Co-Authored-By: colinator27 <[email protected]>
Sorry for making these several commits, but I'm far too lazy to do it the proper way. Co-Authored-By: colinator27 <[email protected]>
Co-Authored-By: colinator27 <[email protected]>
I was about to say that this suggestion feature really needs a way to accept multiple suggestions in one commit but...
|
Wait, what?? I saw that button but it was grayed out... |
No idea, this was the first time I used that feature, I don't even know how it looks on your side :P |
Is this resolved? |
If so, it should be closed. |
Exactly as the title says. This should fix a whole lot, including an oversight with EXTN I made. Apparently "product ID" only happens on newer games... (probably 1.4.9999 and 2+)