예제 #1
0
        public static bool TryLoadData(out VehicleData[] data)
        {
            data = new VehicleData[CachedVehicleData.MaxVehicleCount];
            byte[] data1 = SerializableDataExtension.instance.SerializableData.LoadData(CachedVehicleData._dataID);
            if (data1 == null)
            {
                return(false);
            }
            int    index1 = 0;
            string empty  = string.Empty;

            try
            {
                Utils.Log((object)"Try to load vehicle data.");
                string str = SerializableDataExtension.ReadString(data1, ref index1);
                if (string.IsNullOrEmpty(str) || str.Length != 4)
                {
                    Utils.LogWarning((object)"Unknown data found.");
                    return(false);
                }
                Utils.Log((object)("Found vehicle data version: " + str));
                while (index1 < Math.Min(data1.Length, CachedVehicleData.MaxVehicleCount))
                {
                    int index2 = SerializableDataExtension.ReadInt32(data1, ref index1);
                    if (str == "v001")
                    {
                        int num = (int)SerializableDataExtension.ReadByte(data1, ref index1);
                    }
                    data[index2].LastStopNewPassengers  = SerializableDataExtension.ReadInt32(data1, ref index1);
                    data[index2].LastStopGonePassengers = SerializableDataExtension.ReadInt32(data1, ref index1);
                    data[index2].PassengersThisWeek     = SerializableDataExtension.ReadInt32(data1, ref index1);
                    data[index2].PassengersLastWeek     = SerializableDataExtension.ReadInt32(data1, ref index1);
                    data[index2].IncomeThisWeek         = SerializableDataExtension.ReadInt32(data1, ref index1);
                    data[index2].IncomeLastWeek         = SerializableDataExtension.ReadInt32(data1, ref index1);
                    data[index2].PassengerData          = SerializableDataExtension.ReadFloatArray(data1, ref index1);
                    data[index2].IncomeData             = SerializableDataExtension.ReadFloatArray(data1, ref index1);
                    if (str != "v001" && str != "v002")
                    {
                        data[index2].CurrentStop = SerializableDataExtension.ReadUInt16(data1, ref index1);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Utils.LogWarning((object)("Could not load vehicle data. " + ex.Message));
                data = new VehicleData[CachedVehicleData.MaxVehicleCount];
                return(false);
            }
        }
 private static void Modify(string id, string oldValue, string newValue)
 {
     try
     {
         Dictionary <Locale.Key, string> dictionary = Utils.GetPrivate <Dictionary <Locale.Key, string> >((object)Utils.GetPrivate <Locale>((object)SingletonLite <LocaleManager> .instance, "m_Locale"), "m_LocalizedStrings");
         Locale.Key key = new Locale.Key()
         {
             m_Identifier = id
         };
         string str;
         if (!dictionary.TryGetValue(key, out str))
         {
             return;
         }
         dictionary[key] = str.Replace(oldValue, newValue);
     }
     catch (Exception ex)
     {
         Utils.LogWarning((object)("Unexpected " + ex.GetType().Name + " updating localization: " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine));
     }
 }