SiegeEngineers / auto-mods

some data mods, generated programmatically, so they can be recreated automagically for every new patch
MIT License
18 stars 11 forks source link

Output .dat file seems corrupted #15

Closed BenjaminHau closed 3 years ago

BenjaminHau commented 3 years ago

Hello, I've been trying to run this script in order to create my own automated mod.

I followed the instructions on how to run this on Ubuntu, they worked great for installing the dependencies and compiling. However when I run it, I either encounter an error, or the code executes fine but then the output data file can't be opened with Advanced Genie Editor, whereas the original 'empires2_x2_p1.dat' can without problem.

Examples of what I tried:

Result:

Loading ../../empires2_x2_p1.dat... Terrains: 200 Applying the following modifications in order: x3 terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 0) Aborted (core dumped)

Result:

Loading ../../empires2_x2_p1.dat... Terrains: 200 Applying the following modifications in order: random-costs terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 18446744073709538561) >= this->size() (which is 1701) Aborted (core dumped)

Result:

Loading ../../empires2_x2_p1.dat... Terrains: 200 Applying the following modifications in order: Unknown mod identifier: '' Unknown mod identifier: '' Saving as ../../test.dat... Terrains: 200 Done.

The execution seemed successful, but then I noticed that the saved 'test.dat' is different from the original 'empires2_x2_p1.dat'. The first one being at 3731Ko and the second one at 4065Ko, so clearly they're different. On top of that, when I try to open test.dat with the Advanced Genie Editor, this is what I get: age

I'm wondering if you also encounter the same issue in your environment with the latest AOE2DE patch. I've tried running your code on both Windows and Ubuntu and some behaviors were different but the simple loading/saving gave the same result as shown above on both OS.

Do you have any idea of what I can try to make it work?

I appreciate your help.

HSZemi commented 3 years ago

There is a genieutils update required to work with dat files from the latest patch. I just pushed the necessary changes. If you run git pull --recurse-submodules in your checkout, it should pull the change and update the genieutils submodule, and compilation and application should work again.

BenjaminHau commented 3 years ago

Thanks a lot! I haven't managed to build yet. First I had to install liblz4 using sudo apt-get install liblz4-dev, but I still get the error:

auto-mods/genieutils/src/resource/SlpFile.cpp:91:22: error: ‘LZ4_decompress_safe’ was not declared in this scope unpack_count = LZ4_decompress_safe(reinterpret_cast<const char *>(input.data()),

I double checked and my lz4 version (0.0~r131-2ubuntu3.1) seems to be the newest, so I don't understand this error. Does it build for you?

HSZemi commented 3 years ago

I just followed the instructions from the README in a new checkout and it built for me. If you are reusing your old build folder, that one probably contains a configuration for which LZ4 has not been included when it was created, so the required headers cannot be found during build time. This issue would be solved by deleting the build folder and executing the commands for compiling again from the start.

The liblz4-dev is indeed still missing from the build instructions, I will add it. Thanks!

BenjaminHau commented 3 years ago

I have finally managed to build and execute successfully! I fixed the problem with the file at auto-mods/genieutils/src/resource/SlpFile.cpp:91 by adding the line #include "lz4.h" after #include "lz4hc.h". LZ4_decompress_safe is declared in lz4.h, which is also included in lz4hc.h so I have no idea why I got that error, but I'd bet that the extern "C" has something to do with it. I really don't understand why it worked for you but not for me also. Anyway, I'm on the right track now, thank you so much!