Changeset 341 for tools/dbc_export/DBCExport.pas
- Timestamp:
- Feb 27, 2010, 8:06:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/dbc_export/DBCExport.pas
r340 r341 24 24 NewDBCFileName: string; 25 25 ColumnTypeDefinition: string; 26 LastIndexStringColumns: integer; 27 IndexTable: array of integer; 26 28 SQLquery: string; 27 29 DisplayData: Boolean; … … 33 35 procedure SaveDBC; 34 36 procedure ReplaceText; 37 procedure CreateIndexTable(var DbRows: TDbRows); 35 38 function GetIDbyEntry(entry: integer; var DBRows: TDBRows): integer; 36 39 end; … … 120 123 WriteLn(' -c --coltypedef DBC column type definition string (u - uint32, s - string)'); 121 124 WriteLn(' -d --display Display DBC data'); 122 WriteLn(' -q --sql_query SQL select when entry is ID first column in dbc file and text 0,text1... is texts columns');123 // SELECT T.entry as entry,T.Text as text 0FROM (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.entry125 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 124 127 end; 125 128 … … 153 156 // Load strings for string columns 154 157 for I := 1 to Length(ColumnTypeDefinition) do 155 if ColumnTypeDefinition[I] = 's' then 158 if ColumnTypeDefinition[I] = 's' then begin 156 159 LoadColumnStrings(I - 1); 160 LastIndexStringColumns:=I; 161 end; 162 157 163 158 164 end else WriteLn('File ' + DBCFileName + ' not exists.'); … … 174 180 DBRows : TDbRows; 175 181 Text: String; 176 X, Y, I : Integer;182 X, Y, I,entry: Integer; 177 183 IndexRowData: Integer; 178 184 begin … … 182 188 DBRows := Database.Query(SQLquery); 183 189 190 CreateIndexTable(DBRows); 191 184 192 185 193 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); 195 206 I:=I+1; 207 if (LastIndexStringColumns = X) then 208 Break; 196 209 end; 197 210 end; 198 DBRows.Delete(IndexRowData);199 211 end; 212 200 213 end; 201 214 … … 203 216 204 217 end; 218 end; 219 end; 220 221 //create table index = entry, value = Index-1 DBRows, notfound = 0 222 procedure TDBCExport.CreateIndexTable(var DbRows: TDbRows); 223 var 224 i: integer; 225 Count,entry: integer; 226 begin 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 205 243 end; 206 244 end;
Note:
See TracChangeset
for help on using the changeset viewer.