chrxh / alien

ALIEN is a CUDA-powered artificial life simulation program.
https://alien-project.org
BSD 3-Clause "New" or "Revised" License
4.69k stars 141 forks source link

Can't read from files #47

Closed coderguy57 closed 2 years ago

coderguy57 commented 2 years ago

When ever I try to open an simulation I get 'The selected file could not be opened.' It is cause the Serializer::deserializeDataDescription throws "no data found". Any idea why it does this?

chrxh commented 2 years ago

What system are you using (Win/Linux/Mac)? Which file exactly did you try to open?

coderguy57 commented 2 years ago

Running Ubuntu 20.04. I get the same result for all '.sim' files

chrxh commented 2 years ago

Is the default simulation (https://github.com/chrxh/alien/blob/develop/img/screenshot1.png) loaded at the first start or do you just see a blank background?

If not I can think of 2 error causes:

chrxh commented 2 years ago

Could you please try the following:

  1. Change the following code block in Serializer.cpp https://github.com/chrxh/alien/blob/develop/source/EngineInterface/Serializer.cpp#L157-L170 to (this changes deactivates the decompression.)

        {
            std::ifstream stream(filename, std::ios::binary);
            if (!stream) {
                return false;
            }
            deserializeDataDescription(data.content, stream);
            stream.close();
    
        }
  2. Compile, start the program and load the attached simulation (this sim-file is uncompressed) test_sim.zip

If this works, the problem would be a cross-platform issue with the (de)compression.

coderguy57 commented 2 years ago

Yep that worked. Thx !! We know that's the problem, I can look into why it compression libs don't work

chrxh commented 2 years ago

Thanks, that would be great! Maybe some byte ordering Win vs Linux problem.... ?!

If the problem can't be solved so easily, I could also take out the compression for now (or use other lib) and resave all examples. The files are then unfortunately about twice as large :-/

Note: With the correction above, however, only the deserialization is done without compression. For saving it is still activated.

chrxh commented 2 years ago

I'm currently trying to use zstr/zlib for compression. It would be great if you could try if it works? The source code is in the branch features/zlib. Here is the simulation file for testing: zlib_test.zip

coderguy57 commented 2 years ago

Yep, that worked perfectly! You don't happen to have a discord or slack for the project?

chrxh commented 2 years ago

Thanks for testing! I've now converted all examples and changed the Serializer.cpp completely to the new format. It's now on the develop branch. There is a subreddit for this project at https://www.reddit.com/r/AlienProject. I'd not created a discord or related yet. The development of this project kept me very busy the last few months (and as a result the new version 3.0 will be ready very soon :) .Then I hope to have more time for such things.

chrxh commented 2 years ago

I close this issue. If there are further problems with the file format please let me know.