1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Text ;
3
4
4
5
using SC4Parser . Logging ;
@@ -128,6 +129,20 @@ public class RegionViewSubfile
128
129
/// City description
129
130
/// </summary>
130
131
public string InternalDescription { get ; private set ; }
132
+ /// <summary>
133
+ /// Length of default mayor name
134
+ /// </summary>
135
+ public uint DefaultMayorNameLength { get ; private set ; }
136
+ /// <summary>
137
+ /// Default mayor name (usually "Jonas Sparks")
138
+ /// </summary>
139
+ public string DefaultMayorName { get ; private set ; }
140
+ public uint CurrentOccupancyGroupCount { get ; private set ; }
141
+ public List < OccupancyGroup > OccupancyGroupsCurrent = new List < OccupancyGroup > ( ) ;
142
+ public uint MaxOccupancyGroupCount { get ; private set ; }
143
+ public List < OccupancyGroup > OccupancyGroupsMax = new List < OccupancyGroup > ( ) ;
144
+ public uint LimitsOccupancyGroupCount { get ; private set ; }
145
+ public List < OccupancyGroup > OccupancyGroupsLimits = new List < OccupancyGroup > ( ) ;
131
146
132
147
/// <summary>
133
148
/// Parses Region View Subfile from a byte array
@@ -142,6 +157,7 @@ public void Parse(byte[] buffer)
142
157
143
158
Logger . Log ( LogLevel . Info , "Parsing RegionView subfile..." ) ;
144
159
160
+ // TODO: Convert to BinaryReader (yeah I know..)
145
161
MajorVersion = BitConverter . ToUInt16 ( Extensions . ReadBytes ( buffer , 2 , ref internalOffset ) , 0 ) ;
146
162
MinorVersion = BitConverter . ToUInt16 ( Extensions . ReadBytes ( buffer , 2 , ref internalOffset ) , 0 ) ;
147
163
@@ -175,6 +191,34 @@ public void Parse(byte[] buffer)
175
191
MayorName = Encoding . ASCII . GetString ( Extensions . ReadBytes ( buffer , MayorNameLength , ref internalOffset ) ) ;
176
192
InternalDescriptionLength = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
177
193
InternalDescription = Encoding . ASCII . GetString ( Extensions . ReadBytes ( buffer , InternalDescriptionLength , ref internalOffset ) ) ;
194
+ DefaultMayorNameLength = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
195
+ DefaultMayorName = Encoding . ASCII . GetString ( Extensions . ReadBytes ( buffer , DefaultMayorNameLength , ref internalOffset ) ) ;
196
+ internalOffset += ( 4 * 6 ) ; // Skip over 6 unused uints
197
+
198
+ // Parse Occupant Group info
199
+ CurrentOccupancyGroupCount = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
200
+ for ( int i = 0 ; i < CurrentOccupancyGroupCount ; i ++ )
201
+ {
202
+ uint group = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
203
+ uint pop = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
204
+ OccupancyGroupsCurrent . Add ( new OccupancyGroup ( i , Constants . OCCUPANCY_GROUPS [ i ] , group , pop ) ) ;
205
+ }
206
+
207
+ LimitsOccupancyGroupCount = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
208
+ for ( int i = 0 ; i < LimitsOccupancyGroupCount ; i ++ )
209
+ {
210
+ uint group = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
211
+ uint pop = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
212
+ OccupancyGroupsMax . Add ( new OccupancyGroup ( i , Constants . OCCUPANCY_GROUPS [ i ] , group , pop ) ) ;
213
+ }
214
+
215
+ MaxOccupancyGroupCount = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
216
+ for ( int i = 0 ; i < MaxOccupancyGroupCount ; i ++ )
217
+ {
218
+ uint group = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
219
+ uint pop = BitConverter . ToUInt32 ( Extensions . ReadBytes ( buffer , 4 , ref internalOffset ) , 0 ) ;
220
+ OccupancyGroupsLimits . Add ( new OccupancyGroup ( i , Constants . OCCUPANCY_GROUPS [ i ] , group , pop ) ) ;
221
+ }
178
222
179
223
Logger . Log ( LogLevel . Info , "RegionView subfile parsed" ) ;
180
224
}
@@ -206,6 +250,23 @@ public void Dump()
206
250
Console . WriteLine ( "Mayor Name: {0}" , MayorName ) ;
207
251
Console . WriteLine ( "Internal Description Length: {0}" , InternalDescriptionLength ) ;
208
252
Console . WriteLine ( "Internal Description: {0}" , InternalDescription ) ;
253
+ Console . WriteLine ( "Default Mayor Name Length: {0}" , DefaultMayorNameLength ) ;
254
+ Console . WriteLine ( "Default Mayor Name: {0}" , DefaultMayorName ) ;
255
+ Console . WriteLine ( "Current Occupancy Group Count: {0}" , CurrentOccupancyGroupCount ) ;
256
+ foreach ( OccupancyGroup group in OccupancyGroupsCurrent )
257
+ {
258
+ group . Dump ( ) ;
259
+ }
260
+ Console . WriteLine ( "Max Occupancy Group Count: {0}" , MaxOccupancyGroupCount ) ;
261
+ foreach ( OccupancyGroup group in OccupancyGroupsMax )
262
+ {
263
+ group . Dump ( ) ;
264
+ }
265
+ Console . WriteLine ( "Limits Occupancy Group Count: {0}" , LimitsOccupancyGroupCount ) ;
266
+ foreach ( OccupancyGroup group in OccupancyGroupsLimits )
267
+ {
268
+ group . Dump ( ) ;
269
+ }
209
270
}
210
271
}
211
272
}
0 commit comments