ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/DataAccess/Access_OUP_ADB.pas
(Generate patch)

Comparing oup/current/DataAccess/Access_OUP_ADB.pas (file contents):
Revision 113 by alloc, Sun Feb 25 17:20:22 2007 UTC vs.
Revision 134 by alloc, Wed Mar 28 17:53:54 2007 UTC

# Line 18 | Line 18 | type
18      procedure UpdateListCache;
19  
20      function GetLinksToFile(FileID: Integer): TLinks;
21    function GetLinksFromFile(FileID: Integer): TLinks;
21  
22      function GetFileInfo(FileID: Integer): TFileInfo; override;
23      function GetFilesList(Ext: String; Pattern: String;
# Line 32 | Line 31 | type
31      procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; override;
32  
33      function GetDatLinks(FileID: Integer): TDatLinkList; override;
34 +    function GetDatLink(FileID, DatOffset: Integer): TDatLink; override;
35      function GetRawList(FileID: Integer): TRawDataList; override;
36      function GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo; override;
37  
# Line 46 | Line 46 | type
46   implementation
47  
48   uses
49 <  SysUtils, Data, Functions, ABSDecUtil, DB;
49 >  SysUtils, Data, Functions, ABSDecUtil, DB, DatLinks;
50  
51  
52   (*
# Line 66 | Line 66 | begin
66    FFileName := DBFilename;
67  
68    FDatabase := TABSDatabase.Create(nil);
69 +  FDatabase.Exclusive := True;
70 +  FDatabase.MultiUser := False;
71    FDatabase.DatabaseName := 'OLDBcon' + IntToStr(ConnectionID);
72    FDatabase.DatabaseFileName := DBFilename;
73    FDatabase.Open;
74    FQuery := TABSQuery.Create(FDatabase);
75 +  FQuery.DisableControls;
76    FQuery.DatabaseName := 'OLDBcon' + IntToStr(ConnectionID);
77    FQuery.SQL.Text := 'SELECT [name],[value] FROM globals ORDER BY [name] ASC';
78    FQuery.Open;
# Line 192 | Line 195 | begin
195    FQuery.Close;
196   end;
197  
195 function TAccess_OUP_ADB.GetLinksFromFile(FileID: Integer): TLinks;
196 var
197  i: Integer;
198 begin
199  SetLength(Result.ByName, 0);
200  FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY target_id ASC;';
201  FQuery.Open;
202  SetLength(Result.ByID, FQuery.RecordCount);
203  if FQuery.RecordCount > 0 then
204  begin
205    i := 0;
206    repeat
207      Result.ByID[i].SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger;
208      Result.ByID[i].Destination := FQuery.FieldByName('target_id').AsInteger;
209      Inc(i);
210      FQuery.Next;
211    until FQuery.EOF;
212  end;
213  FQuery.Close;
214 end;
215
198  
199  
200   function TAccess_OUP_ADB.GetFileInfo(fileid: Integer): TFileInfo;
# Line 443 | Line 425 | begin
425    end;
426   end;
427  
428 +
429 +
430 + function TAccess_OUP_ADB.GetDatLink(FileID, DatOffset: Integer): TDatLink;
431 + begin
432 +  Result := DatLinksManager.GetDatLink(FConnectionID, FileID, DatOffset);
433 +  FQuery.SQL.Text := 'SELECT target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' and src_link_offset = ' + IntToStr(DatOffset) + ';';
434 +  FQuery.Open;
435 +  if FQuery.RecordCount > 0 then
436 +    Result.DestID := FQuery.FieldByName('target_id').AsInteger;
437 +  FQuery.Close;
438 + end;
439 +
440 +
441 + function TAccess_OUP_ADB.GetDatLinks(FileID: Integer): TDatLinkList;
442 + var
443 +  i: Integer;
444 +  SrcOffset, DestID: Integer;
445 + begin
446 +  Result := DatLinksManager.GetDatLinks(FConnectionID, FileID);
447 +  if Length(Result) > 0 then
448 +  begin
449 +    FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY src_link_offset ASC;';
450 +    FQuery.Open;
451 +    if FQuery.RecordCount > 0 then
452 +    begin
453 +      repeat
454 +        SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger;
455 +        DestID := FQuery.FieldByName('target_id').AsInteger;
456 +        for i := 0 to High(Result) do
457 +          if Result[i].SrcOffset = SrcOffset then
458 +            Break;
459 +        if i < Length(Result) then
460 +          Result[i].DestID := DestID
461 +        else
462 +          Result[i].DestID := -1;
463 +        FQuery.Next;
464 +      until FQuery.EOF;
465 +    end;
466 +    FQuery.Close;
467 +  end;
468 + end;
469 +
470  
471   function TAccess_OUP_ADB.GetRawList(FileID: Integer): TRawDataList;
472   var

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)