| 44 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 | 
   | 
 procedure TForm_LevelDB.CreateLevel(Source, Target: String); | 
 
 
 
 
 
 
 
 
 | 47 | 
 + | 
 const | 
 
 
 
 
 
 
 
 
 | 48 | 
 + | 
   EmptyBytes: Array[0..31] of Byte = ( | 
 
 
 
 
 
 
 
 
 | 49 | 
 + | 
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | 
   | 
 var | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | 
   | 
   DatHeader:        THeader; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
   | 
   FilesHeader:      TFilesMap; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 | 
   | 
   RawLinks:   TRawDataList; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 78 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | 
   | 
   DatFileStream, RawFileStream: TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 | 77 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 | 78 | 
 – | 
 // ########################### | 
 
 
 
 
 
 
 
 
 
 | 79 | 
 – | 
   datsum, linksum, rawsum: Int64; | 
 
 
 
 
 
 
 
 
 
 | 80 | 
 – | 
   freq: Int64; | 
 
 
 
 
 
 
 
 
 
 | 81 | 
 – | 
   tempticks1, tempticks2: Int64; | 
 
 
 
 
 
 
 
 
 
 | 82 | 
 – | 
 // ########################### | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
   | 
 const | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
   | 
   Steps: Byte = 3; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 294 | 
   | 
   lbl_estimation.Caption := 'Estimated finishing time: unknown'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 295 | 
   | 
   Application.ProcessMessages; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 296 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 300 | 
 – | 
   QueryPerformanceFrequency(freq); | 
 
 
 
 
 
 
 
 
 
 | 301 | 
 – | 
   datsum := 0; | 
 
 
 
 
 
 
 
 
 
 | 302 | 
 – | 
   linksum := 0; | 
 
 
 
 
 
 
 
 
 
 | 303 | 
 – | 
   rawsum := 0; | 
 
 
 
 
 
 
 
 
 
 | 304 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 297 | 
   | 
   FileTime := Time; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 298 | 
   | 
   for FileID := 0 to DatHeader.Files - 1 do | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 299 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 302 | 
   | 
       FilesHeader[FileID].Extension[j] := FileInfo.Extension[4 - j]; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 303 | 
   | 
     if FileInfo.Size > 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 304 | 
   | 
     begin | 
 
 
 
 
 
 
 
 
 
 | 313 | 
 – | 
       QueryPerformanceCounter(tempticks1); | 
 
 
 
 
 
 
 
 
 
 | 314 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 305 | 
   | 
       FilesHeader[FileID].DataAddr := Stream_Body.Size + 8; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 306 | 
   | 
       DatFileStream := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 307 | 
   | 
       Connection.LoadDatFile(FileID, TStream(DatFileStream)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 310 | 
   | 
       DatFileStream.Write(tempi, 4); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 311 | 
   | 
       DatFileStream.Write(LevelID, 4); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 312 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 323 | 
 – | 
       QueryPerformanceCounter(tempticks2); | 
 
 
 
 
 
 
 
 
 
 | 324 | 
 – | 
       datsum := datsum + (tempticks2 - tempticks1); | 
 
 
 
 
 
 
 
 
 
 | 325 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 313 | 
   | 
       DatLinks := Connection.GetDatLinks(FileID); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 314 | 
   | 
       if Length(DatLinks) > 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 315 | 
   | 
       begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 324 | 
   | 
         end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 325 | 
   | 
       end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 326 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 340 | 
 – | 
       QueryPerformanceCounter(tempticks1); | 
 
 
 
 
 
 
 
 
 
 | 341 | 
 – | 
       linksum := linksum + (tempticks1 - tempticks2); | 
 
 
 
 
 
 
 
 
 
 | 342 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 327 | 
   | 
       RawLinks := Connection.GetRawList(FileID); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 328 | 
   | 
       if Length(RawLinks) > 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 329 | 
   | 
       begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 338 | 
   | 
             begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 339 | 
   | 
               RawLinks[i].RawAddr := Stream_Sep.Size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 340 | 
   | 
               Stream_sep.CopyFrom(RawFileStream, RawFileStream.Size); | 
 
 
 
 
 
 
 
 
 | 341 | 
 + | 
               if (Stream_Sep.Size mod 32) > 0 then | 
 
 
 
 
 
 
 
 
 | 342 | 
 + | 
                 Stream_Sep.Write(EmptyBytes[0], 32 - (Stream_Sep.Size mod 32)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 343 | 
   | 
             end else begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 344 | 
   | 
               RawLinks[i].RawAddr := Stream_Raw.Size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 345 | 
   | 
               Stream_Raw.CopyFrom(RawFileStream, RawFileStream.Size); | 
 
 
 
 
 
 
 
 
 | 346 | 
 + | 
               if (Stream_Raw.Size mod 32) > 0 then | 
 
 
 
 
 
 
 
 
 | 347 | 
 + | 
                 Stream_Raw.Write(EmptyBytes[0], 32 - (Stream_Raw.Size mod 32)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 348 | 
   | 
             end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 349 | 
   | 
           end else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 350 | 
   | 
             RawLinks[i].RawAddr := 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 354 | 
   | 
       end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 355 | 
   | 
       DatFileStream.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 356 | 
   | 
       Stream_Body.CopyFrom(DatFileStream, DatFileStream.Size); | 
 
 
 
 
 
 
 
 
 
 
 
 | 357 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 358 | 
 < | 
       QueryPerformanceCounter(tempticks2); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 371 | 
 < | 
       rawsum := rawsum + (tempticks2 - tempticks1); | 
 
 
 
 
 
 
 
 
 
 | 357 | 
 > | 
       if (Stream_Body.Size mod 32) > 0 then | 
 
 
 
 
 
 | 358 | 
 > | 
         Stream_Body.Write(EmptyBytes[0], 32 - (Stream_Body.Size mod 32)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 359 | 
   | 
     end | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 360 | 
   | 
     else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 361 | 
   | 
       FilesHeader[FileID].DataAddr := 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 378 | 
   | 
     Application.ProcessMessages; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 379 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 380 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 394 | 
 – | 
   ShowMessage('AvgDats: ' + FloatToStr((datsum / progress.Max) / freq) + #13#10 + | 
 
 
 
 
 
 
 
 
 
 | 395 | 
 – | 
       'AvgLinks: ' + FloatToStr((linksum / progress.Max) / freq) + #13#10 + | 
 
 
 
 
 
 
 
 
 
 | 396 | 
 – | 
       'AvgRaws: ' + FloatToStr((rawsum / progress.Max) / freq) | 
 
 
 
 
 
 
 
 
 
 | 397 | 
 – | 
    ); | 
 
 
 
 
 
 
 
 
 
 | 398 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 381 | 
   | 
   Stream_Dat.Write(DatHeader, SizeOf(DatHeader)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 382 | 
   | 
   for i := 0 to High(FilesHeader) do | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 383 | 
   | 
     Stream_Dat.Write(FilesHeader[i], SizeOf(FilesHeader[i])); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 386 | 
   | 
   for i := 0 to High(ExtensionsHeader) do | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 387 | 
   | 
     Stream_Dat.Write(ExtensionsHeader[i], SizeOf(ExtensionsHeader[i])); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 388 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 389 | 
 + | 
   if (Stream_Dat.Size mod 32) > 0 then | 
 
 
 
 
 
 
 
 
 | 390 | 
 + | 
     Stream_Dat.Write(EmptyBytes[0], 32 - (Stream_Dat.Size mod 32)); | 
 
 
 
 
 
 
 
 
 | 391 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 392 | 
   | 
   DatHeader.DataSize  := Stream_Body.Size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 393 | 
   | 
   DatHeader.NamesSize := Stream_Names.Size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 394 | 
   | 
   DatHeader.DataAddr  := Stream_Dat.Size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 395 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 396 | 
   | 
   Stream_Body.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 397 | 
   | 
   Stream_Dat.CopyFrom(Stream_Body, Stream_Body.Size); | 
 
 
 
 
 
 
 
 
 | 398 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 399 | 
 + | 
   if (Stream_Dat.Size mod 32) > 0 then | 
 
 
 
 
 
 
 
 
 | 400 | 
 + | 
     Stream_Dat.Write(EmptyBytes[0], 32 - (Stream_Dat.Size mod 32)); | 
 
 
 
 
 
 
 
 
 | 401 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 402 | 
   | 
   DatHeader.NamesAddr := Stream_Dat.Size; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 403 | 
   | 
   Stream_Names.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 404 | 
   | 
   Stream_Dat.CopyFrom(Stream_Names, Stream_Names.Size); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 439 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 440 | 
   | 
   BeginTime, FileTime: Double; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 441 | 
   | 
   Step:       Integer; | 
 
 
 
 
 
 
 
 
 
 | 453 | 
 – | 
   LevelID:    Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 442 | 
   | 
   TimeFormat: TFormatSettings; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 443 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 444 | 
   | 
   ConID:      Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 447 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 448 | 
   | 
   FileID:     Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 449 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 462 | 
 – | 
   Strings:    TStrings; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 450 | 
   | 
   i:          Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 451 | 
   | 
   temps:      String; | 
 
 
 
 
 
 
 
 
 
 | 465 | 
 – | 
   tempi:      Integer; | 
 
 
 
 
 
 
 
 
 
 | 466 | 
 – | 
   tempb:      Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 452 | 
   | 
   tempdata:   TByteData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 453 | 
   | 
   FileInfo:   TFileInfo; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 454 | 
   | 
   DatLinks:   TDatLinkList; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 620 | 
   | 
   DoStep('Writing .dat-fileslist'); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 621 | 
   | 
   Application.ProcessMessages; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 622 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 623 | 
 + | 
   FileTime := Time; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 624 | 
   | 
   Database.StartTransaction; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 625 | 
   | 
   for FileID := 0 to Connection.GetFileCount - 1 do | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 626 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 664 | 
   | 
               BoolToStr(RawLinks[i].LocSep) + ', 0);'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 665 | 
   | 
             Query.ExecSQL; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 666 | 
   | 
           end; | 
 
 
 
 
 
 
 
 
 | 667 | 
 + | 
           if ((i mod 100) = 0) and (FileID > 0) then | 
 
 
 
 
 
 
 
 
 | 668 | 
 + | 
           begin | 
 
 
 
 
 
 
 
 
 | 669 | 
 + | 
             Database.Commit(False); | 
 
 
 
 
 
 
 
 
 | 670 | 
 + | 
             Database.StartTransaction; | 
 
 
 
 
 
 
 
 
 | 671 | 
 + | 
           end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 672 | 
   | 
         end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 673 | 
   | 
       end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 674 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 700 | 
   | 
     end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 701 | 
   | 
     if ((FileID mod 10) = 0) and (FileID >= 100) then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 702 | 
   | 
       lbl_estimation.Caption := 'Estimated time left: ' + TimeToStr( | 
 
 
 
 
 
 
 
 
 
 
 
 | 703 | 
 < | 
         (Time - BeginTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat ); | 
 
 
 
 
 
 
 
 
 
 | 703 | 
 > | 
         (Time - FileTime) / FileID * (progress.Max - FileID + 1) * 1.1, timeformat ); | 
 
 
 
 
 
 
 
 
 
 
 
 | 704 | 
   | 
     progress.Position := FileID; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 705 | 
   | 
     lbl_progress.Caption := 'Files done: ' + IntToStr(FileID) + '/' + IntToStr(progress.Max); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 706 | 
   | 
     Application.ProcessMessages; |