Community Forum

More than 32 FoliageTypes in FoliageMultiLayer ?

Forum Overview >> Farming Simulator 19

CategoryFarming Simulator 19
Created08.03.2020 14:12

Lara Lara (LsLara) 08.03.2020 14:12
I'm currently encountering some issues on adding more fruits to my map.

As we know, out of the box FS19 will allow you to use up to 31 foliages for fruits and deco.

One limit is the channels of the fruit_density.gdm, which allows 32 index states, of which "0" is reserved for empty state.
By changing the FoliageMultiLayer description to:
numChannels="11" numTypeIndexChannels="6" compressionChannels="5"
and adapting the fruit_density.gdm accordingly, you will end up with 63 availabe slots there.

So far, so good, everything works in terms of painting in GE and foliages showing up ingame.

BUT, starting with the 33rd sequential FoliageType listed within FoliageMultiLayer onwards, I get this LOG error:
Invalid foliage type index xxx (where xxx=name of FoliageType).
When I seed these fruits ingame (seeding works and colors are shown in the field view), they will also not grow at all !

Interestingly, the 32nd foliage works perfectly, so it seems to have nothing to do with the channels limit, only with foliage count

I also adapted the custom map.lua to increase the "numFruitDensityMapChannels" to 11 (instead of regular 10), but doesn't change anything.

In fact, ingame the "fruits" themselves seem to work. All tables like g_currentMission / fruitTypeManager / fruitsList / fruits / etc. show correct data.

I'm wondering whether either the FoliageMultiLayer construction is incapable to handle more than 32 indexes by design, or there is some more hidden parameter I do not find ?
Probably it could have to do with updating / growthcontrol functions ? Maybe in FoliageTransformGroupConstructor or GroundType Manager ?

Any ideas ???

Lara Lara (LsLara) 13.03.2020 18:21

Small update after some unsuccessfull trials:

Also the fruit_density_growthState.xml of the Savegame contains only max. 32 cropsState indexes: from 0 ... 31 (omitting those layers that are deco only). But accessing "growthstatetime" inside g_fruitTypeManager shows that the timers of all additional fruits are actually counting up like normal, but still nothing is happening ingame. Changing the XML manually doesn't help either, as it will be overwritten upon game saving.

Does anybody know, how growing is actually handled by the game ??? I don't find any useful hint in the documentation.

Bilbo Beutlin (BBeutlin) 13.03.2020 18:47
If you own the FS on DVD look into folder "sdk". There's a file "densityMaps.txt".

Short extract:
Growth state (normal crops (wheat, canola, ...)):
0000 none
1000 0 (invisible)
0100 1
1100 2
0010 3
1010 4 (fully grown)
0110 5 (fully grown)
1110 6 (fully grown)
0001 7 (withered)
1001 8 (cut short)

The complete array for a default 5 typeIndexChannels is
ttttt gggg wwww
where t = typeIndex, g = growth state + extra states/fruits, w = windrow

By this pattern you see why beneath the typeIndexChannels also other channels (bits) are used. Due to that you can enhance the numTypeIndexChannels only upto a certain limit.

Lara Lara (LsLara) 14.03.2020 15:58
OK, NICE ... I didn't even notice that there is some more on the DVD than the game itself ;-)

Unfortunately, this confuses me even more now ... what are the "windrow bits" doing there, or - what is the "Foliage Density Layout" actually describing ???
When I read this, I first think about fruit_density.gdm and associated foliage layers visible in GE. Windrow stuff should be associated to terrainDetailHeight_density.gdm ?

For fruitdensity, you normally have bits 0-4 for fruit types and bits 5-9 for growth states, of which bit 9 is exclusively used for haulm foliages by use of densityMapChannelOffset=4. So far, this seems to fit, but what about additional 4 bits windrow ? Those bits are also inactive in GE.

By adding a new channel to fruitdensity, I ended up with bits 0-5 for fruit types and bits 6-10 for growth states. So far, this actually works in terms of GE and registering fruits (fruit type manager etc. looks good).

Also, there can not be any "bit overlap" on bit 5 now, as the standard fruits keep growing as normal. If there was some problem of bit 5 being interpreted as growth state instead of fruit type, then it would always be 0 on the original fruits. Consequently every 2nd growth state should't work correctly any more ? But they do.

So, my interpretaion so far is, that the channel updating did work and the game is also dynamically adapting to it in terms of fruit management.
However, there is still something else that needs to be adapted to overcome this invalidity limit ...

Am I thinking wrong somewhere ? :-(

Is there some specific timimg required as to WHEN the game is told that there are 11 instead of 10 numFruitDensityMapChannels by the custom Map.lua ? Currently, I've added this to the same section where also additional channels for terrain angles and detail height are defined. Both are working.

Bilbo Beutlin (BBeutlin) 15.03.2020 00:44
As you surely know, this part of the game engine isn't documented anywhere. So all we have are assumptions. *g*

The entire description of the fruitDensity map refers obviously to the initializing game and later savegame's "fruit_density.gdm".
I'd guess, for simplicity the internal foliage layer maps become copied into the final fruitDensity map, probably by masking out the unneeded bits.
Also only guessing, the windrow channel bits are calculated on harvesting and (later) transferred/merged into the "terrainDetailHeight_density.gdm".
In this way it is enabled the maps may have different resolutions.

I'd also assume, the initializing "mission.lua" might need additional entries to make non-default values operative.

Lara Lara (LsLara) 29.03.2020 17:57
After some more trials and digging through various LUAs without success, I came to the idea to override the built-in growth system with SEASONS.
And it works flawlessly both with foliage indexes >32 and also with total number of fruitTypes >32 !!!
The Log Error still persists, but the consequences will not take any effect thanks to using the alternate growth management.

From that, I draw the conclusions that
a) game can handle increased densityMap channels
b) game can handle more than 31 fruitTypes
c) game can handle growing more than 32 crops

So, there seems to be some kind of check when loading the foliages from I3D that will decide not to accept any index >32 - for whatever yet undisclosed detailed reason, but probably to protect some of the vanilla functions to fail.

So, there is a workaround now, but it's not yet satisfying. There should be some more simple solution, as I cannot imagine that there is some hard-coded limit - there must be some parameter / variable that can be changed to allow more indexes. Unfortunately all the relevant code / functions are not documented ;-(

Olegi4ch (Rotting_Christ) 31.08.2020 16:20
Good day! Could you tell me what lines you wrote in modmap.lua?

Note: Log in to post. Create a new account here.