about summary refs log tree commit diff
path: root/src/game/editor/ed_io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/editor/ed_io.cpp')
-rw-r--r--src/game/editor/ed_io.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp
index 77ae8242..653e84b2 100644
--- a/src/game/editor/ed_io.cpp
+++ b/src/game/editor/ed_io.cpp
@@ -1,3 +1,4 @@
+#include <string.h>
 #include "ed_editor.hpp"
 
 template<typename T>
@@ -214,7 +215,7 @@ int EDITOR::save(const char *filename)
 		item.width = img->width;
 		item.height = img->height;
 		item.external = 0;
-		item.image_name = -1;
+		item.image_name = datafile_add_data(df, strlen(img->name)+1, img->name);
 		item.image_data = datafile_add_data(df, item.width*item.height*4, img->data);
 		datafile_add_item(df, MAPITEMTYPE_IMAGE, i, sizeof(item), &item);
 	}
@@ -353,12 +354,16 @@ int EDITOR::load(const char *filename)
 			{
 				MAPITEM_IMAGE *item = (MAPITEM_IMAGE *)datafile_get_item(df, start+i, 0, 0);
 				void *data = datafile_get_data(df, item->image_data);
+				char *name = (char *)datafile_get_data(df, item->image_name);
 				
 				IMAGE *img = new IMAGE;
 				img->width = item->width;
 				img->height = item->height;
 				img->format = IMG_RGBA;
 				
+				if(name)
+					strncpy(img->name, name, 128);
+				
 				// copy image data
 				img->data = mem_alloc(img->width*img->height*4, 1);
 				mem_copy(img->data, data, img->width*img->height*4);
@@ -367,6 +372,7 @@ int EDITOR::load(const char *filename)
 				
 				// unload image
 				datafile_unload_data(df, item->image_data);
+				datafile_unload_data(df, item->image_name);
 			}
 		}