Skip to content

Commit 69b45d2

Browse files
fix(animalEvents): fall back to farmId 1 instead of 0 in getFarmId()
g_currentMission.player can be nil on certain modded maps (e.g. Judith Plains Montana 4X) at the time a wildlife event fires. The previous fallback returned farmId 0 (the FS25 spectator/no-farm slot), causing addMoney() to silently discard the transaction with no error or log. Affected events: wildlife_veterinary_visit, wildlife_stampede, wildlifeTickHandler (which already had an early-return guard for 0). Fix: return 1 as the fallback — farm 1 is always the singleplayer/host farm in FS25.
1 parent 95fc734 commit 69b45d2

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

.claude/settings.local.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Read(//usr/**)",
1919
"Read(//mingw64/**)",
2020
"Bash(/c/WINDOWS/py:*)",
21-
"Bash(sed:*)"
21+
"Bash(sed:*)",
22+
"Skill(fs25-deploy)",
23+
"Skill(fs25-log)",
24+
"Bash(gh pr:*)",
25+
"Skill(fs25-changelog)"
2226
]
2327
}
2428
}

FS25_RandomWorldEvents.zip

864 KB
Binary file not shown.

modDesc.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
22
<modDesc descVersion="92">
33
<author>TisonK</author>
4-
<version>2.1.1.0</version>
4+
<version>2.1.2.0</version>
55
<modName>FS25_RandomWorldEvents</modName>
66
<title>
77
<en>Random World Events</en>

utils/animalEvents.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ local animalEvents = {}
1414
-- =====================
1515

1616
animalEvents.getFarmId = function()
17-
return g_currentMission and g_currentMission.player and g_currentMission.player.farmId or 0
17+
if g_currentMission and g_currentMission.player and g_currentMission.player.farmId then
18+
return g_currentMission.player.farmId
19+
end
20+
-- Fallback to farm 1 (singleplayer/host farm) so addMoney() is never
21+
-- called with farmId=0 (the "no farm" spectator ID), which silently
22+
-- discards the transaction. Fixes cash deductions on modded maps where
23+
-- g_currentMission.player may be nil when the event fires.
24+
return 1
1825
end
1926

2027
-- Checks that at least one animal husbandry exists on the map.

0 commit comments

Comments
 (0)