
function DLC2BgaOnCreate(id)
    if g_modIsLoaded["pdlc_dlcPack2"] and pdlc_dlcPack2 ~= nil and pdlc_dlcPack2.Bga ~= nil and pdlc_dlcPack2.Bga.onCreate ~= nil then
        pdlc_dlcPack2.Bga.onCreate(id);
    end;
end;
g_onCreateUtil.addOnCreateFunction("dlc2_Bga_onCreate", DLC2BgaOnCreate);

function DLC2BunkerSiloOnCreate(id)
    if g_modIsLoaded["pdlc_dlcPack2"] and pdlc_dlcPack2 ~= nil and pdlc_dlcPack2.BunkerSilo ~= nil and pdlc_dlcPack2.BunkerSilo.onCreate ~= nil then
        pdlc_dlcPack2.BunkerSilo.onCreate(id);
    end;
end;
g_onCreateUtil.addOnCreateFunction("dlc2_BunkerSilo_onCreate", DLC2BunkerSiloOnCreate);

-- code to show error message if DLC2 is not installed or loaded in MP games

local BaseMission_update_old = BaseMission.update;
BaseMission.update = function(self, dt)
    BaseMission_update_old(self, dt);

    if not self.dlc2LoadedChecked and self.time > 200 then
        self.dlc2LoadedChecked = true;
        if g_modIsLoaded["pdlc_dlcPack2"] == nil or not g_modIsLoaded["pdlc_dlcPack2"] or pdlc_dlcPack2 == nil or pdlc_dlcPack2.Bga == nil or pdlc_dlcPack2.BunkerSilo == nil then
            g_gui:showGui("InGameMenu");

            g_inGameMenu.continueEnabled = false;
            g_inGameMenu.continueButton:setDisabled(true);
            g_inGameMenu.errorText:setVisible(true);
            g_inGameMenu.errorText:setText(g_i18n:getText("DLC2_not_installed"));
            g_inGameMenu.playerAlreadySaved = true;
            g_inGameMenu.saveRestartButton:setDisabled(true);

            g_inGameMenu.briefingBg:setVisible(false);
            for i = 1, 3 do
                g_inGameMenu.briefingImages[i]:setVisible(false);
            end;
        end;
    end;
end;
