[SOLVED] Crop Destruction (module) does sub-optimal detection of crops

Das Forum für Fragen und Diskussionen rund um die Mobile Titel des Landwirtschafts-Simulators.
User avatar
Rahkiin
Former GIANTS employee
Posts: 753
Joined: Tue Jan 17, 2017 12:45 pm

[SOLVED] Crop Destruction (module) does sub-optimal detection of crops

Post by Rahkiin »

The CropDestruvtion:destroyFruitArea function works in a way that is suboptimal for mods that change properties of fruits (like Seasons, where we make all fruits have only 1 harvestable state).

In that function, there is a hardcoded set of actions for GRASS and OILSEEDRADISH. We have replaced that with comparisons of their properties instead, so it is more flexible. Without changes to the ingame fruits, the code works the exact same way.

Original code:

Code: Select all

...
            elseif desc.cutState < desc.minHarvestingGrowthState then
                -- grass
                setDensityCompareParams(entry.id, "between", desc.minHarvestingGrowthState+1, desc.maxHarvestingGrowthState+1);
                setDensityParallelogram(entry.id, x,z, widthX,widthZ, heightX,heightZ, 0, g_currentMission.numFruitStateChannels, desc.cutState+2);
                setDensityCompareParams(entry.id, "greater", -1);
            elseif desc.minHarvestingGrowthState == desc.maxHarvestingGrowthState then
                -- oilseed, no destruction
            else
...
Here you want to detect grass and oilseed by using their unique sets of harvesting states. This works, but not when those are not unique anymore.

New code, where the actual intent is used, by comparing the actual fruit type:

Code: Select all

...
            elseif index == FruitUtil.FRUITTYPE_GRASS then
                -- grass
                setDensityCompareParams(entry.id, "between", desc.minHarvestingGrowthState + 1, desc.maxHarvestingGrowthState + 1)
                setDensityParallelogram(entry.id, x, z, widthX, widthZ, heightX, heightZ, 0, g_currentMission.numFruitStateChannels, desc.cutState + 2)
                setDensityCompareParams(entry.id, "greater", -1)
            elseif index == FruitUtil.FRUITTYPE_OILSEEDRADISH then
                -- oilseed, no destruction
            else
...

We 'fixed' this by patching the mod when Seasons loads, but it is nasty and we would prefer the crop destruction mod to be updated.

- PC/Mac/PS4/XB1: Moddable platforms
- Vehicle/Tool/Model/Object: Giants Mod
- Issue: Implementation of CC is a bit silly
- Single- or Multiplayer: Both
- Steps to reproduce: Play seasons without the patch included, or write any other mod that does changes on harvest states of fruits.
User avatar
theSeb
Posts: 1517
Joined: Tue Mar 07, 2017 8:16 pm

Re: Crop Destruction (module) does sub-optimal detection of crops

Post by theSeb »

Also, I can assure you that my fix works 100%

*thumbsup* :lol:
User avatar
x Lethian x
Former GIANTS employee
Posts: 2190
Joined: Thu Mar 02, 2017 12:39 pm

Re: Crop Destruction (module) does sub-optimal detection of crops

Post by x Lethian x »

Hi guys!

Thanks for the report and even the offered fix! I've let the developers know of the problem with the crop destruction mod ;)

Regards,
Lethian
How to report a BUG | How to post a log file | How to upload images
fruktor
Former GIANTS employee
Posts: 109
Joined: Thu Nov 05, 2009 12:48 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by fruktor »

:hi:

well, the check does not use the exact fruit type, so that modders could insert similar fruit types if they wanted to.
One might add another type of grass (klee = clover) or another fruit type which can be used as oilseed raddish (whatever that might be).

Me, personally I don't care how we implement it in the end, just wondering if there are any 'mod fruit types' out there which fall into that range?

Cheers,
fruktor
User avatar
Rahkiin
Former GIANTS employee
Posts: 753
Joined: Tue Jan 17, 2017 12:45 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by Rahkiin »

Hello fruktor,

As far as we are aware, Seasons is the only mod doing anything interesting with the harvest states.
Maybe a hybrid solution could be to add an fruitDesc value to determine whether crops are destructed?
fruktor
Former GIANTS employee
Posts: 109
Joined: Thu Nov 05, 2009 12:48 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by fruktor »

Hi Rahkiin,

hmmm, jap. That would be an option.
But rather for FS19 than for FS17 - don't wanna brake too many mods ;)
User avatar
theSeb
Posts: 1517
Joined: Tue Mar 07, 2017 8:16 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by theSeb »

fruktor wrote:Hi Rahkiin,

hmmm, jap. That would be an option.
But rather for FS19 than for FS17 - don't wanna brake too many mods ;)
Hi Fruktor,

You raise a good point about different fruit types in the same class and having the mod work on them in the same way, but then I don't think comparing min harvest state and max harvest state is a reliable way to classify fruit types. It seems odd to me to say that if min harvest = max harvest, then it must be some type. It is limiting interesting new fruits.

Instead, I would suggest that for FS19 you consider modifying fruitUtil.fruitTypes and give fruits a "classification" value, maybe, grains, roots, grasses etc, so then mods can act on groups of fruits accordingly. *thumbsup*
Last edited by theSeb on Wed Jun 28, 2017 3:53 pm, edited 3 times in total.
User avatar
Rahkiin
Former GIANTS employee
Posts: 753
Joined: Tue Jan 17, 2017 12:45 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by Rahkiin »

Good idea! And then for now, the actual issue can be solved by using the code we suggested.

I only know of 1 mod that makes new fruit types, AdditionalMapTypes, and have not heard anyone using the min=max to prevent crop destruction, willingly.
User avatar
Rahkiin
Former GIANTS employee
Posts: 753
Joined: Tue Jan 17, 2017 12:45 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by Rahkiin »

I see there has been an update, but this bug has not been fixed.

How come?
User avatar
pfreek
GIANTS Software | Technical Projects Coordinator
Posts: 382
Joined: Mon Feb 07, 2011 12:04 pm
Location: Erlangen

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by pfreek »

fruktor wrote:Hi Rahkiin,

hmmm, jap. That would be an option.
But rather for FS19 than for FS17 - don't wanna brake too many mods ;)
It wasn't intentional to not upload your fix, but this may be the reason why.
empato
Posts: 1077
Joined: Thu Apr 27, 2017 1:27 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by empato »

Sorry, one question as layman. Is there any issue if I`m using Seasons and Crop Destruction together?
User avatar
reallogger
Posts: 537
Joined: Thu Jan 14, 2016 10:08 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by reallogger »

empato wrote:Sorry, one question as layman. Is there any issue if I`m using Seasons and Crop Destruction together?
No issues using CD and Seasons together. We have specifically made Seasons compatible with CD.
empato
Posts: 1077
Joined: Thu Apr 27, 2017 1:27 pm

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by empato »

Thanks for quick clarification!"
User avatar
pfreek
GIANTS Software | Technical Projects Coordinator
Posts: 382
Joined: Mon Feb 07, 2011 12:04 pm
Location: Erlangen

Re: [KNOWN ISSUE] Crop Destruction (module) does sub-optimal detection of crops

Post by pfreek »

It does now. :P
Post Reply