Skip to content
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

Revert string types back to system strings #499

Open
monkeyman192 opened this issue Aug 7, 2022 · 1 comment
Open

Revert string types back to system strings #499

monkeyman192 opened this issue Aug 7, 2022 · 1 comment
Assignees
Labels
feature An improvement or feature that is marked for planning and implementation..

Comments

@monkeyman192
Copy link
Owner

A while ago I made some changes to simplify how strings are handled in the .cs files: 1425662
This had implications I didn't fully realise at the time, and since then there has been numerous issues around this change.
It has been suggested we revert back to the original mechanism.
I think this should be done, but with one caveat, we introduce the Alignment attribute for strings that need it so that we continue to not need to include explicit padding bytes.

Ie.

public NMSString0x20A field_name;

will get mapped to

[NMS(Size = 0x20, Alignment = 0x8)]
public string field_name;

And

public NMSString0x10 field_name;

will get mapped to

[NMS(Size = 0x10, Alignment = 0x8)]
public string field_name;

All others will be mapped like:

public NMSString0xXYZ field_name;

to

[NMS(Size = 0xXYZ)]
public string field_name;

This will have implications to anyone using the API as the method to get the value of the string will now no longer need the .Value() call on the field.

@monkeyman192 monkeyman192 added the feature An improvement or feature that is marked for planning and implementation.. label Aug 7, 2022
@monkeyman192
Copy link
Owner Author

Ok, so after some recent discussions I think it's time to revisit this issue. There are some good benefits to implementing this, and the tools which use the exml data could utilise a simpler structure.

One issue to be overcome will be the issue of arrays or lists of strings. We'll need to add an extra attribute to accomodate this so that we can specify the length of the array as well as the length of the string.
It has been proposed that we use Size to indicate the actual size of the object within the array/list (if required), and Length or Count to indicate the number of elements in the array (Count being a bit more explicit in it's meaning and difference I guess)

So previously when we have something like

[NMS(Size=0x15)]
public NMSString0x10[] fieldName;

It will become this

[NMS(Size=0x10, Count=0x15)]
public string[] fieldName;

Similarly, lists will change like so

public List<NMSString0x10> fieldName;

to

[NMS(Size=0x10)]
public List<string> fieldName;

@monkeyman192 monkeyman192 self-assigned this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature An improvement or feature that is marked for planning and implementation..
Projects
None yet
Development

No branches or pull requests

1 participant