summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7bc7d50)
raw | patch | inline | side by side (parent: 7bc7d50)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 19 Sep 2018 15:06:32 +0000 (18:06 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 19 Sep 2018 15:06:32 +0000 (18:06 +0300) |
src/editor/f_packmap.pas | patch | blob | history |
index bf3965687da05c7e7564592291a47d6420ef102c..ac1d07d3d2f216a815d4483442e9876c5c380f75 100644 (file)
--- a/src/editor/f_packmap.pas
+++ b/src/editor/f_packmap.pas
uses
BinEditor, WADEDITOR, g_map, MAPREADER, MAPWRITER, MAPSTRUCT,
- f_main, math, g_language;
+ f_main, math, g_language, g_resources;
{$R *.lfm}
eWAD.Text := SaveDialog.FileName;
end;
-function ProcessResource(wad_to: TWADEditor_1;
- section_to, filename, section, resource: String): Boolean;
-var
- wad2: TWADEditor_1;
- data: Pointer;
- reslen: Integer;
- //s: string;
-
+function ProcessResource(wad_to: TWADEditor_1; section_to, filename, section, resource: String): Boolean;
+ var
+ data: Pointer;
+ reslen: Integer;
begin
- Result := False;
-
if filename = '' then
g_ProcessResourceStr(OpenedMap, @filename, nil, nil)
else
- filename := EditorDir+'wads/'+filename;
-
-// Читаем ресурс из WAD-файла карты или какого-то другого:
- wad2 := TWADEditor_1.Create();
-
- if not wad2.ReadFile(filename) then
- begin
- MessageBox(0, PChar(Format(_lc[I_MSG_WAD_ERROR],
- [ExtractFileName(filename)])),
- PChar(_lc[I_MSG_ERROR]), MB_OK + MB_ICONERROR);
- wad2.Free();
- Exit;
- end;
-
- if not wad2.GetResource(utf2win(section), utf2win(resource), data, reslen) then
- begin
- MessageBox(0, PChar(Format(_lc[I_MSG_RES_ERROR],
- [filename, section, resource])),
- PChar(_lc[I_MSG_ERROR]), MB_OK + MB_ICONERROR);
- wad2.Free();
- Exit;
- end;
-
- wad2.Free();
+ filename := EditorDir + 'wads/' + filename;
- {if wad_to.HaveResource(utf2win(section_to), utf2win(resource)) then
- begin
- for a := 2 to 256 do
+ g_ReadResource(filename, section, resource, data, reslen);
+ if data <> nil then
begin
- s := IntToStr(a);
- if not wad_to.HaveResource(utf2win(section_to), utf2win(resource+s)) then Break;
- end;
- resource := resource+s;
- end;}
-
-// Если такого ресурса нет в WAD-файле-назначении, то копируем:
- if not wad_to.HaveResource(utf2win(section_to), utf2win(resource)) then
+ (* Write resource only if it does not exists *)
+ if not wad_to.HaveResource(utf2win(section_to), utf2win(resource)) then
+ begin
+ if not wad_to.HaveSection(utf2win(section_to)) then
+ wad_to.AddSection(utf2win(section_to));
+ wad_to.AddResource(data, reslen, utf2win(resource), utf2win(section_to))
+ end;
+ FreeMem(data);
+ Result := True
+ end
+ else
begin
- if not wad_to.HaveSection(utf2win(section_to)) then
- wad_to.AddSection(utf2win(section_to));
- wad_to.AddResource(data, reslen, utf2win(resource), utf2win(section_to));
- end;
-
- FreeMem(data);
-
- Result := True;
+ //MessageBox(0, PChar(Format(_lc[I_MSG_WAD_ERROR], [ExtractFileName(filename)])), PChar(_lc[I_MSG_ERROR]), MB_OK + MB_ICONERROR);
+ MessageBox(0, PChar(Format(_lc[I_MSG_RES_ERROR], [filename, section, resource])), PChar(_lc[I_MSG_ERROR]), MB_OK + MB_ICONERROR);
+ Result := False
+ end
end;
procedure TPackMapForm.bPackClick(Sender: TObject);