Пример #1
0
        public static string GetGameBuildID(ArkServerInfo Server)
        {
            AcfReader appManifestReader = new AcfReader(Server.GameAppManifestACF);

            appManifestReader.ACFFileToStruct();
            appManifestReader.CheckIntegrity();
            ACF_Struct GameWorkshopACF = appManifestReader.ACFFileToStruct();

            return(GameWorkshopACF.SubACF["AppState"].SubItems["buildid"]);
        }
Пример #2
0
        private ACF_Struct ACFFileToStruct(string RegionToReadIn)
        {
            ACF_Struct ACF            = new ACF_Struct();
            int        LengthOfRegion = RegionToReadIn.Length;
            int        CurrentPos     = 0;

            while (LengthOfRegion > CurrentPos)
            {
                int FirstItemStart = RegionToReadIn.IndexOf('"', CurrentPos);
                if (FirstItemStart == -1)
                {
                    break;
                }
                int FirstItemEnd = RegionToReadIn.IndexOf('"', FirstItemStart + 1);
                CurrentPos = FirstItemEnd + 1;
                string FirstItem = RegionToReadIn.Substring(FirstItemStart + 1, FirstItemEnd - FirstItemStart - 1);

                int SecondItemStartQuote     = RegionToReadIn.IndexOf('"', CurrentPos);
                int SecondItemStartBraceleft = RegionToReadIn.IndexOf('{', CurrentPos);
                if (SecondItemStartBraceleft == -1 || SecondItemStartQuote < SecondItemStartBraceleft)
                {
                    int    SecondItemEndQuote = RegionToReadIn.IndexOf('"', SecondItemStartQuote + 1);
                    string SecondItem         = RegionToReadIn.Substring(SecondItemStartQuote + 1, SecondItemEndQuote - SecondItemStartQuote - 1);
                    CurrentPos = SecondItemEndQuote + 1;
                    ACF.SubItems.Add(FirstItem, SecondItem);
                }
                else
                {
                    int        SecondItemEndBraceright = RegionToReadIn.NextEndOf('{', '}', SecondItemStartBraceleft + 1);
                    ACF_Struct ACFS = ACFFileToStruct(RegionToReadIn.Substring(SecondItemStartBraceleft + 1, SecondItemEndBraceright - SecondItemStartBraceleft - 1));
                    CurrentPos = SecondItemEndBraceright + 1;
                    ACF.SubACF.Add(FirstItem, ACFS);
                }
            }

            return(ACF);
        }
Пример #3
0
        public static bool NeedsModUpdate(ArkServerInfo Server)
        {
            bool workshopItemNeedsUpdate = false;

            AcfReader serverReader = new AcfReader(Server.CurrentWorkshopACF);

            serverReader.ACFFileToStruct();
            serverReader.CheckIntegrity();
            ACF_Struct atLaunchACF = serverReader.ACFFileToStruct();

            AcfReader updateReader = new AcfReader(Server.UpdatedWorkshopACF);

            updateReader.ACFFileToStruct();
            updateReader.CheckIntegrity();
            ACF_Struct UpdatedWorkshopACF = updateReader.ACFFileToStruct();

            foreach (string mod in ActiveServerMods(Server))
            {
                string[] UpdatedModNTimeData = new string[2];
                UpdatedModNTimeData[0] = mod;
                try
                {
                    UpdatedModNTimeData[1] = UpdatedWorkshopACF.SubACF["AppWorkshop"].SubACF["WorkshopItemsInstalled"].SubACF[mod].SubItems["timeupdated"];
                }
                catch (Exception ex)
                {
                    //Console.WriteLine(DateTime.Now + ": Error in NeedsModUpdate in AllActiveServerMods on mod " + mod + " with exception: " + ex.Message);
                    Methods.Log(Server, DateTime.Now + ": Exception occured when trying to read all active mod's timeupdated value. Exception: " + ex.Message);
                    break;
                }
                UpdatedModNTime.Add(UpdatedModNTimeData);
            }
            foreach (string mod in ActiveServerMods(Server))
            {
                string[] ServerModNTimeData = new string[2];
                ServerModNTimeData[0] = mod;
                try
                {
                    ServerModNTimeData[1] = atLaunchACF.SubACF["AppWorkshop"].SubACF["WorkshopItemsInstalled"].SubACF[mod].SubItems["timeupdated"];
                }
                catch (Exception ex)
                {
                    //Console.WriteLine(DateTime.Now + ": Error reading working time updated element. Exception: " + ex.Message);
                    Methods.Log(Server, DateTime.Now + ": Error reading working time updated element. Exception: " + ex.Message);
                }

                ServerModNTime.Add(ServerModNTimeData);
            }
            foreach (string[] BMod in UpdatedModNTime)
            {
                foreach (string[] AMod in ServerModNTime)
                {
                    //if (BMod[0] != "1257464589")
                    if (BMod[0] == AMod[0])
                    {
                        if (BMod[1] != AMod[1])
                        {
                            workshopItemNeedsUpdate    = true;
                            Server.theModNeedingUpdate = NameOfMod(BMod[0]);
                            //Console.WriteLine(DateTime.Now.ToString() + ": Restart Triggered for Server " + Server.Name + "  to update the following mod: " + BMod[0] + "-" + GlobalVariables.NameOfMod(BMod[0]));
                            Methods.Log(Server, DateTime.Now.ToString() + ": Restart Triggered to update the following mod: " + BMod[0] + "-" + GlobalVariables.NameOfMod(BMod[0]));
                            break;
                        }
                        if (BMod[1] == AMod[1])
                        {
                            workshopItemNeedsUpdate = false;
                        }
                    }
                }
                if (workshopItemNeedsUpdate)
                {
                    break;
                }
            }
            UpdatedModNTime.Clear();
            ServerModNTime.Clear();


            return(workshopItemNeedsUpdate);
        }