[BREAKER | All Platforms] Save corrupts when deleting placed tree

Please report new found bugs in this forum and confirm that you were able to reproduce a bug.
You can find all information in "How to report a bug"
Bensterr
Posts: 37
Joined: Wed Nov 12, 2014 11:36 am

[BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Bensterr »

* BREAKER *

- PC/Mac/PS4/XB1: All
- Vehicle/Tool/Model/Object: Placeables of type 'Tree'
- Issue: When deleting a placed tree, via script or via gameplay.
- Single- or Multiplayer: Single
- Steps to reproduce: Place between 3-10 trees, using the 'FS19 MoreTree' or similar mod. Delete the tree (cut, chip, remove stump) or via script with delete(obj). On console: delete placed tree. Then save the game. The save logic will break, see attached log. This results in a CORRUPTED SAVE. All placeables stored in items.xml afterwards will not be saved. Triggers get removed, buildings go missing. Tried different tree types (fir, volumeTree, Birch, Maple) and all seem to cause the same result.
- Does it happen on a standard map without mods yes/no: Yes, but no (mod required for placing tree).
- Which vehicles & machines are involved: Placeables that are of type "tree".

:!:

2019-08-19 12:55 Warning (script): Unknown entity id 114127 in method 'getNumOfChildren'.
2019-08-19 12:55 LUA call stack:
2019-08-19 12:55 =dataS/scripts/placeables/TreePlaceable.lua (95) : getNumOfChildren
2019-08-19 12:55 =dataS/scripts/missions/mission00.lua (872) : getNeedsSaving
2019-08-19 12:55 =dataS/scripts/FSCareerMissionInfo.lua (302) : saveItems
2019-08-19 12:55 =dataS/scripts/utils/Utils.lua (381) : oldFunc
2019-08-19 12:55 =dataS/scripts/missions/SavegameController.lua (290) : saveToXMLFile
2019-08-19 12:55 =[C] (4294967295)
2019-08-19 12:55 =dataS/scripts/missions/SavegameController.lua (428) : saveWriteSavegameStart
2019-08-19 12:55 =dataS/scripts/FSBaseMission.lua (2859) : saveSavegame
2019-08-19 12:55 =dataS/scripts/FSBaseMission.lua (2217) : saveSavegame
2019-08-19 12:55 =dataS/scripts/FSBaseMission.lua (2073) : updateSaving
2019-08-19 12:55 =dataS/scripts/missions/mission00.lua (469) : update
2019-08-19 12:55 =dataS/scripts/main.lua (1879) : update
2019-08-19 12:55 Game saved successfully.
2019-08-19 12:55 Application exit request forced.

Update:
As I'm working on a mod, which uses delete(obj); to replace a placed tree with a 'planted' one, I dug in a bit and have overwritten the function. The following code seems to fix the error, note the entityExists(); but not the corruption.

Code: Select all

-- Fix for SaveGame breaking after deleting a Placed Tree
	-- TICKET: https://forum.giants-software.com/viewtopic.php?f=998&p=1174406#p1174406
	TreePlaceable.getNeedsSaving = Utils.overwrittenFunction(TreePlaceable.getNeedsSaving, function(self, superFunc)
		if entityExists(self.nodeId) then
			if getNumOfChildren(self.nodeId) == 0 or (self.splitShapeFileId ~= nil and not getFileIdHasSplitShapes(self.splitShapeFileId)) then
				-- remove placeable of all split shapes have been removed
				self:delete();
				return false;
			end;
			return TreePlaceable:superClass().getNeedsSaving(self);
		else
			return false;
		end;
    end);
  
Update 2
Weirdly enough, when comparing the items.xml from before corruption to the items.xml version after corruption, they are exactly the same (deleted tree is missing, which is valid). Although when loaded, not all placeables show - so they do not get loaded correctly. Re-saving then empties the entire items.xml
Bensterr
Posts: 37
Joined: Wed Nov 12, 2014 11:36 am

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Bensterr »

Did some more testing, today. Found out the following:

- I deleted a placed tree, by script using delete(nodeID); It was a Maple Tree, but seems to be irrelevant.
- Saved my game, then checked items.xml. I had 56 Maple Trees entries in there.
- Loaded my savegame again, but using an overwritten Placeable:loadFromXMLFile() function, logging the xmlFilename
- Log shows only 31 Maple Tree's get loaded, although the items.xml has 56.
User avatar
MAurUS
GIANTS Software | Gameplay Programmer
Posts: 133
Joined: Thu Jun 16, 2011 11:54 am
Location: ER
Contact:

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by MAurUS »

Hi Bensterr,

I just tried to reproduce the bug with this mod here: https://farming-simulator.com/mod.php?l ... tle=fs2019

For me it works without any problems. I cut the tree down, removed the stump and crushed the tree. After that I saved the game and reloaded it. Log was clear and everything in place.
Ritchie
Posts: 1490
Joined: Tue Jun 19, 2018 12:15 pm
Location: Scotland

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Ritchie »

MAurUS wrote: Thu Aug 29, 2019 10:24 am Hi Bensterr,

I just tried to reproduce the bug with this mod here: https://farming-simulator.com/mod.php?l ... tle=fs2019

For me it works without any problems. I cut the tree down, removed the stump and crushed the tree. After that I saved the game and reloaded it. Log was clear and everything in place.
You may want to speak to Lethian about this as he was able to replicate the issue and was looking in to a solution. See thread below

viewtopic.php?f=966&t=148654

I've not seen any further update on this issue. I'd suggest at the very least the "more trees" mod is removed from the Modhub until it is fixed though.
Bensterr
Posts: 37
Joined: Wed Nov 12, 2014 11:36 am

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Bensterr »

MAurUS wrote: Thu Aug 29, 2019 10:24 am Hi Bensterr,

I just tried to reproduce the bug with this mod here: https://farming-simulator.com/mod.php?l ... tle=fs2019

For me it works without any problems. I cut the tree down, removed the stump and crushed the tree. After that I saved the game and reloaded it. Log was clear and everything in place.
Hi MAurUS,

Thanks for getting back to me. I am able to reproduce it quite often, although not always. I’d say it happened 90% of the times I tried. Placing multiple trees seems to enhance the probability of it occurring. Try to place around 10-15 beech trees (volumeTree), and maybe use the MoreTree mod as these are ‘base game’ trees.

Make sure there are NO splitshapes left of the tree you’re getting rid of, when you save. I suggest using delete(nodeId) to get rid of the tree for the sake of thoroughness and speed.

It’s definitely an issue, see also the other thread Ritchie linked and try and find some other threads I came across too, with search phrase ‘Placeable missing’.

Let me know if you need more info.
Bensterr
Posts: 37
Joined: Wed Nov 12, 2014 11:36 am

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Bensterr »

Bump.

Any input or updates?
Ritchie
Posts: 1490
Joined: Tue Jun 19, 2018 12:15 pm
Location: Scotland

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Ritchie »

Bensterr wrote: Fri Sep 13, 2019 11:14 am Bump.

Any input or updates?
Have a read through the following thread, the issue has been passed to the modder to resolve.

viewtopic.php?f=963&t=152077
Bensterr
Posts: 37
Joined: Wed Nov 12, 2014 11:36 am

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Bensterr »

Ritchie wrote: Sun Sep 15, 2019 11:40 am
Bensterr wrote: Fri Sep 13, 2019 11:14 am Bump.

Any input or updates?
Have a read through the following thread, the issue has been passed to the modder to resolve.

viewtopic.php?f=963&t=152077
Cheers, thank you for the update.

Seems a bit hard to believe it's only related to the MoreTrees mod. Had a fairly close look through its files but it seems to just add a bunch of placeables with type "tree" to the store. Nothing custom, can't detect anything that's significantly different to other placeable tree mods.

I'll make my own somewhere this week and try, see if it makes a difference.
Bensterr
Posts: 37
Joined: Wed Nov 12, 2014 11:36 am

Re: [BREAKER | All Platforms] Save corrupts when deleting placed tree

Post by Bensterr »

Did some more research and it REALLY SEEMS this is NOT related to a specific mod. When comparing items.xml from before save to after save, a single <item /> (empty) entry is present. This 'used' to be the deleted tree, all <item> entries following that entry will not be loaded.

Seems to be an issue with FS.
Locked