Skip to content

Commit 7171552

Browse files
committed
v2.2.15 - Attempted fix for 'grid-pattern'-growth problem occuring in multiplayer
1 parent ea24284 commit 7171552

5 files changed

Lines changed: 50 additions & 14 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ During a growth-cycle, crops with cause the following effects:
9292

9393
## Change-log
9494

95+
2.2.15
96+
- Attempt at fixing 'grid-pattern'-growth problem which apparently only occurred on clients in a multiplayer game.
97+
9598
2.2.14
9699
- Added Danish translation of ReadMe and 'Map Instructions' by Holse.
97100

SoilManagement/_ReadMe_DK.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xml><info>
3+
<en>Please open this document in a plain-text editor. - It is using file-extension 'XML' due to GIANTS DedicatedServerSoftware causes warnings for 'TXT' file-extensions.</en>
4+
<de>Bitte öffnen Sie dieses Dokument in einem Texteditor. - Es wird die Verwendung der Datei-Endung 'XML' aufgrund GIANTS Dedicated Server Software Warnungen verursacht für 'TXT' Datei-Erweiterungen.</de>
5+
</info><wot><![CDATA[
26
37
48
< Hvordan man bruger SoilMod i spillet - obligatorisk læsning for alle spillere!
@@ -284,4 +288,6 @@
284288
Mekanisk ukrudtsbekæmpelse forebyggelse: Michaelbjerg21978.
285289
Test Certifikat
286290
287-
Oversættelse 'DK' : Holse ( mb-mods.dk )
291+
Oversættelse 'DK' : Holse ( mb-mods.dk )
292+
293+
]]></wot></xml>

SoilManagement/_ReadMe_EN.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Note: This is a BBCode formatted text-file.
1616
[i]Remember to check the FS-UK support topic for any additional information regarding this mod[/i]
1717
1818
[b][u]Changelog[/u][/b]
19+
2.2.15
20+
- Attempt at fixing 'grid-pattern'-growth problem which apparently only occurred on clients in a multiplayer game.
21+
22+
2.2.14
23+
- Added Danish translation of ReadMe and 'Map Instructions' by Holse.
24+
1925
2.2.13
2026
- Added sanity-checking of registered 'fruits' growth-state values against their corresponding foliage-layer, to ensure that SoilMod only uses correctly registered fruits.
2127

SoilManagement/modDesc.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<contributors>sootysax, mngrazy, Gonimy_Vetrom, Iscarriah, Ziuta, DD ModPassion, Alfredo Prieto, Beowulf212, DreadX, Vanquish081, Michaelbjerg21978, Holse</contributors>
55
<FS2013_contributors>JakobT, Gonimy_Vetrom, VAHA, KingFrame, Albi, webalizer, Marxtai, Calamarain</FS2013_contributors>
66

7-
<version>2.2.14</version>
7+
<version>2.2.15</version>
88

99
<title>
1010
<en>Soil Management and Growth Control</en>

SoilManagement/soilMod/fmcGrowthControl.lua

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ fmcGrowthControl.lastGrowth = 0 -- cell
3939
fmcGrowthControl.lastWeed = 0 -- cell
4040
fmcGrowthControl.lastWeather = 0 -- cell
4141
fmcGrowthControl.lastMethod = 0
42-
fmcGrowthControl.gridPow = 5 -- 2^5 == 32
42+
fmcGrowthControl.gridPow = 6 -- 2^6 == 64
4343
fmcGrowthControl.updateDelayMs = math.ceil(60000 / ((2 ^ fmcGrowthControl.gridPow) ^ 2)); -- Minimum delay before next cell update. Consider network-latency/-updates
44-
44+
--
45+
fmcGrowthControl.debugGrowthCycle = 0
4546

4647

4748
-- These are initialized in fmcSoilMod.LUA:
@@ -88,8 +89,8 @@ function fmcGrowthControl.postSetup()
8889
fmcGrowthControl.lastWeed = fmcSettings.getKeyAttrValue("growthControl", "lastWeed", fmcGrowthControl.lastWeed )
8990
fmcGrowthControl.lastWeather = fmcSettings.getKeyAttrValue("growthControl", "lastWeather", fmcGrowthControl.lastWeather )
9091
--fmcGrowthControl.lastMethod = fmcSettings.getKeyAttrValue("growthControl", "lastMethod", fmcGrowthControl.lastMethod )
91-
fmcGrowthControl.updateDelayMs = fmcSettings.getKeyAttrValue("growthControl", "updateDelayMs", fmcGrowthControl.updateDelayMs )
92-
fmcGrowthControl.gridPow = fmcSettings.getKeyAttrValue("growthControl", "gridPow", fmcGrowthControl.gridPow )
92+
fmcGrowthControl.updateDelayMs = fmcSettings.getKeyAttrValue("growthControl", "updateBDelayMs", fmcGrowthControl.updateDelayMs )
93+
fmcGrowthControl.gridPow = fmcSettings.getKeyAttrValue("growthControl", "gridBPow", fmcGrowthControl.gridPow )
9394

9495
fmcGrowthControl.growthIntervalIngameDays = fmcSettings.getKeyAttrValue("growth", "intervalIngameDays", fmcGrowthControl.growthIntervalIngameDays )
9596
fmcGrowthControl.growthStartIngameHour = fmcSettings.getKeyAttrValue("growth", "startIngameHour", fmcGrowthControl.growthStartIngameHour )
@@ -101,14 +102,20 @@ function fmcGrowthControl.postSetup()
101102
fmcGrowthControl.lastWeed = math.floor(math.max(0, fmcGrowthControl.lastWeed))
102103
fmcGrowthControl.lastWeather = math.floor(math.max(0, fmcGrowthControl.lastWeather))
103104
fmcGrowthControl.updateDelayMs = Utils.clamp(math.floor(fmcGrowthControl.updateDelayMs), 10, 60000)
104-
fmcGrowthControl.gridPow = Utils.clamp(math.floor(fmcGrowthControl.gridPow), 1, 8)
105+
fmcGrowthControl.gridPow = Utils.clamp(math.floor(fmcGrowthControl.gridPow), 4, 8)
105106
fmcGrowthControl.growthIntervalIngameDays = Utils.clamp(math.floor(fmcGrowthControl.growthIntervalIngameDays), 1, 99)
106107
fmcGrowthControl.growthStartIngameHour = Utils.clamp(math.floor(fmcGrowthControl.growthStartIngameHour), 0, 23)
107108
fmcGrowthControl.growthIntervalDelayWeeds = math.floor(fmcGrowthControl.growthIntervalDelayWeeds)
108109

109110
-- Pre-calculate
110-
fmcGrowthControl.gridCells = math.pow(2, fmcGrowthControl.gridPow)
111-
fmcGrowthControl.gridCellWH = math.floor(g_currentMission.terrainSize / fmcGrowthControl.gridCells);
111+
fmcGrowthControl.gridCells = math.pow(2, fmcGrowthControl.gridPow)
112+
fmcGrowthControl.terrainSize = math.floor(g_currentMission.terrainSize / fmcGrowthControl.gridCells) * fmcGrowthControl.gridCells;
113+
fmcGrowthControl.gridCellWH = math.floor(fmcGrowthControl.terrainSize / fmcGrowthControl.gridCells);
114+
115+
--
116+
local fruitsFoliageLayerSize = getDensityMapSize(g_currentMission.fruits[1].id)
117+
local foliageAspectRatio = fmcGrowthControl.terrainSize / fruitsFoliageLayerSize
118+
fmcGrowthControl.gridCellWH_adjust = math.min(0.75, foliageAspectRatio)
112119

113120
--
114121
fmcGrowthControl.growthActive = fmcGrowthControl.lastGrowth > 0
@@ -119,7 +126,10 @@ function fmcGrowthControl.postSetup()
119126
end
120127

121128
--
129+
log("fruitsFoliageLayerSize=",fruitsFoliageLayerSize)
122130
log("g_currentMission.terrainSize=",g_currentMission.terrainSize)
131+
log("fmcGrowthControl.terrainSize=",fmcGrowthControl.terrainSize)
132+
log("fmcGrowthControl.gridCellWH_adjust=",fmcGrowthControl.gridCellWH_adjust)
123133
log("fmcGrowthControl.postSetup()",
124134
",growthIntervalIngameDays=" ,fmcGrowthControl.growthIntervalIngameDays,
125135
",growthStartIngameHour=" ,fmcGrowthControl.growthStartIngameHour ,
@@ -375,6 +385,11 @@ function fmcGrowthControl:update(dt)
375385
fmcGrowthControl.nextUpdateTime = g_currentMission.time + 0
376386
fmcGrowthControl.pctCompleted = 0
377387
fmcGrowthControl.growthActive = true;
388+
--
389+
if ModsSettings ~= nil then
390+
fmcGrowthControl.debugGrowthCycle = ModsSettings.getIntLocal("fmcSoilMod", "internals", "debugGrowthCycle", fmcGrowthControl.debugGrowthCycle);
391+
end
392+
--
378393
logInfo("Growth-cycle started. For day/hour:",fmcGrowthControl.lastDay ,"/",g_currentMission.environment.currentHour)
379394
elseif fmcGrowthControl.canActivateWeather and fmcGrowthControl.weatherInfo > 0 then
380395
fmcGrowthControl.canActivateWeather = false
@@ -484,7 +499,7 @@ function fmcGrowthControl:updateWeedFoliage(cellSquareToUpdate)
484499
local tries = 5
485500
local x = math.floor(fmcGrowthControl.gridCellWH * math.floor(cellSquareToUpdate % fmcGrowthControl.gridCells))
486501
local z = math.floor(fmcGrowthControl.gridCellWH * math.floor(cellSquareToUpdate / fmcGrowthControl.gridCells))
487-
local sx,sz = (x-(g_currentMission.terrainSize/2)),(z-(g_currentMission.terrainSize/2))
502+
local sx,sz = (x-(fmcGrowthControl.terrainSize/2)),(z-(fmcGrowthControl.terrainSize/2))
488503

489504
-- Repeat until a spot was found (weed seeded) or maximum-tries reached.
490505
local weedType = math.floor((math.random()*2) % 2)
@@ -588,9 +603,9 @@ end
588603
function fmcGrowthControl:updateFoliageCell(cellToUpdate, weatherInfo, day, pctCompleted, noEventSend)
589604
local x = math.floor(fmcGrowthControl.gridCellWH * math.floor(cellToUpdate % fmcGrowthControl.gridCells))
590605
local z = math.floor(fmcGrowthControl.gridCellWH * math.floor(cellToUpdate / fmcGrowthControl.gridCells))
591-
local sx,sz = (x-(g_currentMission.terrainSize/2)),(z-(g_currentMission.terrainSize/2))
606+
local sx,sz = (x-(fmcGrowthControl.terrainSize/2)),(z-(fmcGrowthControl.terrainSize/2))
592607

593-
fmcGrowthControl:updateFoliageCellXZWH(sx,sz, fmcGrowthControl.gridCellWH - 0.1, weatherInfo, day, pctCompleted, noEventSend)
608+
fmcGrowthControl:updateFoliageCellXZWH(sx,sz, fmcGrowthControl.gridCellWH, weatherInfo, day, pctCompleted, noEventSend)
594609
end
595610

596611
function fmcGrowthControl:endedFoliageCell(day, noEventSend)
@@ -606,8 +621,14 @@ function fmcGrowthControl:updateFoliageCellXZWH(x,z, wh, weatherInfo, day, pctCo
606621
return
607622
end
608623

609-
local sx,sz,wx,wz,hx,hz = x,z, wh-0.5,0, 0,wh-0.5
624+
local sx,sz,wx,wz,hx,hz = x,z, wh - fmcGrowthControl.gridCellWH_adjust,0, 0,wh - fmcGrowthControl.gridCellWH_adjust
610625

626+
--
627+
if fmcGrowthControl.debugGrowthCycle>0 then
628+
logInfo(string.format("%5.2f", pctCompleted*100),"% x/z/wh(",x,":",z,":",wh,") rect(",sx,":",sz," / ",wx,":",wz," / ",hx,":",hz,")")
629+
end
630+
--
631+
611632
if weatherInfo <= 0 then
612633
-- For each fruit foliage-layer
613634
for _,fruitEntry in pairs(g_currentMission.fmcFoliageGrowthLayers) do

0 commit comments

Comments
 (0)