# HG changeset patch # User IBBoard # Date 1274297009 0 # Node ID 3b395ab8784db808af86d06586c1a0dd3d4aebbe # Parent 435eb28b4549c2840be865b97935f75958d11817 Re #270: Add multiple categories to API * Make Race cache new units against each category diff -r 435eb28b4549 -r 3b395ab8784d api/Objects/Race.cs --- a/api/Objects/Race.cs Tue May 18 19:59:17 2010 +0000 +++ b/api/Objects/Race.cs Wed May 19 19:23:29 2010 +0000 @@ -162,15 +162,18 @@ private void CacheUnitType(UnitType unit) { BuildUnitTypesByCategoryCache(); - Dictionary catUnitTypes; - unitTypesByCat.TryGetValue(unit.MainCategory, out catUnitTypes); - - if (catUnitTypes == null) + + foreach (Category cat in unit.Categories) { - throw new InvalidFileException(String.Format("Unit type {0} with name {1} is a unit of an undefined category", unit.ID, unit.Name)); + Dictionary catUnitTypes = DictionaryUtils.GetValue(unitTypesByCat, cat); + + if (catUnitTypes == null) + { + throw new InvalidFileException(String.Format("Unit type {0} with name {1} is a unit of an undefined category ({2})", unit.ID, unit.Name, cat.ID)); + } + + catUnitTypes.Add(unit.ID, unit); } - - catUnitTypes.Add(unit.ID, unit); } private void BuildUnitTypesByCategoryCache()