From 2d8980ed7ed1f80e5e9e5db9af0eaa37857118bb Mon Sep 17 00:00:00 2001 From: w3irDv <170813473+w3irDv@users.noreply.github.com> Date: Sun, 26 May 2024 18:59:29 +0200 Subject: [PATCH] defer updating content.map until shared content is succesfully installed --- source/wad/wad.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/wad/wad.cpp b/source/wad/wad.cpp index 92343894..19c7ba81 100644 --- a/source/wad/wad.cpp +++ b/source/wad/wad.cpp @@ -322,13 +322,14 @@ bool Wad::InstallContents(const char *installpath) // Install content if(content->type == 0x8001) { // shared content - int result = UpdateContentMap(installpath, content, filepath); + int result = CheckContentMap(installpath, content, filepath); if(result == 1) // exists already, skip file continue; else if(result < 0) // failure return false; // else it does not exist...install it + snprintf(filepath, sizeof(filepath), "%s/shared1/%08x.app", installpath, (unsigned int)content_map_size); } else { // private content @@ -419,6 +420,16 @@ bool Wad::InstallContents(const char *installpath) ShowError(tr("File read/write error.")); return false; } + + if(content->type == 0x8001) { + // shared content installed ok. It's time to update content.map + int result = UpdateContentMap(installpath, content, filepath); + if(result == 1) // exists already, skip file + continue; + + else if(result < 0) // failure + return false; + } } return true; @@ -482,8 +493,6 @@ int Wad::UpdateContentMap(const char *installpath, tmd_content *content, char *f if(!WriteFile(filepath, content_map, content_map_size * sizeof(map_entry_t))) return -1; - snprintf(filepath, 1024, "%s/shared1/%08x.app", installpath, (unsigned int)next_entry); - return 0; }