Changeset 616 for tools/WoWHeadLoader
- Timestamp:
- Nov 29, 2013, 6:09:49 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/WoWHeadLoader/WoWHeadLoader.lpr
r612 r616 38 38 function SqlPre(text: string):string; 39 39 procedure UpdateTranslated; 40 function GetEndtextData(data:string): string; 40 41 41 42 function GetMaxIDQuest: integer; … … 118 119 end; 119 120 120 procedure TWoWHeadLoader.WriteHelp; // D:\ProgramFiles\lazarus\units\indy-10.2.0.3\fpc\121 procedure TWoWHeadLoader.WriteHelp; 121 122 begin 122 123 { add your help code here } … … 148 149 data := IdHTTP1.Get('http://www.wowhead.com/quest='+IntToStr(Id)); 149 150 // WriteLn(data); 150 if (pos('<b style="color: red">This quest was marked obsolete',data) > 0) or (pos(' ewr<b style="color: red">This quest is no longer available',data) > 0) then begin151 if (pos('<b style="color: red">This quest was marked obsolete',data) > 0) or (pos('<b style="color: red">This quest is no longer available',data) > 0) then begin 151 152 foundtext:=false; 152 153 Exit; … … 177 178 textobject := TextStringReplace(Copy(data,0,Pos('<',data)-1)); 178 179 179 //endtext 180 181 182 data := skipto('<table class="iconlist">',data); 183 //mazání podsupin u objektů questu 184 if (0 < Pos('<div id="npcgroup-',data)) then begin 185 data := StringReplace(data,'<div','#@{',[rfIgnoreCase]); 186 while (Pos('<div',data) < Pos('</div',data)) and (Pos('<div',data) >0) do begin 187 data := StringReplace(data,'</div','',[rfIgnoreCase]); 188 data := StringReplace(data,'<div','',[rfIgnoreCase]); 189 end; 190 data := Copy(data,0,Pos('#@{',data))+Copy(data,Pos('</div',data),Length(data)); 191 data := StringReplace(data,'</div','',[rfIgnoreCase]); 192 end; 193 if (0 < Pos('<div id="npcgroup-',data)) then begin 194 data := StringReplace(data,'<div','#@{',[rfIgnoreCase]); 195 while (Pos('<div',data) < Pos('</div',data)) and (Pos('<div',data) >0) do begin 196 data := StringReplace(data,'</div','',[rfIgnoreCase]); 197 data := StringReplace(data,'<div','',[rfIgnoreCase]); 198 end; 199 data := Copy(data,0,Pos('#@{',data))+Copy(data,Pos('</div',data),Length(data)); 200 data := StringReplace(data,'</div','',[rfIgnoreCase]); 201 end; 202 if (0 < Pos('<div id="npcgroup-',data)) then begin 203 data := StringReplace(data,'<div','#@{',[rfIgnoreCase]); 204 while (Pos('<div',data) < Pos('</div',data)) and (Pos('<div',data) >0) do begin 205 data := StringReplace(data,'</div','',[rfIgnoreCase]); 206 data := StringReplace(data,'<div','',[rfIgnoreCase]); 207 end; 208 data := Copy(data,0,Pos('#@{',data))+Copy(data,Pos('</div',data),Length(data)); 209 data := StringReplace(data,'</div','',[rfIgnoreCase]); 210 end; 211 //mazání podsupin u objektů questu 212 if (0 < Pos('<div id="npcgroup-',data)) then begin 213 data := StringReplace(data,'<div','#@{',[rfIgnoreCase]); 214 while (Pos('<div',data) < Pos('</div',data)) and (Pos('<div',data) >0) do begin 215 data := StringReplace(data,'</div','',[rfIgnoreCase]); 216 data := StringReplace(data,'<div','',[rfIgnoreCase]); 217 end; 218 data := Copy(data,0,Pos('#@{',data))+Copy(data,Pos('</div',data),Length(data)); 219 data := StringReplace(data,'</div','',[rfIgnoreCase]); 220 end; 221 data := Copy(data,0,Pos('</table',data)); 180 //endtext+objects 181 data:=GetEndtextData(data); 182 // WriteLn(data); 222 183 223 184 … … 232 193 textend:=''; 233 194 end; 234 if ((Pos('<',part) = 0) and (Pos(' ',part) = 0)) then begin195 if ((Pos('<',part) = 0) and (Pos('#',part) = 0) and (Pos(' ',part) = 0)) then begin 235 196 // part := Copy(part,0,Pos(' ',part)-1); 236 197 textend:=TextStringReplace(DelHtmlTags(part)); 237 198 end; 238 if ((Pos('object=',part) > 0) or (Pos('javascript',part) > 0) or ((itemfound = false) and (Pos('<',part) = 0))) then begin199 if ((Pos('object=',part) > 0) or (Pos('javascript',part) > 0) or ((itemfound = false) and (Pos('#',part) = 0) and (Pos('<',part) = 0))) then begin 239 200 part := Copy(part,0,Pos(' ',part)-1); 240 201 part := TextStringReplace(DelHtmlTags(part)); //todo … … 258 219 If foundtext then begin 259 220 DBRows := Database.Query('SELECT * FROM `TextQuest` WHERE `Entry` ='+IntToStr(Id)+' AND `Language` =0 ORDER BY `TextQuest`.`VersionEnd` DESC '); 260 if (DBRows.Count > 0) then 261 if ( 262 CompareStrings(DBRows.Data[0].Values['Title'],textname) and 263 CompareStrings(DBRows.Data[0].Values['Objectives'],textobject) and 264 CompareStrings(DBRows.Data[0].Values['Details'],textdescription) and 265 CompareStrings(DBRows.Data[0].Values['OfferRewardText'],textcomplection) and 266 CompareStrings(DBRows.Data[0].Values['RequestItemsText'],textprogress) and 267 CompareStrings(DBRows.Data[0].Values['EndText'],textend) and 268 CompareStrings(DBRows.Data[0].Values['ObjectiveText1'],textobjective1) and 269 CompareStrings(DBRows.Data[0].Values['ObjectiveText2'],textobjective2) and 270 CompareStrings(DBRows.Data[0].Values['ObjectiveText3'],textobjective3) and 271 CompareStrings(DBRows.Data[0].Values['ObjectiveText4'],textobjective4) 272 ) then 221 if (DBRows.Count > 0) then begin 222 if (DBRows.Data[0].Values['VersionEnd'] = IntToStr(ImportedVersion)) then Exit; //konec pokud už tam text je 223 if ( 224 CompareStrings(DBRows.Data[0].Values['Title'],textname) and 225 CompareStrings(DBRows.Data[0].Values['Objectives'],textobject) and 226 CompareStrings(DBRows.Data[0].Values['Details'],textdescription) and 227 CompareStrings(DBRows.Data[0].Values['OfferRewardText'],textcomplection) and 228 CompareStrings(DBRows.Data[0].Values['RequestItemsText'],textprogress) and 229 CompareStrings(DBRows.Data[0].Values['ObjectiveText2'],textobjective2) and 230 CompareStrings(DBRows.Data[0].Values['ObjectiveText3'],textobjective3) and 231 CompareStrings(DBRows.Data[0].Values['ObjectiveText4'],textobjective4) and 232 ( 233 ( 234 CompareStrings(DBRows.Data[0].Values['EndText'],textend) and 235 CompareStrings(DBRows.Data[0].Values['ObjectiveText1'],textobjective1) 236 ) or 237 ( 238 CompareStrings(DBRows.Data[0].Values['EndText'],textobjective1) and 239 CompareStrings(DBRows.Data[0].Values['ObjectiveText1'],textend) 240 ) 241 ) 242 ) then 243 begin 244 //text je stejný 245 Database.Query('UPDATE `wowpreklad`.`TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Id` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';'); 246 Database.Query('UPDATE `wowpreklad`.`TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Take` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';'); 247 UpdateTranslated; 248 Exit; //konec: text je stejný upravili se jenom výsledné verze 249 end; 250 // if not ( 251 // CompareStrings(DBRows.Data[0].Values['EndText'],textend) and 252 // CompareStrings(DBRows.Data[0].Values['ObjectiveText1'],textobjective1) and 253 // CompareStrings(DBRows.Data[0].Values['ObjectiveText2'],textobjective2) and 254 // CompareStrings(DBRows.Data[0].Values['ObjectiveText3'],textobjective3) and 255 // CompareStrings(DBRows.Data[0].Values['ObjectiveText4'],textobjective4) 256 // ) then Readln; 257 end; 258 273 259 begin 274 //text je stejný275 Database.Query('UPDATE `wowpreklad`.`TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Id` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';');276 DBRows := Database.Query('UPDATE `wowpreklad`.`TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Take` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';');277 //TODO: update caskadově všechny texty vycházející z této verze278 UpdateTranslated;279 Exit;280 end;281 282 begin283 //v databázi je víc textu než v importu -> vytvoř novou verzi a vytvoř nový překlad284 260 { 285 261 WriteLn('INSERT INTO `wowpreklad`.`TextQuest` (' … … 321 297 end; 322 298 299 { 323 300 if (DBRows.Count = 0) then Exit; 324 {325 301 WriteLn('guest='+IntToStr(Id)+' DB "' 326 302 +DBRows.Data[0].Values['Title']+ '" '+chr(10)+ … … 349 325 } 350 326 351 352 // ReadLn; 353 end; 354 // else WriteLn('guest='+IntToStr(Id)+' Nenalezen'); 355 327 end; 356 328 except 357 329 on E: EIdHTTPProtocolException do … … 363 335 on E:Exception do 364 336 GetTextQuest(Id); 365 // on E: EIdSocketError do then366 // foundtext := false;367 // end;368 337 end; 369 338 end; … … 374 343 i:integer; 375 344 begin 376 GetTextQuest( 12996);377 GetTextQuest( 13105);378 379 GetTextQuest(13164); 380 381 GetTextQuest(13358); 382 383 GetTextQuest(1 3375);345 GetTextQuest(7081); 346 GetTextQuest(7122); 347 GetTextQuest(9192); 348 349 GetTextQuest(12509); 350 351 352 GetTextQuest(12580); 384 353 385 354 GetTextQuest(13369); … … 394 363 395 364 396 for i := 12865to GetMaxIDQuest do begin365 for i := 0 to GetMaxIDQuest do begin 397 366 GetTextQuest(i); 398 367 write('.'); … … 491 460 492 461 function TWoWHeadLoader.CompareStrings(textdb: string; textimport: string): boolean; 462 var 463 part,data :string; 493 464 begin 494 465 textdb:=DelHtmlTags(LowerCase(textdb)); 466 textdb := StringReplace(textdb,'s'+chr(39)+'s','',[rfReplaceAll, rfIgnoreCase]); 467 textdb := StringReplace(textdb,'s'+chr(39),'',[rfReplaceAll, rfIgnoreCase]); 468 textdb := StringReplace(textdb,chr(39)+'s','',[rfReplaceAll, rfIgnoreCase]); 469 textdb := StringReplace(textdb,chr(39),'',[rfReplaceAll, rfIgnoreCase]); 470 495 471 textdb := StringReplace(textdb,' ','',[rfReplaceAll, rfIgnoreCase]); 496 472 textdb := StringReplace(textdb,',','',[rfReplaceAll, rfIgnoreCase]); … … 499 475 textdb := StringReplace(textdb,chr(13),'',[rfReplaceAll, rfIgnoreCase]); 500 476 textdb := StringReplace(textdb,'$b','',[rfReplaceAll, rfIgnoreCase]); 501 textdb := StringReplace(textdb,'$B','',[rfReplaceAll, rfIgnoreCase]);502 // textdb := StringReplace(textdb,'$n','$N',[rfReplaceAll, rfIgnoreCase]);503 // textdb := StringReplace(textdb,'$g','$G',[rfReplaceAll, rfIgnoreCase]);504 // textdb := StringReplace(textdb,'$c','$C',[rfReplaceAll, rfIgnoreCase]);505 // textdb := StringReplace(textdb,'$r','$R',[rfReplaceAll, rfIgnoreCase]);506 textdb := StringReplace(textdb,'s'+chr(39)+'s','',[rfReplaceAll, rfIgnoreCase]);507 textdb := StringReplace(textdb,'s'+chr(39),'',[rfReplaceAll, rfIgnoreCase]);508 textdb := StringReplace(textdb,chr(39)+'s','',[rfReplaceAll, rfIgnoreCase]);509 textdb := StringReplace(textdb,chr(39),'',[rfReplaceAll, rfIgnoreCase]);510 477 511 478 textimport:=DelHtmlTags(LowerCase(textimport)); … … 514 481 textimport := StringReplace(textimport,chr(39)+'s','',[rfReplaceAll, rfIgnoreCase]); 515 482 textimport := StringReplace(textimport,chr(39),'',[rfReplaceAll, rfIgnoreCase]); 516 // textimport := StringReplace(textimport,'$n','$N',[rfReplaceAll, rfIgnoreCase]); 517 // textimport := StringReplace(textimport,'$g','$G',[rfReplaceAll, rfIgnoreCase]); 518 // textimport := StringReplace(textimport,'$c','$C',[rfReplaceAll, rfIgnoreCase]); 519 // textimport := StringReplace(textimport,'$r','$R',[rfReplaceAll, rfIgnoreCase]); 483 520 484 textimport := StringReplace(textimport,' ','',[rfReplaceAll, rfIgnoreCase]); 521 485 textimport := StringReplace(textimport,',','',[rfReplaceAll, rfIgnoreCase]); … … 524 488 textimport := StringReplace(textimport,chr(13),'',[rfReplaceAll, rfIgnoreCase]); 525 489 textimport := StringReplace(textimport,'$b','',[rfReplaceAll, rfIgnoreCase]); 526 textimport := StringReplace(textimport,'$B','',[rfReplaceAll, rfIgnoreCase]);527 490 if ((textdb = textimport) or ( (textdb <> '') and (textimport = '') )) then Result := true 528 491 else begin 529 //TODO: smazat celé $g pro porovnání 530 Result:=false; 531 WriteLn(textdb); 532 WriteLn(textimport); 533 // ReadLn; 492 //zkusím rozgenerovat $g nejdřív podle prvního 493 data:=textdb; 494 while (Pos('$g',data)> 0) do begin 495 part := skipto('$g',data); 496 part := '$g'+Copy(part,0,Pos(';',part)); 497 data := StringReplace(data,part,Copy(part,3,Pos(':',part)-3),[rfReplaceAll, rfIgnoreCase]); 498 end; 499 if (data = textimport) then 500 Result := true else begin 501 data:=textdb; 502 while (Pos('$g',data)> 0) do begin 503 part := skipto('$g',data); 504 part := '$g'+Copy(part,0,Pos(';',part)); 505 data := StringReplace(data,part,Copy(part,Pos(':',part)+1,Length(part)-1-Pos(':',part)),[rfReplaceAll, rfIgnoreCase]); 506 end; 507 if (data = textimport) then 508 Result := true else begin 509 Result:=false; 510 WriteLn('db: '+textdb); 511 WriteLn('in: '+textimport); 512 end; 513 end; 534 514 end; 535 515 end; … … 593 573 end; 594 574 575 function TWoWHeadLoader.GetEndtextData(data: string): string; 576 var 577 i:integer; 578 begin 579 data := skipto('<table class="iconlist">',data); 580 //mazání podsupin u objektů questu 581 for i:=0 to 4 do begin 582 if (0 < Pos('<div id="npcgroup-',data)) then begin 583 data := StringReplace(data,'<div','#@{',[rfIgnoreCase]); 584 while (Pos('<div',data) < Pos('</div',data)) and (Pos('<div',data) >0) do begin 585 data := StringReplace(data,'</div','',[rfIgnoreCase]); 586 data := StringReplace(data,'<div','',[rfIgnoreCase]); 587 end; 588 data := Copy(data,0,Pos('#@{',data))+Copy(data,Pos('</div',data),Length(data)); 589 data := StringReplace(data,'</div','',[rfIgnoreCase]); 590 end; 591 end; 592 // WriteLn(Copy(data,0,Pos('</table',data))); 593 if (skipto('<table class="iconlist">',data) <> data) then 594 data := Copy(data,0,Pos('</table',data))+skipto('<table class="iconlist">',data); 595 // WriteLn(Copy(data,0,Pos('</table',data))); 596 //writeln(data); 597 //mazání podsupin u objektů questu 598 for i:=0 to 4 do begin 599 if (0 < Pos('<div id="npcgroup-',data)) then begin 600 data := StringReplace(data,'<div','#@{',[rfIgnoreCase]); 601 while (Pos('<div',data) < Pos('</div',data)) and (Pos('<div',data) >0) do begin 602 data := StringReplace(data,'</div','',[rfIgnoreCase]); 603 data := StringReplace(data,'<div','',[rfIgnoreCase]); 604 end; 605 data := Copy(data,0,Pos('#@{',data))+Copy(data,Pos('</div',data),Length(data)); 606 data := StringReplace(data,'</div','',[rfIgnoreCase]); 607 end; 608 end; 609 data := Copy(data,0,Pos('</table',data)); 610 Result:=data; 611 end; 612 595 613 var 596 614 Application: TWoWHeadLoader;
Note:
See TracChangeset
for help on using the changeset viewer.