23.07.2011, 19:09
|
|
Прохожий
|
|
Регистрация: 10.04.2011
Сообщения: 11
Репутация: 10
|
|
Цитата:
Сообщение от M.A.D.M.A.N.
А мне нужно, чтоб толком объяснили откуда взялся этот файл, чтоб понять откуда плясать, если тебе нужна помощь.
|
Это игра Perfect World файл data это магазин игры.
вот чё накапал в инете
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;
type
TList1 = record
id:integer;
name: array [0..63] of byte;
int1:integer;
int2:integer;
int3:integer;
int4:integer;
end;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
ListBox1: TListBox;
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure ListBox1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
ListPos: array [1..4] of Integer; // сюда сохраняем смещения листa
ListLen: array [1..4] of Integer; // сюда сохраняем количество элементов
ffile: tStream;
procedure OpenList1(lb: TListBox); // это у нас собс-но открытие первого листа
procedure FillListPos; // это будет заполнение листа
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
List1: array of TList1;
procedure TForm1.OpenList1(lb: TListBox);
var
num: integer;
w: widestring;
begin
num := lb.ItemIndex;
Edit1.Text:=IntToStr(List1[num].id);
SetLength(w, 32);
Move(List1[num].name[0], w[1], 64);
Edit2.Text:=w;
Edit3.Text:=IntToStr(List1[num].int1);
Edit4.Text:=IntToStr(List1[num].int2);
Edit5.Text:=IntToStr(List1[num].int3);
Edit6.Text:=IntToStr(List1[num].int4);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
ws: WideString;
begin
if OpenDialog1.Execute then begin
if not FileExists(opendialog1.FileName) then exit;
if Assigned(fFile) then
begin
FreeAndNil(fFile);
end;
// Создаем поток
fFile := TFileStream.Create(OpenDialog1.FileName, (fmOpenReadWrite{or fmShareExclusive}));
// Заполняем массив с позициями
FillListPos;
// Читаем лист 1
SetLength(ws, 32);
fFile.Position := ListPos[1]+4;
SetLength(List1, ListLen[1]);
fFile.Read(List1[0], ListLen[1]*SizeOf(TList1));
for i := 0 to ListLen[1] - 1 do
begin
Move(List1[i].name, Pointer(ws)^, 64);
ListBox1.Items.Add(IntToStr(List1[i].id) + ' - ' + ws);
end;
end;
end;
procedure TForm1.FillListPos;
var
fListLen: Integer;
begin
(*
== подсчет смещений каждого последующего листа ==
8 это смещение первого листа.
8 + 4 + размер первого листа = смещение второго листа.
смещение второго листа + 4 + размер второго листа = смещение третьего, и т.д.
*)
ListPos[1] := 8;
if Assigned(fFile) then begin
fFile.Position := ListPos[1]; // устанавливавем маркер в позицию начала Листа1
fFile.Read(fListLen, SizeOf(fListLen)); // Считываем количество элементов
ListLen[1] := fListLen;
ListPos[2] := ListPos[1] + ListLen[1]*SizeOf(TList1) + 4; // получаем смещение второго листа
end;
end;
// -------------------------------------------------------- //
procedure TForm1.ListBox1Click(Sender: TObject);
begin
openlist1(listbox1);
end;
end.
но она не открывает нужный мне файл
но открывает другой файл каторый мне тоже нужно открыть
|