X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_res_downloader.pas;h=471268ed20ba9645d44f4ade7564d55c24b6401c;hb=7292fe409145dfcbb2776e34bb64d56e32985b9d;hp=fc815dabc5b526302cc20640885a782a0f1e88d0;hpb=41d480b02f4d0257f13a87810c0053b8b0df3b13;p=d2df-sdl.git diff --git a/src/game/g_res_downloader.pas b/src/game/g_res_downloader.pas index fc815da..471268e 100644 --- a/src/game/g_res_downloader.pas +++ b/src/game/g_res_downloader.pas @@ -1,3 +1,19 @@ +(* Copyright (C) DooM 2D:Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$INCLUDE g_amodes.inc} unit g_res_downloader; interface @@ -9,7 +25,7 @@ function g_Res_DownloadWAD(const FileName: string): string; implementation -uses g_language, sfs, WADEDITOR; +uses g_language, sfs, utils, wadreader; const DOWNLOAD_DIR = 'downloads'; @@ -23,7 +39,7 @@ begin repeat if (searchResult.Attr and faDirectory) = 0 then begin - if SFSStrEqu(searchResult.Name, filename) then + if StrEquCI1251(searchResult.Name, filename) then begin files.Add(dirName+'/'+filename); Exit; @@ -90,15 +106,14 @@ end; function SaveWAD(const path, filename: string; const data: array of Byte): string; var - resFile: TFileStream; + resFile: TStream; + dpt: string; begin try - Result := path + DOWNLOAD_DIR + '/' + filename; - if not DirectoryExists(path + DOWNLOAD_DIR) then - begin - CreateDir(path + DOWNLOAD_DIR); - end; - resFile := TFileStream.Create(Result, fmCreate); + result := path+DOWNLOAD_DIR+'/'+filename; + dpt := path+DOWNLOAD_DIR; + if not findFileCI(dpt, true) then CreateDir(dpt); + resFile := createDiskFile(result); resFile.WriteBuffer(data[0], Length(data)); resFile.Free except @@ -109,7 +124,7 @@ end; function g_Res_DownloadWAD(const FileName: string): string; var msgStream: TMemoryStream; - resStream: TFileStream; + resStream: TStream; mapData: TMapDataMsg; i: Integer; resData: TResDataMsg; @@ -141,9 +156,7 @@ begin msgStream := g_Net_Wait_Event(NET_MSG_RES_RESPONSE); resData := ResDataFromMsgStream(msgStream); - resStream := TFileStream.Create(GameDir+'/wads/'+ - mapData.ExternalResources[i].Name, - fmCreate); + resStream := createDiskFile(GameDir+'/wads/'+mapData.ExternalResources[i].Name); resStream.WriteBuffer(resData.FileData[0], resData.FileSize); resData.FileData := nil;