[gnome-2048] Allow spaces in saved game.



commit 5256824eddee72ac085d2a2f9b2d55e20e4ee8e0
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Feb 13 14:18:04 2019 +0100

    Allow spaces in saved game.
    
    That helps for manually editing
    a saved game, as you can align.

 src/grid.vala | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/grid.vala b/src/grid.vala
index f87182f..407d16b 100644
--- a/src/grid.vala
+++ b/src/grid.vala
@@ -579,7 +579,7 @@ private class Grid : Object
 
         for (uint i = 0; i < rows; i++)
         {
-            tokens = lines [i + 1].split (" ");
+            _parse_line (lines [i + 1], out tokens);
             // we do need to be strict here
             if (tokens.length != cols)
                 return false;
@@ -598,6 +598,16 @@ private class Grid : Object
         return true;
     }
 
+    private static inline void _parse_line (string line, out string [] tokens)
+    {
+        tokens = line.split (" ");
+        string [] _tokens = {};
+        foreach (string token in tokens)
+            if (token != "")
+                _tokens += token;
+        tokens = _tokens;
+    }
+
     private static inline bool _convert_tile_number (ref uint64 number_64,
                                                      out uint8 number)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]