fixed graphical bug when snap-pushing with smooth movement in BD engine
[rocksndiamonds.git] / src / game_bd / bd_caveset.c
index af02d741f52847cf56ed2bec6211371573f3c6fa..0ee9c3b82d9ee59208d0bd0b0d2c2bc8f2f6ee25 100644 (file)
@@ -87,6 +87,9 @@ GdCavesetData *gd_caveset_data_new(void)
 
   gd_struct_set_defaults_from_array(data, gd_caveset_properties, caveset_defaults);
 
+  if (leveldir_current != NULL)
+    data->levelset_subdir = getStringCopy(leveldir_current->subdir);
+
   return data;
 }
 
@@ -99,7 +102,9 @@ void gd_caveset_data_free(GdCavesetData *data)
     if (gd_caveset_properties[i].type == GD_TYPE_LONGSTRING)
       checked_free(STRUCT_MEMBER(char *, data, gd_caveset_properties[i].offset));
 
-  free(data);
+  checked_free(data->levelset_subdir);
+
+  checked_free(data);
 }
 
 // ============================================================================
@@ -118,14 +123,16 @@ void gd_caveset_clear(void)
 
   if (gd_caveset_data)
   {
-    free(gd_caveset_data);
+    gd_caveset_data_free(gd_caveset_data);
     gd_caveset_data = NULL;
   }
 
   // always newly create this
   // create pseudo cave containing default values
   gd_caveset_data = gd_caveset_data_new();
-  gd_strcpy(gd_caveset_data->name, getCurrentLevelsetName());
+
+  if (leveldir_current != NULL)
+    gd_strcpy(gd_caveset_data->name, leveldir_current->name);
 }
 
 // return number of caves currently in memory.