Mercurial > repos > IBBoard.WarFoundry.API
annotate api/AbstractWarFoundryLoader.cs @ 291:24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
* Fix quick fix so that it actually works and loads files - but it is still a quick-fix that needs double-checking
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 14 Dec 2010 20:17:07 +0000 |
parents | c035afa4a42c |
children | b24a78cfd314 |
rev | line source |
---|---|
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (AbstractWarFoundryLoader.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.Collections.Generic; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using System.IO; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using IBBoard.Collections; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using IBBoard.IO; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 using IBBoard.Logging; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 using IBBoard.WarFoundry.API.Factories; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 using IBBoard.WarFoundry.API.Objects; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 namespace IBBoard.WarFoundry.API |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 /// The base abstract implementation of a WarFoundry file loader |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 public abstract class AbstractWarFoundryLoader |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 private ICollection<DirectoryInfo> directories; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 private ICollection<INativeWarFoundryFactory> factories; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 private ICollection<INonNativeWarFoundryFactory> nonNativeFactories; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 private Dictionary<IWarFoundryFactory, SimpleSet<IWarFoundryObject>> loadedObjects; |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
25 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 public delegate void FileLoadingCompleteDelegate(List<FileLoadFailure> failures); |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
27 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 public event MethodInvoker FileLoadingStarted; |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
29 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 public event FileLoadingCompleteDelegate FileLoadingFinished; |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
31 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 protected AbstractWarFoundryLoader() |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 directories = new List<DirectoryInfo>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 factories = new List<INativeWarFoundryFactory>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 nonNativeFactories = new List<INonNativeWarFoundryFactory>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 loadedObjects = new Dictionary<IWarFoundryFactory,SimpleSet<IWarFoundryObject>>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 /// Adds a directory to the collection of directories that will be searched for WarFoundry data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 /// <param name="directory"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 /// The <see cref="DirectoryInfo"/> to add to the list for searching for data files |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 public void AddLoadDirectory(DirectoryInfo directory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 if (!directories.Contains(directory)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 directories.Add(directory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 /// Removes a directory from the collection of directories that will be searched for WarFoundry data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 /// <param name="directory"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 /// A <see cref="DirectoryInfo"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 public void RemoveLoadDirectory(DirectoryInfo directory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 if (directories.Contains(directory)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 directories.Remove(directory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 /// Registers a <see cref="INativeWarFoundryFactory"/> as a factory that can parse native data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 /// <param name="factory"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 /// The <see cref="INativeWarFoundryFactory"/> to register to parse native data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 public void RegisterFactory(INativeWarFoundryFactory factory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 if (!factories.Contains(factory)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 factories.Add(factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 /// Unregisters a <see cref="INativeWarFoundryFactory"/> so that it will no longer be used to try to parse native data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 /// <param name="factory"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 /// The <see cref="INativeWarFoundryFactory"/> to remove from the collection of factories that are used to try to parse native data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 public void UnregisterFactory(INativeWarFoundryFactory factory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 if (factories.Contains(factory)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 factories.Remove(factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 /// Registers a <see cref="INonNativeWarFoundryFactory"/> so that it will be used to try to parse non-native data files from other applications. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 /// <param name="factory"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 /// The <see cref="INonNativeWarFoundryFactory"/> to register to parse non-native data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 public void RegisterNonNativeFactory(INonNativeWarFoundryFactory factory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 if (!nonNativeFactories.Contains(factory)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 nonNativeFactories.Add(factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
107 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
111 /// Unregisters a <see cref="INonNativeWarFoundryFactory"/> so that it will no longer be used to try to parse non-native data files from other applications. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 /// <param name="factory"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 /// The <see cref="INonNativeWarFoundryFactory"/> to remove from the collection of factories that are used to try to parse non-native data files. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 public void UnregisterNonNativeFactory(INonNativeWarFoundryFactory factory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 if (nonNativeFactories.Contains(factory)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 nonNativeFactories.Remove(factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
123 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 /// Loads all of the data files in the registered directories. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 /// A <see cref="List"/> of <see cref="FileLoadFailure"/> for files that failed to load |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 public List<FileLoadFailure> LoadFiles() |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 PrepareForFileLoad(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 Dictionary<FileInfo, IWarFoundryFactory> loadableRaces = new Dictionary<FileInfo, IWarFoundryFactory>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 Dictionary<FileInfo, IWarFoundryFactory> loadableGameSystems = new Dictionary<FileInfo, IWarFoundryFactory>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 List<FileLoadFailure> failedLoads = FillLoadableFiles(loadableRaces, loadableGameSystems); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 failedLoads.AddRange(LoadGameSystems(loadableGameSystems)); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 failedLoads.AddRange(LoadRaces(loadableRaces)); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 OnFileLoadingFinished(failedLoads); |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
139 FinishFileLoad(); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 return failedLoads; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
142 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 private void OnFileLoadingFinished(List<FileLoadFailure> failures) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
145 if (FileLoadingFinished != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
146 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 FileLoadingFinished(failures); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
150 |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
151 protected virtual void PrepareForFileLoad() |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
152 { |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
153 //Do nothing special |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
154 } |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
155 |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
156 protected virtual void FinishFileLoad() |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
157 { |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
158 //Do nothing special |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
159 } |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
160 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 private List<FileLoadFailure> FillLoadableFiles(Dictionary<FileInfo, IWarFoundryFactory> loadableRaces, Dictionary<FileInfo, IWarFoundryFactory> loadableGameSystems) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 List<FileLoadFailure> fails = new List<FileLoadFailure>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 foreach (DirectoryInfo directory in directories) |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
166 { |
281
c035afa4a42c
Fixes #301: "Reload files" doesn't work when folder didn't exist
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
167 directory.Refresh(); |
c035afa4a42c
Fixes #301: "Reload files" doesn't work when folder didn't exist
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
168 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 if (directory.Exists) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
170 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 List<FileLoadFailure> directoryFails = FillLoadableFilesForDirectory(loadableRaces, loadableGameSystems, directory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 fails.AddRange(directoryFails); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 LogNotifier.WarnFormat(GetType(), "Load for {0} failed because directory didn't exist", directory.FullName); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 return fails; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 private List<FileLoadFailure> FillLoadableFilesForDirectory(Dictionary<FileInfo, IWarFoundryFactory> loadableRaces, Dictionary<FileInfo, IWarFoundryFactory> loadableGameSystems, DirectoryInfo directory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 List<FileLoadFailure> fails = new List<FileLoadFailure>(); |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
186 LogNotifier.Debug(GetType(), "Load from " + directory.FullName); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 foreach (FileInfo file in directory.GetFiles()) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
189 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 IWarFoundryFactory factory = GetGameSystemLoadingFactoryForFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 if (factory != null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 loadableGameSystems.Add(file, factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
195 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
198 factory = GetRaceLoadingFactoryForFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
200 if (factory != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 loadableRaces.Add(file, factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
203 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
205 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 FileLoadFailure failure = new FileLoadFailure(file, "File not handled as a Race or Game System definition: {0}", "FileNotHandled"); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 fails.Add(failure); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 LogNotifier.Info(GetType(), failure.Message); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
211 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
212 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
213 return fails; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
214 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 private IWarFoundryFactory GetGameSystemLoadingFactoryForFile(FileInfo file) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
217 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 IWarFoundryFactory loadingFactory = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
219 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
220 foreach (INonNativeWarFoundryFactory factory in nonNativeFactories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 if (factory.CanHandleFileAsGameSystem(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
223 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
224 loadingFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
225 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
226 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
228 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
229 if (loadingFactory == null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
231 foreach (INativeWarFoundryFactory factory in factories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
232 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
233 if (factory.CanHandleFileAsGameSystem(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
235 loadingFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
236 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
237 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
238 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 return loadingFactory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 private IWarFoundryFactory GetRaceLoadingFactoryForFile(FileInfo file) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
246 IWarFoundryFactory loadingFactory = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 foreach (INonNativeWarFoundryFactory factory in nonNativeFactories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 if (factory.CanHandleFileAsRace(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
252 loadingFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
254 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
255 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
257 if (loadingFactory == null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
259 foreach (INativeWarFoundryFactory factory in factories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
260 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
261 if (factory.CanHandleFileAsRace(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
262 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 loadingFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
267 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
268 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 return loadingFactory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
270 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
271 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 private List<FileLoadFailure> LoadGameSystems(Dictionary<FileInfo, IWarFoundryFactory> gameSystemFiles) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
273 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
274 List<FileLoadFailure> fails = new List<FileLoadFailure>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
275 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
276 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
277 foreach (FileInfo file in gameSystemFiles.Keys) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
278 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
279 FileLoadFailure failure = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
280 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
281 try |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
282 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
283 bool loaded = LoadObject(file, gameSystemFiles[file]); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
284 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
285 if (!loaded) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
286 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
287 failure = new FileLoadFailure(file, "FileLoadFailed", "Failed to load {0} as GameSystem using {1}"); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
288 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
289 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
290 catch (Exception ex) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
291 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
292 failure = new FileLoadFailure(file, null, ex.Message, null, ex); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
293 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
294 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
295 if (failure != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
296 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
297 fails.Add(failure); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
298 LogNotifier.Warn(GetType(), failure.Message, failure.Exception); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
299 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
300 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
301 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
302 return fails; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
303 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
304 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
305 private List<FileLoadFailure> LoadRaces(Dictionary<FileInfo, IWarFoundryFactory> raceFiles) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
306 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
307 List<FileLoadFailure> fails = new List<FileLoadFailure>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
308 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
309 foreach (FileInfo file in raceFiles.Keys) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
310 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
311 FileLoadFailure failure = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
312 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
313 try |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
314 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
315 bool loaded = LoadObject(file, raceFiles[file]); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
316 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
317 if (!loaded) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
318 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
319 failure = new FileLoadFailure(file, "FileLoadFailed", "Failed to load {0} as Race using {1}"); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
320 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
321 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
322 catch (Exception ex) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
323 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
324 failure = new FileLoadFailure(file, null, ex.Message, null, ex); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
325 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
326 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
327 if (failure != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
328 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
329 fails.Add(failure); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
330 LogNotifier.Warn(GetType(), failure.Message, failure.Exception); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
331 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
332 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
333 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
334 return fails; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
335 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
336 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
337 private bool LoadObject(FileInfo file, IWarFoundryFactory factory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
338 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
339 bool loaded = false; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
340 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
341 LogNotifier.DebugFormat(GetType(), "Loading {0} using {1}", file.FullName, factory.GetType().Name); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
342 ICollection<IWarFoundryObject> objects = factory.CreateObjectsFromFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
343 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
344 if (objects.Count > 0) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
345 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
346 AddLoadedObjects(objects, factory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
347 loaded = true; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
348 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
349 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
350 return loaded; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
351 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
352 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
353 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
354 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
355 /// Loads a single file through the registered WarFoundryFactories, if a factory exists that supports the file format. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
356 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
357 /// <param name="file"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
358 /// A <see cref="FileInfo"/> for the file to attempt to load |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
359 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
360 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
361 /// An ICollection of IWarFoundryObjects loaded from <code>file</code> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
362 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
363 public ICollection<IWarFoundryObject> LoadFile(FileInfo file) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
364 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
365 ICollection<IWarFoundryObject> objs = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
366 IWarFoundryFactory loadFactory = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
367 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
368 try |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
369 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
370 objs = LoadFileWithNonNativeFactories(file, out loadFactory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
371 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
372 if (objs == null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
373 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
374 objs = LoadFileWithNativeFactories(file, out loadFactory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
375 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
376 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
377 catch (InvalidFileException ex) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
378 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
379 LogNotifier.Error(GetType(), file.FullName + " failed to load", ex); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
380 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
381 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
382 if (objs != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
383 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
384 AddLoadedObjects(objs, loadFactory); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
385 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
386 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
387 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
388 objs = new List<IWarFoundryObject>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
389 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
390 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
391 return objs; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
392 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
393 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
394 private ICollection<IWarFoundryObject> LoadFileWithNonNativeFactories(FileInfo file, out IWarFoundryFactory loadFactory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
395 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
396 ICollection<IWarFoundryObject> objs = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
397 loadFactory = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
398 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
399 if (nonNativeFactories.Count > 0) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
400 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
401 LogNotifier.Debug(GetType(), "Attempting to load " + file.FullName + " as a non-native file"); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
402 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
403 foreach (INonNativeWarFoundryFactory factory in nonNativeFactories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
404 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
405 bool canLoad = factory.CanHandleFileFormat(file); |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
406 LogNotifier.Debug(GetType(), "Load using " + factory.GetType().FullName + "? " + (canLoad ? "yes" : "no")); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
407 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
408 if (canLoad) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
409 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
410 objs = factory.CreateObjectsFromFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
411 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
412 if (objs != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
413 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
414 loadFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
415 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
416 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
417 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
418 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
419 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
420 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
421 return objs; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
422 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
423 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
424 private ICollection<IWarFoundryObject> LoadFileWithNativeFactories(FileInfo file, out IWarFoundryFactory loadFactory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
425 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
426 ICollection<IWarFoundryObject> objs = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
427 loadFactory = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
428 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
429 if (factories.Count > 0) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
430 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
431 LogNotifier.Debug(GetType(), "Attempting to load " + file.FullName + " as native file"); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
432 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
433 foreach (INativeWarFoundryFactory factory in factories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
434 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
435 if (factory.CanHandleFileFormat(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
436 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
437 objs = factory.CreateObjectsFromFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
438 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
439 if (objs != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
440 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
441 loadFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
442 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
443 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
444 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
445 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
446 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
447 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
448 return objs; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
449 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
450 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
451 private void AddLoadedObjects(ICollection<IWarFoundryObject> loadedObjs, IWarFoundryFactory factory) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
452 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
453 SimpleSet<IWarFoundryObject> objs; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
454 loadedObjects.TryGetValue(factory, out objs); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
455 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
456 if (objs == null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
457 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
458 objs = new SimpleSet<IWarFoundryObject>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
459 loadedObjects.Add(factory, objs); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
460 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
461 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
462 objs.AddRange(loadedObjs); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
463 StoreObjects(loadedObjs); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
464 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
465 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
466 private void StoreObjects(ICollection<IWarFoundryObject> loadedObjects) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
467 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
468 foreach (IWarFoundryObject loadedObject in loadedObjects) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
469 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
470 if (loadedObject is GameSystem) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
471 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
472 StoreGameSystem((GameSystem)loadedObject); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
473 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
474 else if (loadedObject is Race) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
475 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
476 StoreRace((Race)loadedObject); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
477 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
478 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
479 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
480 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
481 protected void StoreGameSystem(GameSystem system) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
482 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
483 GameSystem existingSystem = GetExistingSystemForSystem(system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
484 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
485 if (existingSystem != null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
486 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
487 if (!system.Equals(existingSystem)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
488 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
489 //TODO: Raise an event to say we got a different duplicate |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
490 //We can't just fail, because failing is for completely unhandled files, not for objects in a file |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
491 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
492 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
493 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
494 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
495 DoStoreGameSystem(system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
496 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
497 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
498 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
499 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
500 /// Gets a game system that has already been loaded that duplicates the supplied game system's ID, if one exists. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
501 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
502 /// <param name="system"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
503 /// The <see cref="GameSystem"/> to find pre-existing duplicates of |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
504 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
505 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
506 /// <code>null</code> if no existing duplicate exists, else the duplicate <see cref="GameSystem"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
507 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
508 protected abstract GameSystem GetExistingSystemForSystem(GameSystem system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
509 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
510 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
511 /// Stores a GameSystem in the loader's relevant storage structure |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
512 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
513 /// <param name="system"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
514 /// The loaded <see cref="GameSystem"/> to store |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
515 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
516 protected abstract void DoStoreGameSystem(GameSystem system); |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
517 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
518 protected void StoreRace(Race race) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
519 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
520 if (race.GameSystem == null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
521 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
522 throw new InvalidOperationException("Race cannot have null game system. Game system should be loaded before race."); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
523 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
524 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
525 DoStoreRace(race); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
526 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
527 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
528 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
529 /// Performs the implementation specific storage of a race |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
530 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
531 /// <param name="race"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
532 /// The <see cref="Race"/> to store |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
533 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
534 protected abstract void DoStoreRace(Race race); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
535 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
536 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
537 /// Gets all <see cref="GameSystem"/>s that are currently available, determined by those that can be loaded with the current <see cref="IWarFoundryFactory"/>s. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
538 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
539 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
540 /// An array of <see cref="GameSystem"/>s that are currently available. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
541 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
542 public abstract GameSystem[] GetGameSystems(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
543 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
544 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
545 /// Gets a single <see cref="GameSystem"/> with a given ID. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
546 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
547 /// <param name="systemID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
548 /// The ID of the <see cref="GameSystem"/> to get, as a <see cref="System.String"/>. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
549 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
550 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
551 /// The <see cref="GameSystem"/> with the given ID, or <code>null</code> if one doesn't exist. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
552 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
553 public abstract GameSystem GetGameSystem(string systemID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
554 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
555 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
556 /// Removes a loaded <see cref="GameSystem"/>. Used when a GameSystem fails to complete loading |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
557 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
558 /// <param name="system">The GameSystem to remove</param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
559 protected internal abstract void RemoveGameSystem(GameSystem system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
560 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
561 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
562 /// Gets an array of the races for the specified <see cref="GameSystem"/>. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
563 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
564 /// <param name="system"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
565 /// The <see cref="GameSystem"/> to get the available races for. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
566 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
567 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
568 /// An array of <see cref="Race"/>s for the <see cref="GameSystem"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
569 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
570 public abstract Race[] GetRaces(GameSystem system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
571 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
572 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
573 /// Gets a single race for a given <see cref="GameSystem"/> by ID of the race. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
574 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
575 /// <param name="system"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
576 /// The <see cref="GameSystem"/> that the race is part of. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
577 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
578 /// <param name="raceID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
579 /// A <see cref="System.String"/> ID for the race to load. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
580 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
581 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
582 /// A <see cref="Race"/> with the specified ID from the <see cref="GameSystem"/>, or <code>null</code> if one doesn't exist. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
583 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
584 public abstract Race GetRace(GameSystem system, string raceID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
585 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
586 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
587 /// Gets a single race for a given <see cref="GameSystem"/> by the race's ID and sub-race ID. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
588 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
589 /// <param name="system"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
590 /// The <see cref="GameSystem"/> that the race is part of. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
591 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
592 /// <param name="raceID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
593 /// The <see cref="System.String"/> ID for the race to load. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
594 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
595 /// <param name="raceSubID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
596 /// A <see cref="System.String"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
597 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
598 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
599 /// A <see cref="Race"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
600 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
601 public abstract Race GetRace(GameSystem system, string raceID, string raceSubID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
602 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
603 protected internal abstract void RemoveRace(Race race); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
604 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
605 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
606 /// Gets the IDs of all of the game systems currently available. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
607 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
608 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
609 /// An array of <see cref="System.String"/>s representing the IDs of the game systems. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
610 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
611 public virtual string[] GetGameSystemIDs() |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
612 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
613 GameSystem[] systems = GetGameSystems(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
614 return GetWarFoundryObjectIDs(systems); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
615 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
616 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
617 protected string[] GetWarFoundryObjectIDs(WarFoundryObject[] objs) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
618 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
619 int objCount = objs.Length; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
620 string[] keys = new string[objCount]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
621 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
622 for (int i = 0; i < objCount; i++) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
623 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
624 keys[i] = objs[i].ID; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
625 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
626 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
627 return keys; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
628 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
629 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
630 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
631 /// Gets the IDs of all of the races of a specified game system. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
632 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
633 /// <param name="system"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
634 /// The <see cref="GameSystem"/> to get the available races for. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
635 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
636 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
637 /// An array of <see cref="System.String"/>s representing the IDs of the races of the specified game system. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
638 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
639 public virtual string[] GetSystemRaceIDs(GameSystem system) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
640 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
641 Race[] races = GetRaces(system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
642 return GetWarFoundryObjectIDs(races); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
643 } |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
644 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
645 public Army LoadArmy(FileInfo file) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
646 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
647 IWarFoundryFactory factory = GetArmyLoadingFactoryForFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
648 Army loadedArmy = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
649 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
650 if (factory != null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
651 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
652 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(file); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
653 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
654 if (objs.Count == 1) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
655 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
656 foreach (IWarFoundryObject systemCount in objs) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
657 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
658 if (systemCount is Army) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
659 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
281
diff
changeset
|
660 loadedArmy = (Army)systemCount; |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
661 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
662 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
663 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
664 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
665 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
666 return loadedArmy; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
667 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
668 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
669 private IWarFoundryFactory GetArmyLoadingFactoryForFile(FileInfo file) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
670 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
671 IWarFoundryFactory loadingFactory = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
672 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
673 foreach (INonNativeWarFoundryFactory factory in nonNativeFactories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
674 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
675 if (factory.CanHandleFileAsArmy(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
676 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
677 loadingFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
678 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
679 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
680 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
681 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
682 if (loadingFactory == null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
683 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
684 foreach (INativeWarFoundryFactory factory in factories) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
685 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
686 if (factory.CanHandleFileAsArmy(file)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
687 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
688 loadingFactory = factory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
689 break; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
690 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
691 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
692 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
693 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
694 return loadingFactory; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
695 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
696 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
697 } |