diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-01-19 13:02:22 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-01-19 13:02:22 +0000 |
| commit | b5a6dacfa30d8f7a9714f2ea4694234b5d7c09bf (patch) | |
| tree | 2dc8ff1ac4ef40e4a6f73e473439f00a78a84688 /src/game/editor/ed_io.cpp | |
| parent | 6f2b43af9b83c69134a7a5ecb6e5820c42fcb135 (diff) | |
| download | zcatch-b5a6dacfa30d8f7a9714f2ea4694234b5d7c09bf.tar.gz zcatch-b5a6dacfa30d8f7a9714f2ea4694234b5d7c09bf.zip | |
fixed naming of images
Diffstat (limited to 'src/game/editor/ed_io.cpp')
| -rw-r--r-- | src/game/editor/ed_io.cpp | 8 |
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); } } |