2020-06-21 18:48:53 -04:00
|
|
|
package d2datadict
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
|
|
)
|
|
|
|
|
2020-06-30 09:17:07 -04:00
|
|
|
// LevelMazeDetailsRecord is a representation of a row from lvlmaze.txt
|
|
|
|
// these records define the parameters passed to the maze level generator
|
2020-06-21 18:48:53 -04:00
|
|
|
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.
|
2020-06-29 12:37:11 -04:00
|
|
|
LevelID int // Level
|
2020-06-21 18:48:53 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2020-06-30 09:17:07 -04:00
|
|
|
// LevelMazeDetails stores all of the LevelMazeDetailsRecords
|
|
|
|
var LevelMazeDetails map[int]*LevelMazeDetailsRecord //nolint:gochecknoglobals // Currently global by design
|
2020-06-21 18:48:53 -04:00
|
|
|
|
2020-06-29 12:37:11 -04:00
|
|
|
// LoadLevelMazeDetails loads LevelMazeDetailsRecords from text file
|
2020-06-21 18:48:53 -04:00
|
|
|
func LoadLevelMazeDetails(file []byte) {
|
2020-07-07 08:56:31 -04:00
|
|
|
LevelMazeDetails = make(map[int]*LevelMazeDetailsRecord)
|
2020-06-29 12:37:11 -04:00
|
|
|
|
2020-07-07 08:56:31 -04:00
|
|
|
d := d2common.LoadDataDictionary(file)
|
|
|
|
for d.Next() {
|
2020-06-21 18:48:53 -04:00
|
|
|
record := &LevelMazeDetailsRecord{
|
2020-07-07 08:56:31 -04:00
|
|
|
Name: d.String("Name"),
|
|
|
|
LevelID: d.Number("Level"),
|
|
|
|
NumRoomsNormal: d.Number("Rooms"),
|
|
|
|
NumRoomsNightmare: d.Number("Rooms(N)"),
|
|
|
|
NumRoomsHell: d.Number("Rooms(H)"),
|
|
|
|
SizeX: d.Number("SizeX"),
|
|
|
|
SizeY: d.Number("SizeY"),
|
2020-06-21 18:48:53 -04:00
|
|
|
}
|
2020-06-29 12:37:11 -04:00
|
|
|
LevelMazeDetails[record.LevelID] = record
|
2020-06-21 18:48:53 -04:00
|
|
|
}
|
2020-06-29 12:37:11 -04:00
|
|
|
|
2020-07-07 08:56:31 -04:00
|
|
|
if d.Err != nil {
|
|
|
|
panic(d.Err)
|
|
|
|
}
|
|
|
|
|
2020-06-21 18:48:53 -04:00
|
|
|
log.Printf("Loaded %d LevelMazeDetails records", len(LevelMazeDetails))
|
|
|
|
}
|