nwnxee / unified

Binaries available under the Releases tab on Github
https://nwnxee.github.io/unified
GNU General Public License v3.0
128 stars 91 forks source link

NWNX_Data unexpected behavior #425

Closed ELadner closed 4 years ago

ELadner commented 5 years ago

This seems like it should work, but causes the server to crash (on the very first line).

    NWNX_Data_Array_Insert_Str(OBJECT_INVALID, "test", 0, "ALCHEMY");
    NWNX_Data_Array_Insert_Str(OBJECT_INVALID, "test", 1, "ATHLETICS");
    NWNX_Data_Array_Insert_Str(OBJECT_INVALID, "test", 2, "ENCHANTING");

It seems like "Insert" expects there to be existing elements around where it's inserting, otherwise, it crashes.

Daztek commented 5 years ago

You need to call NWNX_Data_Array_Resize() first. It doesn't automatically resize the array.

The following works:

NWNX_Data_Array_Resize(NWNX_DATA_TYPE_STRING, OBJECT_INVALID, "test", 3);

NWNX_Data_Array_Insert_Str(OBJECT_INVALID, "test", 0, "ALCHEMY");
NWNX_Data_Array_Insert_Str(OBJECT_INVALID, "test", 1, "ATHLETICS");
NWNX_Data_Array_Insert_Str(OBJECT_INVALID, "test", 2, "ENCHANTING");
ELadner commented 5 years ago

Thank you, Daz!

ELadner commented 5 years ago

Could that insert be made to automatically resize?

PushBack doesn't require manual sizing...

mtijanic commented 4 years ago

Fixed in 64bit branch. Closing.