print();

local modDirectory = g_currentModDirectory

function onLoadMapFinished(mission, node)
	local pricekaviar = g_fillTypeManager:getFillTypeByName("MAIZE").pricePerLiter
	
	
	if node ~= 0 then
	
	local kaviarHudFile = "Paletten/hud_fill_kaviar.dds"
	local kaviarHudFileSmall = "Paletten/hud_fill_kaviar_sml.dds"
	
    local kaviarFilType = g_fillTypeManager:addFillType("KAVIAR", g_i18n:getText("kaviar"), true, pricekaviar * 4.0, 0.00045, math.rad(10), kaviarHudFile, kaviarHudFileSmall,modDirectory, nil, { 1, 1, 1 }, nil, false)
	
	g_currentMission.hud.fillLevelsDisplay:refreshFillTypes(g_fillTypeManager)
	end;
end;

function load(id, xmlFile, key,customEnvironment)
	local hasmaize =false
	local haskaviar=false	
	
	
	local object=id
	if object == nil then
	else
	hasmaize =false
	haskaviar=false
	
	
	for i,filltype in pairs(object.acceptedFillTypes) do
	local fillname=g_fillTypeManager.indexToName[i]
		if fillname == "MAIZE" then
		hasmaize=true
	end;
		if fillname == "KAVIAR" then
		haskaviar=true
	end;
		
end;

		if hasmaize and not haskaviar then
		local filltypen = g_fillTypeManager:getFillTypeIndexByName("KAVIAR")
		local price = g_fillTypeManager:getFillTypeByName("KAVIAR").pricePerLiter
			object:addAcceptedFillType(filltypen,price,true,false)
			object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("KAVIAR")]=object.priceMultipliers[ g_fillTypeManager:getFillTypeIndexByName("MAIZE")]
			object:initPricingDynamics()
		end;
		
	end;
end;

FSBaseMission.loadMapFinished = Utils.prependedFunction(FSBaseMission.loadMapFinished, onLoadMapFinished)
SellingStation.load = Utils.appendedFunction(SellingStation.load, load)