From 3bf759727ef86d4ea08a55ba482e7199bfdc856e Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 30 Jan 2010 16:04:42 +0000 Subject: [PATCH] Correct storing of filenames as well --- Src/gui/game_info.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Src/gui/game_info.cpp b/Src/gui/game_info.cpp index 87af57a..f8e6686 100644 --- a/Src/gui/game_info.cpp +++ b/Src/gui/game_info.cpp @@ -88,6 +88,7 @@ struct game_info *GameInfo::dump() total_sz += strlen(this->author) + 1; total_sz += strlen(this->name) + 1; + total_sz += strlen(this->filename) + 1; total_sz += png_sz; /* 4-byte align */ @@ -99,16 +100,19 @@ struct game_info *GameInfo::dump() out->version_magic = VERSION_MAGIC; out->author_off = 0; /* Starts AFTER the header */ out->name_off = out->author_off + strlen(this->author) + 1; - out->screenshot_off = out->name_off + strlen(this->name) + 1; + out->filename_off = out->name_off + strlen(this->name) + 1; + out->screenshot_off = out->filename_off + strlen(this->filename) + 1; memcpy(out->data + out->author_off, this->author, strlen(this->author) + 1); memcpy(out->data + out->name_off, this->name, strlen(this->name) + 1); + memcpy(out->data + out->filename_off, this->filename, strlen(this->filename) + 1); memcpy(out->data + out->screenshot_off, png_data, png_sz); out->sz = htonl(out->sz); out->author_off = htons(out->author_off); out->version_magic = htons(out->version_magic); out->name_off = htons(out->name_off); + out->filename_off = htons(out->filename_off); out->screenshot_off = htons(out->screenshot_off); return out; @@ -122,11 +126,12 @@ bool GameInfo::fromDump(struct game_info *gi) gi->version_magic = ntohs(gi->version_magic); gi->author_off = ntohs(gi->author_off); gi->name_off = ntohs(gi->name_off); + gi->filename_off = ntohs(gi->filename_off); gi->screenshot_off = ntohs(gi->screenshot_off); this->author = xstrdup((char*)gi->data + gi->author_off); this->name = xstrdup((char*)gi->data + gi->name_off); - this->filename = xstrdup(" "); + this->filename = xstrdup((char*)gi->data + gi->filename_off); rw = SDL_RWFromMem(gi->data + gi->screenshot_off, gi->sz - gi->screenshot_off);