adding loader for level maze details (#377)

This commit is contained in:
dk 2020-06-21 15:48:53 -07:00 committed by GitHub
parent 485e60683b
commit 3fe57700a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 0 deletions

View File

@ -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))
}

View File

@ -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"

View File

@ -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},
}