make tmx.sex handle infinite maps gracefully
This commit is contained in:
19
tmx.sex
19
tmx.sex
@@ -71,6 +71,25 @@
|
||||
(tile-height int)))
|
||||
|
||||
(pub fn load-tmx ((file (* const char))) (* tmx-map)
|
||||
;; raytmx does not support Tiled infinite maps: their <chunk> data makes
|
||||
;; its CSV parser read past a fixed-size stack buffer. Reject them with a
|
||||
;; useful message instead of crashing inside the parser.
|
||||
(var raw (* char) (LoadFileText file))
|
||||
(if (== raw NULL)
|
||||
(do
|
||||
(TraceLog LOG-ERROR "failed to read TMX \"%s\"" file)
|
||||
(return NULL)))
|
||||
(var is-infinite (* char) (strstr raw "infinite=\"1\""))
|
||||
(var has-chunks (* char) (strstr raw "<chunk"))
|
||||
(if (|| (!= is-infinite NULL) (!= has-chunks NULL))
|
||||
(do
|
||||
(TraceLog LOG-ERROR
|
||||
"TMX \"%s\" is an infinite (chunked) map; raytmx only supports finite maps. Convert it with tools/tmx_to_finite.py"
|
||||
file)
|
||||
(UnloadFileText raw)
|
||||
(return NULL)))
|
||||
(UnloadFileText raw)
|
||||
|
||||
(var handle (* TmxMap) (LoadTMX file))
|
||||
(if (== handle NULL)
|
||||
(do
|
||||
|
||||
Reference in New Issue
Block a user