summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-16 16:54:37 +0000
committerrubidium <rubidium@openttd.org>2011-11-16 16:54:37 +0000
commita3a2fdcfc2f8737ed1c52672c473b4fe32ac2bc9 (patch)
treec1d02f09d8f5a5eac339a90c080096e9e72a0010 /src/network
parent6548ec6e9ecf0f6d608d0b738213f62b1ce6e584 (diff)
downloadopenttd-a3a2fdcfc2f8737ed1c52672c473b4fe32ac2bc9.tar.xz
(svn r23234) -Fix [FS#4840]: crash when after downloading content
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_content.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 40bf03f97..d1a04c04e 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -530,13 +530,41 @@ void ClientNetworkContentSocketHandler::AfterDownload()
if (GunzipFile(this->curInfo)) {
unlink(GetFullFilename(this->curInfo, true));
- TarScanner ts;
- ts.AddFile(GetFullFilename(this->curInfo, false), 0);
-
if (this->curInfo->type == CONTENT_TYPE_BASE_MUSIC) {
/* Music can't be in a tar. So extract the tar! */
ExtractTar(GetFullFilename(this->curInfo, false), BASESET_DIR);
unlink(GetFullFilename(this->curInfo, false));
+ } else {
+ Subdirectory sd = NO_DIRECTORY;
+ switch (this->curInfo->type) {
+ case CONTENT_TYPE_AI:
+ sd = AI_DIR;
+ break;
+
+ case CONTENT_TYPE_AI_LIBRARY:
+ sd = AI_LIBRARY_DIR;
+ break;
+
+ case CONTENT_TYPE_BASE_GRAPHICS:
+ case CONTENT_TYPE_BASE_SOUNDS:
+ case CONTENT_TYPE_BASE_MUSIC:
+ sd = BASESET_DIR;
+ break;
+
+ case CONTENT_TYPE_NEWGRF:
+ sd = NEWGRF_DIR;
+ break;
+
+ case CONTENT_TYPE_SCENARIO:
+ case CONTENT_TYPE_HEIGHTMAP:
+ sd = SCENARIO_DIR;
+ break;
+
+ default: NOT_REACHED();
+ }
+
+ TarScanner ts;
+ ts.AddFile(sd, GetFullFilename(this->curInfo, false));
}
this->OnDownloadComplete(this->curInfo->id);