Advertisement
thebadCB

Read ItemList AIKA

Sep 13th, 2015
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 4.17 KB | None | 0 0
  1. unit Func;
  2.  
  3. interface
  4.  
  5. Uses
  6.  Windows,SysUtils,Classes, Dialogs;
  7.  
  8.   Type
  9.   TByteArr = array of byte;
  10.   TByteArray = array of byte;
  11.  
  12. type T_ItemList = Record  // Cada Item tem 464 bytes
  13. Name        : Array [0..63]  of Byte;
  14. NameEnglish : Array [0..63]  of Byte;
  15. Descrition  : Array [0..127] of Byte;
  16. Unk         : Array [0..207] of byte;
  17. End;
  18.  
  19.  
  20.   Procedure ReadItemList;
  21.  
  22.   function StrToArray(const Hexstr: String): TByteArr;
  23.   function bintoAscii(const bin: array of byte): AnsiString;
  24.   Function CountStr(Str: String):Integer;
  25.  
  26. implementation
  27.  
  28. Procedure ReadItemList;
  29. var
  30.   f,N       : TFileStream;
  31.   buffer    : array of BYTE;
  32.   local     : string;
  33.   I,j, size : Integer;
  34.  
  35.   Key1,Key2   : string;
  36.   cipherTable : TByteArr;
  37.   cipherLength: integer;
  38.   par         : boolean;
  39.   sign        : Integer;
  40.   myFile        : TextFile;
  41.   ListItem :ARRAY OF  T_ItemList;
  42. begin
  43.   sign    := 1; //1=DECRIPTA //  -1= ENCRIPTA
  44.   Key1 := 'BEC6C0CCC5DB20B8AEBDBAC6AE20C0CEC4DAB5F920B7E7C6BEC0D4B4CFB4D92E20B7EAB7E720B6F6B6F32E2E2E20C0B82E2E2E20C1A4B8BB20C1A4B8BB20B1CDC2FAB4D92E20B1D7B7A1B5B520C7D8BEDFC7CFB4CF20BEEEC2BF20BCF620BEF8C1D22E2E2E20';
  45.   Key2 := 'C0CCB0C520C0D0C1F620B8B6BCBCBFE42E20C0D0C0B8B8E920B3AABBDBBBE7B6F7B5CBB4CFB4D92E20C1A6B9DF20C0FDB4EB20C0D0C1F6B8BBB0ED20C2F8C7D120BBE7B6F7B5EEB7CE20BBE7BCBCBFE42E20BEC6BCCCC1D23F20C1C1C0BABCBCBBF3B8B8B5ECBDC3B4D92E';
  46.  
  47.   local:=Getcurrentdir+'\ItemList.bin';
  48.   if not(FileExists(local)) then
  49.   begin
  50.     showmessage('Arquivo não encontrado. Coloque o ItemList.bin na mesma pasta');
  51.     exit;
  52.   end;
  53.   F := TFileStream.Create(local, fmOpenRead); //abre o arquivo
  54.   size := F.Size;
  55.   SetLength(buffer,size); //seta o tamanho do buffer que vai receber os bytes
  56.   F.Read(buffer[0],size); //buffer recebe os bytes
  57.   F.Free;
  58.  
  59.   if (Size mod 2) = 0 then Par := true else Par := False;  //verifica se o tamanho do arquivo é PAR
  60.  
  61.   cipherLength := CountStr(Key1); //tamanho da key  
  62.   cipherTable  := StrToArray(Key1); //transforma a key que esta em string para array of byte
  63.  
  64.   j:=0;
  65. while j < Size-1 do  //começa a decriptar os bytes
  66.   begin
  67.   buffer[j] := buffer[j] - sign*(cipherTable[j mod cipherLength]+j);
  68.   inc(j);
  69.   buffer[j] := buffer[j] - sign*(cipherTable[j mod cipherLength]+j);
  70.   inc(j);
  71.   if not par then  // se não for par decripta 3 bytes a cada loop
  72.   begin
  73.   buffer[j] := buffer[j] - sign*(cipherTable[j mod cipherLength]+j);
  74.   inc(j);
  75.  end;
  76. end;
  77.  
  78.   AssignFile(myFile, 'ItemList.csv'); //cria um arquivo csv do excell
  79.   ReWrite(myFile); //configura para escrever
  80.  
  81.   setlength(ListItem, Round(size/$1D0));  //seta o tamanho do buffer com do record
  82.   Move(buffer[0], ListItem[0], size); //move o buffer para o array do record
  83.  
  84.    for i := 0 to  Round(size/$1D0) do //faz o loop
  85.    begin
  86.    WriteLn(myFile,bintoAscii(ListItem[i].Name)+';'+bintoAscii(ListItem[i].NameEnglish)+';'+bintoAscii(ListItem[i].Descrition));
  87.    end;
  88.    CloseFile(myFile); //fecha o arquivo.
  89. end;
  90.  
  91. {    Key1 - ItemList0.bin
  92.             UI\PI.bin
  93.             UI\SetItem.bin
  94.  
  95.      Key2 - ActionText.bin
  96.             SkillData0.bin
  97.             UI\BW.bin
  98.             UI\Dialog.bin
  99.             UI\Easing.bin
  100.             UI\MakeItems.bin
  101.             UI\Quest.bin
  102.             UI\Recipe.bin
  103.             UI\RecipeRate.bin
  104.             UI\Reinforce.bin
  105.             UI\Reinforce2.bin
  106.             UI\Reinforce3.bin
  107.             UI\ReinforceA01.bin
  108.             UI\ReinforceW01.bin
  109.             UI\Siege01.bin
  110.             UI\Siege02.bin}
  111.  
  112.  
  113. function StrToArray(const Hexstr: String): TByteArr; //transforma string em array of byte
  114. var
  115. i: Integer;
  116. begin
  117. if Length(Hexstr)>1 then
  118. begin
  119. SetLength(Result, Length(Hexstr) div 2);
  120. for i:=0 to (Length(Hexstr) div 2 - 1) do
  121.   Result[i]:= StrToInt('$' + Copy(Hexstr, (i * 2) + 1, 2));
  122. end
  123. end;
  124.  
  125. Function CountStr(Str: String):Integer; //retorna o numero de caracteres de um texto
  126. begin
  127.    Result := length(Str) div 2 ;
  128. end;
  129.  
  130. function bintoAscii(const bin: array of byte): AnsiString;  //transforma array of byte em ansistring
  131. var
  132.  i: integer;
  133.  A: String;
  134. begin
  135.   SetLength(Result, Length(bin));
  136.   for i := 0 to Length(bin)-1 do
  137.     Result[1+i] := AnsiChar(bin[i]);
  138. end;
  139.  
  140. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement