codengine / SOTFEdit

A Sons of The Forest Savegame Editor
MIT License
104 stars 6 forks source link

Max Items, unintended behaviour on cooked food #10

Closed PsyEng closed 1 year ago

PsyEng commented 1 year ago

I used the max items button and some unintended behaviour came out. I had an cooked leg, which was rotten by the time I saved (I think so) and after using the editor, it overwrite the the rotten item with an cooked item, which isn´t shown in my bagback if I open the inventory, but will show, if I open the campfire or the bagback of my friend. I will try to replicate the issue and investigate it more later and update the issue. If you need further information or anything else, please let me know it.

codengine commented 1 year ago

Hi, did I get it right - it was overwritten while you had it in the inventory? Could you also tell me which version you used?

PsyEng commented 1 year ago

Exactly. I had one in my inventory, which was rotten (I´m pretty sure it was) and then I hit the max items button, load the save and then it showed me two legs, which was cooked, but one was rotten in fact. I use the latest version 0.9.2I´m taking my meal now and will try to replicate the issue later this evening and report back.

codengine commented 1 year ago

The thing is - the data model behind "meat" and "fish" is a bit ... complicated. I had to implement some special tricks for the drying rack and shelves (fish and meat will stay as it is there).

So yeah I must have forgotten to take care about the inventory. I'll plan a fix but I can not guarantee if it makes it into the next version.

Thanks anyway for the report :)

codengine commented 1 year ago

I will add a fix in the next release. It will not be perfect because it will just add some kind of meat/fish/legs etc. but at least it will be usable again. A proper fix will follow afterwards where you can select how many rotten/spoiled/cooked things you have.

PsyEng commented 1 year ago

Sry, I didn´t get the time yesterday to answer.

I investigated and tested a little bit arround and think, I´ve some good/useful informations for you. Meat is really easy, also fish should be the same, but I didn´t explicitly tested it, because I´m in the winter season and there´s no fish around me.

The structure of meat is like this:

{
    "ItemId": 433,
    "TotalCount": 3,                                    # Count of all items (raw, spoiled, cooked, but not equipped)
    "UniqueItems": [        
        {
            "Modules": [                                # Each piece of item has it´s own module
                {
                    "CurrentState": 3,                  # State in which the item is (1: raw, 3: rotten/spoiled, 5: cooked)
                    "ModuleId": 3,                      # ModuleId 3 is the state of the item
                    "TimeRemainingInState": -1.0,       # Time in seconds, till it spoils, negative tell´s it´s spoiled
                    "Version": "0.0.0"
                }
            ]
        },
        {
            "Modules": [
                {
                    "CurrentState": 5,
                    "ModuleId": 3,
                    "PauseDecay": true,                 # Only used, if it was on a drying rack
                    "TimeRemainingInState": 86400.0,
                    "Version": "0.0.0"
                }
            ]
        },
        {
            "Modules": [
                {
                    "CurrentState": 1,
                    "ModuleId": 3,
                    "TimeRemainingInState": 761.315063,
                    "Version": "0.0.0"
                }
            ]
        }
    ]
}

The structure of arms/legs is like this:

{
    "ItemId": 480,
    "TotalCount": 2,
    "UniqueItems": [
        {
            "Modules": [
                {
                    "SourceActorType": 13,
                    "Version": "0.0.0",
                    "ModuleId": 1       # ModuleId 1 is the source from where the piece/item is coming from (cannibal, etc.)
                },
                {
                    "CurrentState": 5,
                    "TimeRemainingInState": 59395.4141,
                    "Version": "0.0.0",
                    "ModuleId": 3
                },
                {
                    "Version": "0.0.0"
                },
                {
                    "AmmoType": 480,
                    "CurrentAmmo": 1,
                    "WeaponModIds": [],
                    "Version": "0.0.0",
                    "ModuleId": 4       # ModuleId 4 is for previously equipped or rotten/spoiled items, only force-needed for rotten/spoiled items
                }
            ]
        }
    ]
}

Please consider, that my format/structure is not the same, which your code produces or you use!

Hopefully this helps you a little bit with your code. If you need any further informations/help, let me know it.

I´m not familiar with C#, C++ or any other programming language, but have some skills with Python, Bash and PowerShell, most part with scripting and not programming, so please be aware, that I couldn´t spend some code, but I´m able to debug the basics of the most parts for your code to give you hint´s or so on.

codengine commented 1 year ago

Yeah I have no headaches about meat and fish, in fact the same problem exists for Shelves as well. I came up now with a solution like this: grafik

I can do the same for Legs and Arms but only with the trade-off that I will select a default cannibal-type as the origin. The editor would just get too complex for a niche function if the user was able to select stuff like the cannibal type where they came from.

codengine commented 1 year ago

I think Module 4 is not necessary because the state (rotten, cooked) is determined by CurrentState in module 3. Could you try what happens if you remove module 4?

PsyEng commented 1 year ago

I think Module 4 is not necessary because the state (rotten, cooked) is determined by CurrentState in module 3. Could you try what happens if you remove module 4?

You´re right. Module 4 isn´t necessary, it works fine without.

I made a patch to add support for the legs and arms. I´m also sure, that all was fine before, but the arms/legs are so close together in the inventory, that I wasn´t able to select the rotten one and in the inventory, if you hover over one of the legs/arms, it shows 2 items, even if they´re separated.

codengine commented 1 year ago

That already helps :) Thanks. As I've written in the PR, I need to add some more code until one can use it.

PsyEng commented 1 year ago

You´re welcome :) If you need any further help, let me know it and I will show what I can do. Also I can review the german translation, if it´s necessary. Will close the issue, since it´s merged, if there´s anything else, we can reopen it.

codengine commented 1 year ago

You are welcome to join the discord. There is dev talk, research and information about progress and such.