From 3fe57700a553fb5954d1af112ac33663acd874f8 Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 21 Jun 2020 15:48:53 -0700 Subject: [PATCH] adding loader for level maze details (#377) --- d2common/d2data/d2datadict/level_maze.go | 56 ++++++++++++++++++++++++ d2common/d2resource/resource_paths.go | 2 + main.go | 1 + 3 files changed, 59 insertions(+) create mode 100644 d2common/d2data/d2datadict/level_maze.go diff --git a/d2common/d2data/d2datadict/level_maze.go b/d2common/d2data/d2datadict/level_maze.go new file mode 100644 index 00000000..53103a79 --- /dev/null +++ b/d2common/d2data/d2datadict/level_maze.go @@ -0,0 +1,56 @@ +package d2datadict + +import ( + "log" + + "github.com/OpenDiablo2/OpenDiablo2/d2common" +) + +type LevelMazeDetailsRecord struct { + // descriptive, not loaded in game. Corresponds with Name field in + // Levels.txt + Name string // Name + + // ID from Levels.txt + // NOTE: Cave 1 is the Den of Evil, its associated treasure level is quest + // only. + LevelId int // Level + + // the minimum number of .ds1 map sections that will make up the maze in + // Normal, Nightmare and Hell difficulties. + NumRoomsNormal int // Rooms + NumRoomsNightmare int // Rooms(N) + NumRoomsHell int // Rooms(H) + + // the size in the X\Y direction of any component ds1 map section. + SizeX int // SizeX + SizeY int // SizeY + + // Possibly related to how adjacent .ds1s are connected with each other, + // but what the different values are for is unknown. + // Merge int // Merge + + // Included in the original Diablo II beta tests and in the demo version. + // Beta +} + +var LevelMazeDetails map[int]*LevelMazeDetailsRecord + +func LoadLevelMazeDetails(file []byte) { + dict := d2common.LoadDataDictionary(string(file)) + numRecords := len(dict.Data) + LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord, numRecords) + for idx, _ := range dict.Data { + record := &LevelMazeDetailsRecord{ + Name: dict.GetString("Name", idx), + LevelId: dict.GetNumber("Level", idx), + NumRoomsNormal: dict.GetNumber("Rooms", idx), + NumRoomsNightmare: dict.GetNumber("Rooms(N)", idx), + NumRoomsHell: dict.GetNumber("Rooms(H)", idx), + SizeX: dict.GetNumber("SizeX", idx), + SizeY: dict.GetNumber("SizeY", idx), + } + LevelMazeDetails[record.LevelId] = record + } + log.Printf("Loaded %d LevelMazeDetails records", len(LevelMazeDetails)) +} diff --git a/d2common/d2resource/resource_paths.go b/d2common/d2resource/resource_paths.go index 49f8c6fa..1444f484 100644 --- a/d2common/d2resource/resource_paths.go +++ b/d2common/d2resource/resource_paths.go @@ -173,7 +173,9 @@ const ( ObjectType = "/data/global/excel/objtype.bin" LevelWarp = "/data/global/excel/LvlWarp.bin" LevelDetails = "/data/global/excel/Levels.txt" + LevelMaze = "/data/global/excel/LvlMaze.txt" LevelSubstitutions = "/data/global/excel/LvlSub.txt" + ObjectDetails = "/data/global/excel/Objects.txt" SoundSettings = "/data/global/excel/Sounds.txt" ItemStatCost = "/data/global/excel/ItemStatCost.txt" diff --git a/main.go b/main.go index d2be9372..3cb85ad4 100644 --- a/main.go +++ b/main.go @@ -412,6 +412,7 @@ func loadDataDict() error { {d2resource.DifficultyLevels, d2datadict.LoadDifficultyLevels}, {d2resource.AutoMap, d2datadict.LoadAutoMaps}, {d2resource.LevelDetails, d2datadict.LoadLevelDetails}, + {d2resource.LevelMaze, d2datadict.LoadLevelMazeDetails}, {d2resource.LevelSubstitutions, d2datadict.LoadLevelSubstitutions}, }