[common] fix load old level format
This commit is contained in:
1
WORK.md
1
WORK.md
@@ -9,5 +9,4 @@
|
|||||||
* gamepad support
|
* gamepad support
|
||||||
* screen gamepad on mobiles
|
* screen gamepad on mobiles
|
||||||
* resize render on mobiles
|
* resize render on mobiles
|
||||||
* [bug] map load on linux
|
|
||||||
* [bug] game progress broken
|
* [bug] game progress broken
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ class LevelUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function loads(data:String):LevelConfig {
|
public static function loads(data:String):LevelConfig {
|
||||||
try {
|
// If first char is digit load as old format
|
||||||
|
if (Std.parseInt(data.charAt(0)) != null) {
|
||||||
|
return loadsOld(data);
|
||||||
|
} else {
|
||||||
var obj:LevelSource = Yaml.parse(data, Parser.options().useObjects());
|
var obj:LevelSource = Yaml.parse(data, Parser.options().useObjects());
|
||||||
return {
|
return {
|
||||||
data: obj.data.split('').map(function(c) return Std.parseInt(c)),
|
data: obj.data.split('').map(function(c) return Std.parseInt(c)),
|
||||||
@@ -48,8 +51,6 @@ class LevelUtil {
|
|||||||
name: obj.name,
|
name: obj.name,
|
||||||
size: obj.size,
|
size: obj.size,
|
||||||
}
|
}
|
||||||
} catch (error:Dynamic) {
|
|
||||||
return loadsOld(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user