Example #1
0
 private static void mergeCarClassData(CarClasses defaultCarClassData, CarClasses userCarClassData)
 {
     int userCarClassesCount = 0;
     List<CarClass> classesToAddFromDefault = new List<CarClass>();
     foreach (CarClass defaultCarClass in defaultCarClassData.carClasses)
     {
         Boolean isInUserCarClasses = false;
         int userCarClassIndex = 0;
         foreach (CarClass userCarClass in userCarClassData.carClasses)
         {
             if (userCarClass.carClassEnum == defaultCarClass.carClassEnum)
             {
                 isInUserCarClasses = true;
                 userCarClassesCount++;
                 break;
             }
             else if (userCarClass.carClassEnum == CarClassEnum.USER_CREATED && userCarClass.placeholderClassId.Length == 0 &&
                 userCarClassIds.Count > userCarClassIndex)
             {
                 userCarClass.placeholderClassId = userCarClassIds[userCarClassIndex];
                 Console.WriteLine("Adding a user defined class with ID " + userCarClass.placeholderClassId);
                 userCarClassIndex++;
             }
         }
         if (!isInUserCarClasses)
         {
             classesToAddFromDefault.Add(defaultCarClass);
         }
     }
     userCarClassData.carClasses.AddRange(classesToAddFromDefault);
     Console.WriteLine("Loaded " + defaultCarClassData.carClasses.Count + " default car class definitions and " +
         userCarClassesCount + " user defined car class definitions");
 }
Example #2
0
        public static void loadCarClassData()
        {
            userCarClassIds = new List<string>();
            CarClasses defaultCarClassData = getCarClassDataFromFile(getDefaultCarClassFileLocation());
            CarClasses userCarClassData = getCarClassDataFromFile(getUserCarClassFileLocation());
            mergeCarClassData(defaultCarClassData, userCarClassData);
            foreach (CarClass carClass in userCarClassData.carClasses)
            {
                carClass.setupRegexs();
            }
            CAR_CLASSES = userCarClassData;

            // reset session scoped cache of class name / ID to CarClass Dictionary.
            nameToCarClass = new Dictionary<string, CarClass>();
            intToCarClass = new Dictionary<int, CarClass>();
        }