From 1b36016a1a8556e6861012378c7e61f68ce6a962 Mon Sep 17 00:00:00 2001 From: shmyga Date: Thu, 20 Jun 2019 11:16:17 +0300 Subject: [PATCH] [common] fix load old level format --- WORK.md | 1 - src/common/haxe/ru/m/tankz/util/LevelUtil.hx | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WORK.md b/WORK.md index 1616f3d..94a965b 100644 --- a/WORK.md +++ b/WORK.md @@ -9,5 +9,4 @@ * gamepad support * screen gamepad on mobiles * resize render on mobiles -* [bug] map load on linux * [bug] game progress broken diff --git a/src/common/haxe/ru/m/tankz/util/LevelUtil.hx b/src/common/haxe/ru/m/tankz/util/LevelUtil.hx index 05b37de..5b3110b 100644 --- a/src/common/haxe/ru/m/tankz/util/LevelUtil.hx +++ b/src/common/haxe/ru/m/tankz/util/LevelUtil.hx @@ -40,7 +40,10 @@ class LevelUtil { } 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()); return { data: obj.data.split('').map(function(c) return Std.parseInt(c)), @@ -48,8 +51,6 @@ class LevelUtil { name: obj.name, size: obj.size, } - } catch (error:Dynamic) { - return loadsOld(data); } }