NicknineTheEagle / Frostbite-Scripts

Python scripts for extracting Frostbite Engine assets
Other
87 stars 14 forks source link

Arrays of enums only show *nullEnum* #29

Closed FlashHit closed 2 years ago

FlashHit commented 2 years ago

Unverified because I couldn't use the scripts yet. I just know that this is an issue in the ebx files that are already here on github.

FB2 example (BF3 Windows): https://github.com/EmulatorNexus/Venice-EBX/blob/master/Input/InputConfiguration.txt#L8

FB3 example (BF4 Windows) (This one is pretty old): https://github.com/GreyDynamics/BF4_EBX/blob/master/gameplay/Input/InputConfigurationConsole_offset_.txt#L7

NicknineTheEagle commented 2 years ago

Post source ebx files.

FlashHit commented 2 years ago

What do you mean?

The first link is from NoFaTe btw.

NicknineTheEagle commented 2 years ago

What do you mean?

The text files you linked are converted from binary ebx format.

The first link is from NoFaTe btw.

Then why in the world are you writing this to me instead of NoFaTe? They didn't even use my scripts to convert ebx files.

FlashHit commented 2 years ago

The text files you linked are converted from binary ebx format.

Well help me with #28 and then we will see if it's maybe already fixed in this script or not. And if not then I can post the source ebx files.

Then why in the world

because I thought its the same script

FlashHit commented 2 years ago

Just created the ebx files and the txt files with your scripts. So now I have it, which files should I send? There are too many and the whole folder is too big to upload.

NicknineTheEagle commented 2 years ago

You could send the source ebx for the one you've linked, with nullenums.

FlashHit commented 2 years ago

okay https://github.com/FlashHit/Warsaw-EBX/blob/main/gameplay/Input/InputConfiguration.txt here the ebx file, can only upload it zipped: inputconfiguration.zip

FlashHit commented 2 years ago

I know it's a bit different in your script but basically instead of getting field.typeInfo.name (which is kinda similar to fieldDesc.ref I guess? maybe not.) we need field.typeInfo.elementType.name. Idk how to describe it properly. That's how it works in the Venice Unleashed modding api. So basically field.typeInfo.name returns an empty string and field.typeInfo.elementType.name would return the enum type name. (In this case: InputConceptIdentifiers)

FlashHit commented 2 years ago

or to describe it better fieldDesc.ref is 0 for all the cases where we get a *nullEnum* I just noticed that the code in if fieldDesc.ref not in self.enumerations: could do the job for these cases as well.

NicknineTheEagle commented 2 years ago

field.typeInfo.elementType.name - what's that based on? The lower 4 bits in fieldDesc.type, maybe? Or the upper bits?

NicknineTheEagle commented 2 years ago

There is a complex descriptor at position 10 at named InputConceptIdentifiers, I believe that's what DefaultExclusiveInputConcepts array is supposed to contain.

FlashHit commented 2 years ago

field.typeInfo.elementType.name - what's that based on? The lower 4 bits in fieldDesc.type, maybe? Or the upper bits?

Maybe, idk.

There is a complex descriptor at position 10 at named InputConceptIdentifiers, I believe that's what DefaultExclusiveInputConcepts is supposed to contain.

Ye that's what it should contain for sure.

NicknineTheEagle commented 2 years ago

Question is, how does it point at that complex desc? What's that Venice Unleashed modding API you were talking about?

FlashHit commented 2 years ago

Question is, how does it point at that complex? What's that Venice Unleashed modding API you were talking about?

It is a modding framework. So we can mod Battlefield 3 with a lua script.

https://docs.veniceunleashed.net/vext/ref/shared/type/fieldinformation/

NicknineTheEagle commented 2 years ago

Question is, how does it point at that complex? What's that Venice Unleashed modding API you were talking about?

It is a modding framework. So we can mod Battlefield 3 with a lua script.

https://docs.veniceunleashed.net/vext/ref/shared/type/fieldinformation/

Of course, it's closed source, why would modders ever want to share their research? Guess I'll have to figure this out myself.

FlashHit commented 2 years ago

Appreciate it 👍

FlashHit commented 2 years ago

Maybe this is useful: https://github.com/Hattiwatti/BF3MinimapGenerator/blob/master/FB%20SDK/TypeInfo.h

or this: https://www.unknowncheats.me/forum/battlefield-4/115756-just-another-more-complete-sdk-gen.html

NicknineTheEagle commented 2 years ago

Hmm, SDK structs do not directly align onto EBX binary data. This is not terribly helpful. So far, I'm clueless as to what's going on with enum arrays. fieldDesc.ref is always 0, the complex descriptor exists but there doesn't seem to be any data pointing at it.

FlashHit commented 2 years ago

Maybe you need to start at the array and not when you are already at the enum itself within that array.

In arrays we have:

field.typeInfo.array true
field.typeInfo.name ""
field.typeInfo.enum false
field.typeInfo.fields nil (empty table)
field.typeInfo.elementType (only in arrays I think)

I see that there is some kind of arrayCmplxDesc but idk if that's what is needed here.

NicknineTheEagle commented 2 years ago

Already check, there's nothing in the array info pointing at enum info either.

NicknineTheEagle commented 2 years ago

At runtime there's field.typeInfo.elementType which points at elements' type info struct but I have no idea how it's stored on disk. It should supposedly be taken from array's linked field desc which is how it works for other field types but type info index is 0 for enums in arrays. This is really strange.

NicknineTheEagle commented 2 years ago

@FlashHit Do you think you could look for enum arrays in later supported FB3 games (e.g. NFS: Payback)?

FlashHit commented 2 years ago

I don't have any newer games :/ just NFS MW, BF3 & BF4.

There is this site: https://sym.gg/databrowser/#BF1_1_Alpha/Gameplay/Input/$BF1_1_Alpha/Gameplay/Input/InputConfiguration.dice

Here it seems to be fixed.

NicknineTheEagle commented 2 years ago

There is this site: https://sym.gg/databrowser/#BF1_1_Alpha/Gameplay/Input/$BF1_1_Alpha/Gameplay/Input/InputConfiguration.dice

Here it seems to be fixed.

This is BF1, though, I haven't looked at it yet.

NicknineTheEagle commented 2 years ago

It looks like later games do have a working link to complex desc with enum names list. I checked BFV and it shows correct enum names in arrays. To be honest, I would not be surprised if enum names are really not referenced in earlier games, they're probably only used internally for debugging as the actual values are there in the array itself. Frosty Editor does show enum names in BF4 but I believe it's only because they have InputConceptIdentifiers enum declared in Frosty code itself (i.e. it has names hardcoded).

FlashHit commented 2 years ago

They use everywhere the enum names, just for the arrays it doesn't show it.

I am also wondering how it was done here: http://webx.powback.com/Games/Venice/Input/InputConfiguration.json

"DefaultExclusiveInputConcepts": {
          "$type": "InputConceptIdentifiers",
          "$array": true,
          "$value": [

So here it knows which type the array is.

This is kinda annoying.

For now I did field.value=str(compareValue)+" *unknownEnum*" instead of field.value="*nullEnum*"

NicknineTheEagle commented 2 years ago

They use everywhere the enum names, just for the arrays it doesn't show it.

Yes.

I am also wondering how it was done here: http://webx.powback.com/Games/Venice/Input/InputConfiguration.json

Peculiar, it shows enum name and but not value names in the array.

NicknineTheEagle commented 2 years ago

For now I did field.value=str(compareValue)+" unknownEnum" instead of field.value="nullEnum"

Yeah, I was thinking of something like that. I'll just slap a workaround on for now because I'm at a dead end.

NicknineTheEagle commented 2 years ago

Could you provide EBX sample from BF3, too? Just in case.

FlashHit commented 2 years ago

That's from BF3 dump: inputconfiguration.zip

FlashHit commented 2 years ago

Here is the ebx dumper that I got from NoFaTe maybe there is sth usefull in there: ebxdumper.zip

It has some nice additions I think. Like eventConnections have an eventHash and he used the eventHashes file to provide the actual name of the event as well. Here an example: https://github.com/EmulatorNexus/Venice-EBX/blob/master/Characters/Soldiers/MpSoldier.txt#L3251

NicknineTheEagle commented 2 years ago

Added a workaround in https://github.com/NicknineTheEagle/Frostbite-Scripts/commit/048ed2991722faaf5c7972bd7c0fa08d833be5b2.

NicknineTheEagle commented 2 years ago

Since workaround works, I'm closing this unless new information comes up regarding enum arrays.