Skip to content

Commit

Permalink
mission vehicles filename check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmtrx committed Jan 23, 2022
1 parent 5894000 commit b63bd7b
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 36 deletions.
39 changes: 18 additions & 21 deletions missionVehicles/baseGame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@

<!-- maizeMission -->
<group fieldSize="small" variant="MAIZE" rewardScale="1.4">
<vehicle filename="$data/vehicles/bizon/z056/z056.xml" /> <!-- combine -->
<vehicle filename="$data/vehicles/capello/quasarF4/quasarF4.xml">
<vehicle filename="$data/vehicles/newHolland/chSeries/chSeries.xml" /> <!-- combine -->
<vehicle filename="$data/vehicles/capello/diamant8/diamant8.xml">
<!-- header -->
<configuration name="baseMaterial" id="36" />
</vehicle>
<vehicle filename="$data/vehicles/newHolland/T7/T7.xml">
<!-- tractor -->
<configuration name="wheel" id="4" />
</vehicle>
<vehicle filename="$data/vehicles/strautmann/SEK802/SEK802.xml">
<vehicle filename="$data/vehicles/claas/carat/carat.xml">
<!-- trailer -->
<configuration name="fillVolume" id="4" />
<configuration name="trailer" id="3" />
Expand All @@ -61,14 +61,14 @@
</group>

<group fieldSize="medium" variant="MAIZE">
<vehicle filename="$data/vehicles/rostselmash/161/161.xml">
<vehicle filename="$data/vehicles/claas/lexion8000/lexion8000.xml">
<!-- combine -->
<configuration name="wheel" id="2" />
</vehicle>
<vehicle filename="$data/vehicles/capello/diamantHS8/diamantHS8.xml">
<vehicle filename="$data/vehicles/claas/corio1275C/corio1275C.xml" />
<!-- header -->
<configuration name="baseMaterial" id="2" />
</vehicle>
<vehicle filename="$data/vehicles/claas/corio1275CTrailer/corio1275CTrailer.xml" />
<!-- header trailer -->
<vehicle filename="$data/vehicles/jcb/fastrac4220/fastrac4220.xml">
<!-- tractor -->
<configuration name="wheel" id="3" />
Expand All @@ -90,15 +90,12 @@
</group>

<group fieldSize="large" variant="MAIZE">
<vehicle filename="$data/vehicles/deutzFahr/topLiner4090/topLiner4090.xml">
<vehicle filename="$data/vehicles/johndeere/x9_1100/x9_1100.xml">
<!-- combine -->
<configuration name="wheel" id="4" />
</vehicle>
<vehicle filename="$data/vehicles/caseIH/header4408/header4408.xml">
<!-- header -->
<configuration name="baseMaterial" id="23" />
<configuration name="wheel" id="3" />
</vehicle>
<vehicle filename="$data/vehicles/deutzFahr/header4090Trailer/header4090Trailer.xml" /> <!-- headerTrailer -->
<vehicle filename="$data/vehicles/johnDeere/headerC16F/headerC16F.xml" /> <!-- header -->
<vehicle filename="$data/vehicles/nardi/n60_45/n60_45.xml" /> <!-- headerTrailer -->
<vehicle filename="$data/vehicles/newHolland/T7/T7.xml">
<!-- tractor -->
<configuration name="motor" id="2" />
Expand Down Expand Up @@ -402,7 +399,7 @@
</group>

<group fieldSize="medium" variant="MAIZE" rewardScale="0.8">
<vehicle filename="$data/vehicles/fendt/fendt700/fendt700.xml">
<vehicle filename="$data/vehicles/fendt/vario700/vario700.xml">
<!-- tractor -->
<configuration name="baseMaterial" id="2" />
<configuration name="wheel" id="3" />
Expand Down Expand Up @@ -476,28 +473,28 @@
</group>

<group fieldSize="medium">
<vehicle filename="$data/vehicles/fendt/fendt300/fendt300.xml">
<vehicle filename="$data/vehicles/fendt/vario700/vario700.xml">
<!-- tractor -->
<configuration name="baseMaterial" id="2" />
<configuration name="wheel" id="6" />
<configuration name="motor" id="2" />
<configuration name="fillUnit" id="1" />
<configuration name="frontloader" id="1" />
</vehicle>
<vehicle filename="$data/vehicles/einboeck/rotation1200/rotation1200.xml" /> <!-- weeder -->
<vehicle filename="$data/vehicles/einboeck/pneumaticstarPro1200/pneumaticstarPro1200.xml" /> <!-- weeder -->
<vehicle filename="$data/vehicles/agco/weight650/weight650.xml">
<!-- weight -->
<configuration name="baseMaterial" id="6" />
</vehicle>
</group>

<group fieldSize="large">
<vehicle filename="$data/vehicles/steyr/profiCVT/profiCVT.xml">
<vehicle filename="$data/vehicles/fendt/vario700/vario700.xml">
<!-- tractor -->
<configuration name="baseMaterial" id="2" />
<configuration name="wheel" id="6" />
<configuration name="motor" id="2" />
<configuration name="wheel" id="5" />
<configuration name="fillUnit" id="1" />
<configuration name="frontloader" id="1" />
</vehicle>
<vehicle filename="$data/vehicles/treffler/TS1520/TS1520.xml" /> <!-- weeder -->
<vehicle filename="$data/vehicles/agco/weight1100/weight1100.xml">
Expand Down Expand Up @@ -718,7 +715,7 @@
<configuration name="frontloader" id="1" />
</vehicle>
<vehicle filename="$data/vehicles/newHolland/bigBaler1290HD/bigBaler1290HD.xml" /> <!-- baler -->
<vehicle filename="$data/vehicles/kuhn/kuhnSW4014/kuhnSW4014.xml" /> <!-- bale wrapper -->
<vehicle filename="$data/vehicles/kuhn/SW4014/SW4014.xml" /> <!-- bale wrapper -->
<vehicle filename="$data/vehicles/jcb/fastrac8330/fastrac8330.xml">
<!-- tractor -->
<configuration name="motor" id="1" />
Expand Down
2 changes: 1 addition & 1 deletion missionVehicles/sample_userDefined.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</group>

<group fieldSize="medium" variant="MAIZE" rewardScale="0.8">
<vehicle filename="$data/vehicles/fendt/fendt700/fendt700.xml">
<vehicle filename="$data/vehicles/fendt/vario700/vario700.xml">
<!-- tractor -->
<configuration name="baseMaterial" id="2" />
<configuration name="wheel" id="3" />
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="61">
<modDesc descVersion="63">
<author>Mmtrx</author>
<version>1.2.0.0</version>
<title>
Expand Down
71 changes: 68 additions & 3 deletions scripts/missionVehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ function BetterContracts.loadMissionVehicles(missionManager, superFunc, ...)
debugPrint("[%s] %s map detected, loading mission vehicles created by %s", self.name, "FS19_ThueringerHoehe", "Lahmi")
missionManager.missionVehicles = {}
self:loadExtraMissionVehicles(self.directory .. "missionVehicles/FS19_ThueringerHoehe/baseGame.xml")
self:loadExtraMissionVehicles(self.directory .. "missionVehicles/FS19_ThueringerHoehe/claasPack.xml")
else
if self.debug then
self:checkExtraMissionVehicles(self.directory .. "missionVehicles/baseGame.xml")
end
self:loadExtraMissionVehicles(self.directory .. "missionVehicles/baseGame.xml")
-- self:loadExtraMissionVehicles(self.directory .. "missionVehicles/claasPack.xml")
end
local userdef = self.directory .. "missionVehicles/userDefined.xml"
if fileExists(userdef) then
if fileExists(userdef) and self:checkExtraMissionVehicles(userdef) then
self:loadExtraMissionVehicles(userdef)
end
self:validateMissionVehicles()
Expand All @@ -52,14 +54,77 @@ function BetterContracts:validateMissionVehicles()
for _,f in ipairs({"small","medium","large"}) do
if g_missionManager.missionVehicles[type][f] == nil or
#g_missionManager.missionVehicles[type][f] == 0 then
Logging.devWarning("[%s] No missionVehicles for %s missions on %s fields",
Logging.warning("[%s] No missionVehicles for %s missions on %s fields",
self.name, type, f)
end
end
end
end
end

function BetterContracts:checkExtraMissionVehicles(xmlFilename)
-- check if all vehicles specified can be loaded
local modName, modDirectory, filename, ignore
local check = true
local xmlFile = loadXMLFile("loadExtraMissionVehicles", xmlFilename)
local i = 0
while true do
local baseKey = string.format("missionVehicles.mission(%d)", i)
if hasXMLProperty(xmlFile, baseKey) then
local missionType = getXMLString(xmlFile, baseKey .. "#type") or ""
--self:loadExtraMissionVehicles_groups(xmlFile, baseKey, missionType, modDirectory)
local j = 0
while true do
local groupKey = string.format("%s.group(%d)", baseKey, j)
if hasXMLProperty(xmlFile, groupKey) then
--self:loadExtraMissionVehicles_vehicles(xmlFile, groupKey, modDirectory)
local k = 0
while true do
local vehicleKey = string.format("%s.vehicle(%d)", groupKey, k)
if hasXMLProperty(xmlFile, vehicleKey) then
local baseDirectory = nil
local vfile = getXMLString(xmlFile, vehicleKey .. "#filename") or "missingFilename"
ignore = false
modName = getXMLString(xmlFile, vehicleKey .. "#requiredMod")
if getXMLBool(xmlFile, vehicleKey .. "#isMod") then
baseDirectory = modDirectory
elseif modName~= nil then
if g_modIsLoaded[modName]then
baseDirectory = g_modNameToDirectory[modName]
else
Logging.warning("[%s] required Mod %s not found, ignoring mission vehicle %s",
self.name, modName, vfile)
ignore = true
check = false
end
end
if not ignore then
filename = Utils.getFilename(vfile, baseDirectory)
-- try to load from store item
if g_storeManager.xmlFilenameToItem[string.lower(filename)] == nil then
Logging.warning("**[%s] - could not get store item for '%s'",self.name,filename)
check = false
end
end
else
break
end
k = k +1
end
else
break
end
j = j +1
end
else
break
end
i = i + 1
end
delete(xmlFile)
return check
end

function BetterContracts:loadExtraMissionVehicles(xmlFilename)
local xmlFile = loadXMLFile("loadExtraMissionVehicles", xmlFilename)
local modDirectory = nil
Expand Down
10 changes: 0 additions & 10 deletions scripts/userint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ function BetterContracts:getFromVehicle(cat, m)
return false
end
if cat == 4 then wwidth = 0 end -- init for search for biggest wwidth
--[[
for _, v in ipairs(m.vehiclesToLoad) do
vecc = {vec = g_storeManager.xmlFilenameToItem[string.lower(v.filename)],
con = v.configurations}
if vecc.vec == nil then
Logging.warning("**[%s] - could not get store item for '%s'",self.name,v.filename)
return false
end
table.insert(vehicles, vecc)
end]]
for _, v in ipairs(m.vehiclesToLoad) do -- main loop over vehicles to load
vec = g_storeManager.xmlFilenameToItem[string.lower(v.filename)]
con = v.configurations
Expand Down

0 comments on commit b63bd7b

Please sign in to comment.