More map trailer work
This commit is contained in:
@@ -48,25 +48,40 @@ type Header struct {
|
||||
// Need to investigate the rest of the header too
|
||||
}
|
||||
|
||||
type Trailer struct {
|
||||
Unknown1 uint16
|
||||
Unknown2 uint16
|
||||
Unknown3 uint32
|
||||
Unknown4 uint32
|
||||
Unknown5 uint32
|
||||
type TrailerHeader struct {
|
||||
Discard1 [3]byte // No idea what this lot is
|
||||
MaxWidth uint32
|
||||
MaxLength uint32
|
||||
MinWidth uint32
|
||||
MinLength uint32
|
||||
|
||||
NumCharacters uint32
|
||||
Padding1 uint32
|
||||
Unknown6 uint16
|
||||
Unknown7 uint16
|
||||
Unknown8 uint32
|
||||
|
||||
Unknown1 uint32
|
||||
Unknown2 uint16
|
||||
Unknown3 uint16
|
||||
Unknown4 uint32
|
||||
NumThingies uint32
|
||||
Padding2 [36]byte
|
||||
Padding1 [20]byte
|
||||
}
|
||||
|
||||
type TrailerTrailer struct {
|
||||
Title [255]byte
|
||||
Briefing [2048]byte
|
||||
Unknown1 [85]uint8 // Maybe? each contains either 0 or 1? Hard to say
|
||||
}
|
||||
|
||||
type Character struct {
|
||||
Unknown1 uint32
|
||||
}
|
||||
|
||||
type Characters []Character
|
||||
|
||||
// TODO. These are triggers/reactors/etc.
|
||||
type Thingy struct {}
|
||||
|
||||
type Thingies []Thingy
|
||||
|
||||
func (h Header) Width() int {
|
||||
return int(h.MaxWidth - h.MinWidth)
|
||||
}
|
||||
@@ -189,7 +204,14 @@ func (h Header) Check() []error {
|
||||
type GameMap struct {
|
||||
Header
|
||||
Cells
|
||||
// TODO: parse this into sections
|
||||
TrailerHeader
|
||||
Characters
|
||||
Thingies
|
||||
TrailerTrailer
|
||||
|
||||
// TODO: parse this into sections. This is the text that comes from the
|
||||
// .TXT file. Maybe we don't need it at all since it should be duplicated in
|
||||
// the trailer.
|
||||
Text string
|
||||
}
|
||||
|
||||
@@ -305,5 +327,37 @@ func loadMapFile(filename string) (*GameMap, error) {
|
||||
return nil, fmt.Errorf("Error parsing cells for %s: %v", filename, err)
|
||||
}
|
||||
|
||||
if err := binary.Read(zr, binary.LittleEndian, &out.TrailerHeader); err != nil {
|
||||
return nil, fmt.Errorf("Error parsing trailer header for %s: %v", filename, err)
|
||||
}
|
||||
|
||||
log.Printf("Trailer Header: %#+v", out.TrailerHeader)
|
||||
/*
|
||||
// TODO: until we know how large each character record should be, we can't read this lot
|
||||
|
||||
out.Characters = make(Characters, int(out.TrailerHeader.NumCharacters))
|
||||
if err := binary.Read(zr, binary.LittleEndian, &out.Characters); err != nil {
|
||||
return nil, fmt.Errorf("Error parsing characters for %s: %v", filename, err)
|
||||
}
|
||||
|
||||
out.Thingies = make(Thingies, int(out.TrailerHeader.NumThingies))
|
||||
if err := binary.Read(zr, binary.LittleEndian, &out.Thingies); err != nil {
|
||||
return nil, fmt.Errorf("Error parsing thingies for %s: %v", filename, err)
|
||||
}
|
||||
|
||||
if err := binary.Read(zr, binary.LittleEndian, &out.TrailerTrailer); err != nil {
|
||||
return nil, fmt.Errorf("Error parsing trailer trailer for %s: %v", filename, err)
|
||||
}
|
||||
log.Printf("Trailer Trailer: %s", out.TrailerTrailer.String())
|
||||
*/
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (t *TrailerTrailer) String() string {
|
||||
return fmt.Sprintf(
|
||||
"title=%q briefing=%q rest=%#+v",
|
||||
strings.TrimRight(string(t.Title[:]), "\x00"),
|
||||
strings.TrimRight(string(t.Briefing[:]), "\x00"),
|
||||
t.Unknown1,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user