--by susi&wing /giants
local modDirectory = g_currentModDirectory
function onLoadMapFinished(mission, node)  
    if node ~= 0 then     
        local priceWater = g_fillTypeManager:getFillTypeByName("WATER").pricePerLiter				
        local saltwaterHudFile = "hud/hud_fill_saltwater.png"
        local saltwaterHudFileSmall = "hud/hud_fill_saltwater_small.png"       		
		      
		print("Register new filltype for Salt water trigger:agua salada/saltwater/Salzwasser/eau salée");
        local saltwaterFilType = g_fillTypeManager:addFillType("SALTWATER", g_i18n:getText("agua salada"), true, priceWater * 1.1, 0.00045, math.rad(40), saltwaterHudFile, saltwaterHudFileSmall,modDirectory, nil, { 1, 1, 1 }, nil, false)
		local SALTWATERCategory = {"LIQUID"}
		for _,k in pairs(SALTWATERCategory) do
			g_fillTypeManager:addFillTypeToCategory(saltwaterFilType.index, g_fillTypeManager.nameToCategoryIndex[k])			
		end
		  g_currentMission.hud.fillLevelsDisplay:refreshFillTypes(g_fillTypeManager)
    end	
end	
function load(id, xmlFile, key,customEnvironment)
		local hasmaize =false
		local hassaltwater=false		
		local object=id					
		if object == nil then
		else
		haswater =false
		hassaltwater=false
			for i,filltype in pairs(object.acceptedFillTypes) do
					
			local fillname=g_fillTypeManager.indexToName[i]
	
				if fillname == "WATER" then
					haswater=true								
				end;
				if fillname == "SALTWATER" then
					hassaltwater=true								
				end;	
			end;
				
				if haswater and not hassaltwater then
					--add SALTWATER zur SellingStation wo MAIZE nimmt
					local filltypen = g_fillTypeManager:getFillTypeIndexByName("SALTWATER")
					local price = g_fillTypeManager:getFillTypeByName("SALTWATER").pricePerLiter
					object:addAcceptedFillType(filltypen,price,true,false)
					object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("SALTWATER")]=object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("WATER")]
					object:initPricingDynamics()
				end;						
		end
end
FSBaseMission.loadMapFinished = Utils.prependedFunction(FSBaseMission.loadMapFinished, onLoadMapFinished)
SellingStation.load = Utils.appendedFunction(SellingStation.load, load)

