Ignore:
Timestamp:
Feb 27, 2010, 8:06:39 PM (14 years ago)
Author:
maron
Message:

Místo cyklu prohledávájící v datách entry vytvoření tabulky indexů, zkrácení průchodu osou X při přepisování textů

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/dbc_export/DBCExport.pas

    r340 r341  
    2424    NewDBCFileName: string;
    2525    ColumnTypeDefinition: string;
     26    LastIndexStringColumns: integer;
     27    IndexTable: array of integer;
    2628    SQLquery: string;
    2729    DisplayData: Boolean;
     
    3335    procedure SaveDBC;
    3436    procedure ReplaceText;
     37    procedure CreateIndexTable(var DbRows: TDbRows);
    3538    function GetIDbyEntry(entry: integer; var DBRows: TDBRows): integer;
    3639  end;
     
    120123  WriteLn('  -c --coltypedef  DBC column type definition string (u - uint32, s - string)');
    121124  WriteLn('  -d --display     Display DBC data');
    122   WriteLn('  -q --sql_query  SQL select when entry is ID first column in dbc file and text0,text1... is texts columns');
    123   // SELECT T.entry as entry,T.Text as text0 FROM (SELECT * FROM gametips WHERE (Complete = 1) AND ((Language = 1)) AND (User IN (459,670,602,462,1,400,638,592,624,610,769,331,131,704,2,499,641,660,578,337,304,277,208,613,768,754,590,606,26,618,739,503,601,607,585,596,765,320,547,687)) AND VersionStart <= 9947 AND VersionEnd >= 9947) AS T GROUP BY T.entry
     125  WriteLn('  -q --sql_query  SQL select when entry is ID first column in dbc file and text1,text2... is texts columns');
     126  // SELECT T.entry as entry,T.Text as text1 FROM (SELECT * FROM gametips WHERE (Complete = 1) AND ((Language = 1)) AND (User IN (459,670,602,462,1,400,638,592,624,610,769,331,131,704,2,499,641,660,578,337,304,277,208,613,768,754,590,606,26,618,739,503,601,607,585,596,765,320,547,687)) AND VersionStart <= 9947 AND VersionEnd >= 9947) AS T GROUP BY T.entry
    124127end;
    125128
     
    153156      // Load strings for string columns
    154157      for I := 1 to Length(ColumnTypeDefinition) do
    155         if ColumnTypeDefinition[I] = 's' then
     158        if ColumnTypeDefinition[I] = 's' then begin
    156159          LoadColumnStrings(I - 1);
     160          LastIndexStringColumns:=I;
     161        end;
     162
    157163
    158164    end else WriteLn('File ' + DBCFileName + ' not exists.');
     
    174180  DBRows : TDbRows;
    175181  Text: String;
    176   X, Y, I: Integer;
     182  X, Y, I,entry: Integer;
    177183  IndexRowData: Integer;
    178184begin
     
    182188      DBRows := Database.Query(SQLquery);
    183189
     190      CreateIndexTable(DBRows);
     191
    184192
    185193      for Y := 0 to Length(DBC.Cells) - 1 do begin
    186         if (Y = 129) then
    187                IndexRowData:= GetIDbyEntry(Cells[Y,0],DBRows);
    188         IndexRowData:= GetIDbyEntry(Cells[Y,0],DBRows);
    189         I := 0;
    190         if (IndexRowData <> -1) then begin
    191           for X := 0 to Length(ColumnTypeDefinition)-1 do begin
    192             if ColumnTypeDefinition[X+1] = 's' then begin
    193               Text:=DBRows.Data[IndexRowData].Values['text'+IntToStr(I)];
    194               SetString(Y,X,Text);
     194        entry :=Cells[Y,0];
     195        if (Length(IndexTable) > entry) then
     196           IndexRowData:= IndexTable[entry]
     197        else IndexRowData:= 0;
     198
     199         I := 1;
     200
     201        if (IndexRowData <> 0) then begin
     202          for X := 1 to Length(ColumnTypeDefinition) do begin
     203            if ColumnTypeDefinition[X] = 's' then begin
     204              Text:=DBRows.Data[IndexRowData-1].Values['text'+IntToStr(I)];
     205              SetString(Y,X-1,Text);
    195206              I:=I+1;
     207              if (LastIndexStringColumns = X) then
     208                Break;
    196209            end;
    197210          end;
    198           DBRows.Delete(IndexRowData);
    199211        end;
     212
    200213      end;
    201214
     
    203216
    204217    end;
     218  end;
     219end;
     220
     221//create table index = entry, value = Index-1 DBRows, notfound = 0
     222procedure TDBCExport.CreateIndexTable(var DbRows: TDbRows);
     223var
     224 i: integer;
     225 Count,entry: integer;
     226begin
     227  try
     228     Count:=DBRows.Count;
     229     for i:=1 to Count do begin
     230       entry:=StrToInt(DBRows.Data[i-1].Values['entry']);
     231
     232       if (i =127) then
     233         SetLength(IndexTable,entry+1);
     234
     235       if (Length(IndexTable)-1 < entry) then
     236         SetLength(IndexTable,entry+1);
     237
     238
     239       IndexTable[entry]:=i;
     240
     241    end;
     242  except
    205243  end;
    206244end;
Note: See TracChangeset for help on using the changeset viewer.