File tree Expand file tree Collapse file tree 4 files changed +26
-146
lines changed
Expand file tree Collapse file tree 4 files changed +26
-146
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public AnimationManager(AudioStreamPlayer audioPlayer) {
6363 public IniData getINIData ( string pathKey ) {
6464 if ( ! iniDatas . TryGetValue ( pathKey , out IniData tr ) ) {
6565 string fullPath = Util . Civ3MediaPath ( pathKey ) ;
66- tr = new FileIniDataParser ( ) . ReadFile ( fullPath ) ;
66+ tr = C7Engine . Util . GetFileIniDataParser ( ) . ReadFile ( fullPath ) ;
6767 iniDatas . Add ( pathKey , tr ) ;
6868 }
6969 return tr ;
Original file line number Diff line number Diff line change 1- using System . IO ;
1+ using IniParser . Model ;
22using IniParser . Exceptions ;
33
44namespace C7Engine {
5- using IniParser ;
6- using IniParser . Model ;
7-
85 public class C7Settings {
96 private const string SETTINGS_FILE_NAME = "C7.ini" ;
107 public static IniData settings ;
118
129 public static void LoadSettings ( ) {
1310 try {
14- settings = new FileIniDataParser ( ) . ReadFile ( SETTINGS_FILE_NAME ) ;
11+ settings = Util . GetFileIniDataParser ( ) . ReadFile ( SETTINGS_FILE_NAME ) ;
1512 } catch ( ParsingException ) {
1613 //First run. The file doesn't exist. That's okay. We'll use sensible defaults.
1714 settings = new IniData ( ) ;
@@ -20,7 +17,7 @@ public static void LoadSettings() {
2017 }
2118
2219 public static void SaveSettings ( ) {
23- new FileIniDataParser ( ) . WriteFile ( SETTINGS_FILE_NAME , settings ) ;
20+ Util . GetFileIniDataParser ( ) . WriteFile ( SETTINGS_FILE_NAME , settings ) ;
2421 }
2522
2623 public static void SetValue ( string section , string key , string value ) {
Original file line number Diff line number Diff line change 1+ using IniParser ;
2+
3+ namespace C7Engine ;
4+
5+ public static class Util {
6+ private static FileIniDataParser fileIniDataParser ;
7+
8+ public static FileIniDataParser GetFileIniDataParser ( ) {
9+ if ( fileIniDataParser != null ) return fileIniDataParser ;
10+
11+ FileIniDataParser parser = new FileIniDataParser ( ) ;
12+ // The default behaviour of the parser is to throw an exception
13+ // when it finds duplicate keys (e.x. Tank.ini has 'DEAD' two times in [Sound Effects])
14+ // so, we want to allow it so that it doesn't crash
15+ parser . Parser . Configuration . AllowDuplicateKeys = true ;
16+ // but we only want to keep the last value we encounter
17+ parser . Parser . Configuration . OverrideDuplicateKeys = true ;
18+
19+ fileIniDataParser = parser ;
20+ return parser ;
21+ }
22+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments