changed name of preprocessor constant to improve readability
[rocksndiamonds.git] / src / libgame / system.c
index a7a12792b3668d0bfd41397679835774d89be2b6..a615b92fcefbe1c8f974fae1bcd8bdbe5b1f778e 100644 (file)
@@ -80,7 +80,7 @@ void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir,
   program.config_filename = config_filename;
 
   program.userdata_subdir = userdata_subdir;
-  program.userdata_path = getUserGameDataDir();
+  program.userdata_path = getMainUserGameDataDir();
 
   program.program_title = program_title;
   program.window_title = "(undefined)";
@@ -104,6 +104,25 @@ void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir,
   program.log_file[LOG_ERR_ID] = program.log_file_default[LOG_ERR_ID] = stderr;
 
   program.headless = FALSE;
+
+#if defined(PLATFORM_EMSCRIPTEN)
+  EM_ASM
+  (
+    Module.sync_done = 0;
+
+    FS.mkdir('/persistent');           // create persistent data directory
+    FS.mount(IDBFS, {}, '/persistent');        // mount with IDBFS filesystem type
+    FS.syncfs(true, function(err)      // sync persistent data into memory
+    {
+      assert(!err);
+      Module.sync_done = 1;
+    });
+  );
+
+  // wait for persistent data to be synchronized to memory
+  while (emscripten_run_script_int("Module.sync_done") == 0)
+    Delay(20);
+#endif
 }
 
 void InitNetworkInfo(boolean enabled, boolean connected, boolean serveronly,
@@ -1232,7 +1251,7 @@ void ReCreateGameTileSizeBitmap(Bitmap **bitmaps)
 
   if (gfx.game_tile_size == gfx.standard_tile_size)
   {
-    bitmaps[IMG_BITMAP_GAME] = bitmaps[IMG_BITMAP_STANDARD];
+    bitmaps[IMG_BITMAP_PTR_GAME] = bitmaps[IMG_BITMAP_STANDARD];
 
     return;
   }
@@ -1244,7 +1263,7 @@ void ReCreateGameTileSizeBitmap(Bitmap **bitmaps)
   Bitmap *bitmap_new = ZoomBitmap(bitmap, width, height);
 
   bitmaps[IMG_BITMAP_CUSTOM] = bitmap_new;
-  bitmaps[IMG_BITMAP_GAME]   = bitmap_new;
+  bitmaps[IMG_BITMAP_PTR_GAME] = bitmap_new;
 }
 
 static void CreateScaledBitmaps(Bitmap **bitmaps, int zoom_factor,
@@ -1394,9 +1413,9 @@ static void CreateScaledBitmaps(Bitmap **bitmaps, int zoom_factor,
       bitmaps[IMG_BITMAP_CUSTOM] = tmp_bitmap_0;
 
     if (bitmaps[IMG_BITMAP_CUSTOM])
-      bitmaps[IMG_BITMAP_GAME] = bitmaps[IMG_BITMAP_CUSTOM];
+      bitmaps[IMG_BITMAP_PTR_GAME] = bitmaps[IMG_BITMAP_CUSTOM];
     else
-      bitmaps[IMG_BITMAP_GAME] = bitmaps[IMG_BITMAP_STANDARD];
+      bitmaps[IMG_BITMAP_PTR_GAME] = bitmaps[IMG_BITMAP_STANDARD];
 
     boolean free_old_bitmap = TRUE;