All pastes #837981 Raw Edit

Untitled

public text v1 · immutable
#837981 ·published 2007-12-30 00:58 UTC
rendered paste body
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    lbl1: TLabel;
    lbl2: TLabel;
    lbl3: TLabel;
    lbl4: TLabel;
    btn1: TButton;
    lbl5: TLabel;
    lbl6: TLabel;
    lbl7: TLabel;
    lbl8: TLabel;
    lbl9: TLabel;
    lbl10: TLabel;
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  dat_id: integer;
  item_count, creature_count, effect_count, distance_count: SmallInt;
implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
var
  tibia_dat: File;
  parsed_file: TextFile;
  i,j : Integer;
  min_id, max_id: integer;
  temp_width, temp_height, temp_xdiv, temp_ydiv, temp_zdiv, anim_len, frames: Byte;
  temp_byte: Byte;
  num_sprites: Cardinal;
  opt_byte: Byte;
  spr_id: SmallInt;
begin
  AssignFile(tibia_dat, 'tibia.dat');
  AssignFile(parsed_file, 'parsed.txt');
  Rewrite(parsed_file);
  Reset(tibia_dat,1);
  BlockRead(tibia_dat, dat_id, 4);
  lbl5.Caption := IntToStr(dat_id);
  BlockRead(tibia_dat, item_count, 2);
  lbl7.Caption := IntToStr(item_count);
  BlockRead(tibia_Dat, creature_count, 2);
  lbl8.Caption := IntToStr(creature_count);
  BlockRead(tibia_dat, effect_count, 2);
  lbl9.Caption := IntToStr(effect_count);
  BlockRead(tibia_dat, distance_count, 2);
  lbl10.Caption := IntToStr(distance_count);

  min_id := 100;
  max_id := item_count + creature_count;
  for i:=min_id to max_id-1 do
  begin
    opt_byte := $AA;
    while(opt_byte <> $FF) do
    begin
     BlockRead(tibia_dat, opt_byte, 1);
    end;
    BlockRead(tibia_dat, temp_width, 1);
    BlockRead(tibia_dat, temp_height, 1);
    if(temp_width > 1) or (temp_height > 1) then BlockRead(tibia_dat, temp_byte, 1);
    BlockRead(tibia_dat, frames, 1);
    BlockRead(tibia_dat, temp_xdiv, 1);
    BlockRead(tibia_dat, temp_ydiv, 1);
    BlockRead(tibia_dat, temp_zdiv, 1);
    BlockRead(tibia_dat, anim_len, 1);
    num_sprites := temp_width * temp_height * frames * anim_len * temp_xdiv * temp_ydiv * temp_zdiv;
    for j:=0 to num_sprites-1 do
    begin
       BlockRead(tibia_dat, spr_id, 2);
       Writeln(parsed_file, 'GAME_ID: ' + IntToStr(i) + ' AND SPR_ID: ' + IntToStr(spr_id));
    end;
  end;
  CloseFile(tibia_dat);
  CloseFile(parsed_file);

end;

end.