diff --git a/cmd/screp/screp.go b/cmd/screp/screp.go index 355d11d..0b3725a 100644 --- a/cmd/screp/screp.go +++ b/cmd/screp/screp.go @@ -24,7 +24,7 @@ import ( const ( appName = "screp" - appVersion = "v1.11.3" + appVersion = "v1.11.4" appAuthor = "Andras Belicza" appHome = "https://github.com/icza/screp" ) diff --git a/rep/mapdata.go b/rep/mapdata.go index d2b99b1..9768aa5 100644 --- a/rep/mapdata.go +++ b/rep/mapdata.go @@ -18,6 +18,8 @@ type MapData struct { // TileSet defines the tile set used on the map. TileSet *repcore.TileSet + TileSetMissing bool `json:"tileSetMissing,omitempty"` + // Scenario name Name string diff --git a/repparser/repparser.go b/repparser/repparser.go index 5390080..87ef7a4 100644 --- a/repparser/repparser.go +++ b/repparser/repparser.go @@ -60,7 +60,7 @@ import ( const ( // Version is a Semver2 compatible version of the parser. - Version = "v1.11.3" + Version = "v1.11.4" ) var ( @@ -775,6 +775,12 @@ func parseMapData(data []byte, r *rep.Replay, cfg Config) error { md.MapGraphics = &rep.MapGraphics{} } + // Even though "ERA " section is mandatory, I've seen reps where it was missing. + // TileSet may be cruitial for some apps, let's ensure it doesn't remain nil. + // Somewhat arbitrary default: + md.TileSet = repcore.TileSetTwilight + md.TileSetMissing = true + var ( scenarioNameIdx uint16 // String index scenarioDescriptionIdx uint16 // String index @@ -793,6 +799,7 @@ func parseMapData(data []byte, r *rep.Replay, cfg Config) error { md.Version = sr.getUint16() case "ERA ": // Tile set sub-section md.TileSet = repcore.TileSetByID(sr.getUint16() & 0x07) + md.TileSetMissing = false case "DIM ": // Dimension sub-section // If map has a non-standard size, the replay header contains // invalid map size, this is the correct one.