55 "encoding/json"
66 "io"
77 "maps"
8+ "reflect"
89 "slices"
910)
1011
@@ -45,9 +46,9 @@ type AreaHeader struct {
4546 AmbientCount uint16 `json:"ambient_count"`
4647 AmbientOffset uint32 `json:"ambient_offset"`
4748 VariableOffset uint32 `json:"variable_offset"`
48- VariableCount uint16 `json:"variable_count"`
49+ VariableCount uint32 `json:"variable_count"`
50+ TiledObjectFlagOffset uint16 `json:"tiled_object_flag_offset"`
4951 TiledObjectFlagCount uint16 `json:"tiled_object_flag_count"`
50- TiledObjectFlagOffset uint32 `json:"tiled_object_flag_offset"`
5152 Script Resref `json:"script"`
5253 ExploredSize uint32 `json:"explored_size"`
5354 ExploredOffset uint32 `json:"explored_offset"`
@@ -343,7 +344,7 @@ type AreaSong struct {
343344
344345type AreaRestEncounter struct {
345346 Name LongString `json:"name"`
346- RandomCreatureString [10 ]uint32 `json:"random_creature_string"`
347+ RandomCreatureString [10 ]strref `json:"random_creature_string"`
347348 RandomCreature [10 ]Resref `json:"random_creature"`
348349 RandomCreatureNum uint16 `json:"random_creature_num"`
349350 Difficulty uint16 `json:"difficulty"`
@@ -354,7 +355,7 @@ type AreaRestEncounter struct {
354355 Activated uint16 `json:"activated"`
355356 ProbabilityDay uint16 `json:"probability_day"`
356357 ProbabilityNight uint16 `json:"probability_night"`
357- Unused [14 ] uint32 `json:"unused"`
358+ Unused [56 ] uint8 `json:"unused"`
358359}
359360
360361type Area struct {
@@ -379,6 +380,64 @@ type Area struct {
379380 Filename string `json:"-"`
380381}
381382
383+ func (a * Area ) Equal (other * Area ) bool {
384+ if ! reflect .DeepEqual (a .AreaHeader , other .AreaHeader ) {
385+ return false
386+ }
387+ if ! slices .Equal (a .Actors , other .Actors ) {
388+ return false
389+ }
390+ if ! slices .Equal (a .Regions , other .Regions ) {
391+ return false
392+ }
393+ if ! slices .Equal (a .SpawnPoints , other .SpawnPoints ) {
394+ return false
395+ }
396+ if ! slices .Equal (a .Entrances , other .Entrances ) {
397+ return false
398+ }
399+ if ! slices .Equal (a .Containers , other .Containers ) {
400+ return false
401+ }
402+ if ! slices .Equal (a .Items , other .Items ) {
403+ return false
404+ }
405+ if ! slices .Equal (a .Vertices , other .Vertices ) {
406+ return false
407+ }
408+ if ! slices .Equal (a .Ambients , other .Ambients ) {
409+ return false
410+ }
411+ if ! slices .Equal (a .Variables , other .Variables ) {
412+ return false
413+ }
414+ if ! slices .Equal (a .ExploredBitmasks , other .ExploredBitmasks ) {
415+ return false
416+ }
417+ if ! slices .Equal (a .Doors , other .Doors ) {
418+ return false
419+ }
420+ if ! slices .Equal (a .Animations , other .Animations ) {
421+ return false
422+ }
423+ if ! slices .Equal (a .MapNotes , other .MapNotes ) {
424+ return false
425+ }
426+ if ! slices .Equal (a .TiledObjects , other .TiledObjects ) {
427+ return false
428+ }
429+ if ! slices .Equal (a .Traps , other .Traps ) {
430+ return false
431+ }
432+ if ! reflect .DeepEqual (a .Songs , other .Songs ) {
433+ return false
434+ }
435+ if ! reflect .DeepEqual (a .RestInterruptions , other .RestInterruptions ) {
436+ return false
437+ }
438+ return true
439+ }
440+
382441func OpenArea (r io.ReadSeeker ) (* Area , error ) {
383442 area := Area {}
384443
@@ -505,24 +564,24 @@ func (are *Area) Write(w io.Writer) error {
505564 return err
506565 }
507566 order := map [uint32 ]func () error {
508- are .ActorsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Actors ) },
509- are .RegionOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Regions ) },
510- are .SpawnPointOffset : func () error { return binary .Write (w , binary .LittleEndian , are .SpawnPoints ) },
511- are .EntranceOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Entrances ) },
512- are .ContainerOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Containers ) },
513- are .ItemOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Items ) },
514- are .VertexOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Vertices ) },
515- are .AmbientOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Ambients ) },
516- are .VariableOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Variables ) },
517- are .TiledObjectFlagOffset : func () error { return binary .Write (w , binary .LittleEndian , are .TiledObjects ) },
518- are .ExploredOffset : func () error { return binary .Write (w , binary .LittleEndian , are .ExploredBitmasks ) },
519- are .DoorsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Doors ) },
520- are .AnimationOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Animations ) },
521- are .TiledObjectOffset : func () error { return binary .Write (w , binary .LittleEndian , are .TiledObjects ) },
522- are .SongEntriesOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Songs ) },
523- are .RestInterruptionsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .RestInterruptions ) },
524- are .AutomapOffset : func () error { return binary .Write (w , binary .LittleEndian , are .MapNotes ) },
525- are .ProjectileTrapsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Traps ) },
567+ are .ActorsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Actors ) },
568+ are .RegionOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Regions ) },
569+ are .SpawnPointOffset : func () error { return binary .Write (w , binary .LittleEndian , are .SpawnPoints ) },
570+ are .EntranceOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Entrances ) },
571+ are .ContainerOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Containers ) },
572+ are .ItemOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Items ) },
573+ are .VertexOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Vertices ) },
574+ are .AmbientOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Ambients ) },
575+ are .VariableOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Variables ) },
576+ uint32 ( are .TiledObjectFlagOffset ): func () error { return binary .Write (w , binary .LittleEndian , are .TiledObjects ) },
577+ are .ExploredOffset : func () error { return binary .Write (w , binary .LittleEndian , are .ExploredBitmasks ) },
578+ are .DoorsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Doors ) },
579+ are .AnimationOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Animations ) },
580+ are .TiledObjectOffset : func () error { return binary .Write (w , binary .LittleEndian , are .TiledObjects ) },
581+ are .SongEntriesOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Songs ) },
582+ are .RestInterruptionsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .RestInterruptions ) },
583+ are .AutomapOffset : func () error { return binary .Write (w , binary .LittleEndian , are .MapNotes ) },
584+ are .ProjectileTrapsOffset : func () error { return binary .Write (w , binary .LittleEndian , are .Traps ) },
526585 }
527586 for _ , key := range slices .Sorted (maps .Keys (order )) {
528587 if err := order [key ](); err != nil {
0 commit comments