AdditionalSellingStations = {
    modDir = g_currentModDirectory
}

PlaceableSellingStation.onLoad = Utils.overwrittenFunction(PlaceableSellingStation.onLoad, function (self, superFunc, savegame, ...)
    superFunc(self, savegame, ...)

    if self.xmlFile.filename:lower():contains("maize") then
        return true
    end
    local xmlFilename = string.format("%sxml/addToSellingStation.xml", AdditionalSellingStations.modDir)
    local xml = loadXMLFile("mod_addToSellingStationXMLFile", xmlFilename)

    local i = 0
    while true do
        local path = "addToSellingStation.sellingStation(" .. i .. ")"
        local attachTo = g_fillTypeManager:getFillTypeIndexByName(getXMLString(xml, path .. "#attachTo"))
        if attachTo == nil then
            break
        end

        local spec = self.spec_sellingStation
        local sellingStation = spec.sellingStation

        for fillTypeIndex, _ in pairs(sellingStation.supportedFillTypes) do
            if fillTypeIndex == attachTo then
                local attached = getXMLString(xml, path .. "#fillType"):split(" ")
                for _, fillTypeName in ipairs(attached) do
                    local fillType = g_fillTypeManager:getFillTypeByName(fillTypeName)

                    if fillType ~= nil and sellingStation.supportedFillTypes[fillType.index] == nil then
                        sellingStation.supportedFillTypes[fillType.index] = true
                        local price = fillType.pricePerLiter

                        sellingStation:addAcceptedFillType(fillType.index, price, true, false)

                        for _, unloadTrigger in pairs(sellingStation.unloadTriggers) do
                            unloadTrigger.fillTypes[fillType.index] = true
                        end
                    end
                end

                sellingStation:initPricingDynamics()
                sellingStation:updateSupportedFillTypes()
            end
        end
        i = i + 1
    end

    return true
end)