unit SummaryLoaders;

interface
uses classes;

type

 TSummaryReader=Class(TObject)
  function loadFlagLists(fileName:string):TStrings;
 end;

implementation
uses SysUtils,types,windows;

function TSummaryReader.loadFlagLists(fileName:string):TStrings;
var
 stream:TMemoryStream;
 len,count,i,j,value:DWORD;
 text:PChar;
begin

 if(FileExists(fileName))and(
 AnsiLowercase(ExtractFileName(fileName))='summary.wsm')then
 begin
  stream:=TMemoryStream.Create;
  result:=TStringList.Create();
  try
   stream.LoadFromFile(fileName);

   stream.ReadBuffer(len,SizeOf(len));  //画像
   stream.Position:=stream.Position+len;

 //  windows.MessageBox(0,'シナリオ名',PChar(IntToHex(stream.Position,0)),MB_OK);
   stream.ReadBuffer(len,SizeOf(len));  //シナリオ名
   stream.Position:=stream.Position+len;

 //  windows.MessageBox(0,'解説',PChar(IntToHex(stream.Position,0)),MB_OK);

   stream.ReadBuffer(len,SizeOf(len));  //解説
   stream.Position:=stream.Position+len;

 //  windows.MessageBox(0,'作者名',PChar(IntToHex(stream.Position,0)),MB_OK);

   stream.ReadBuffer(len,SizeOf(len));  //作者名
   stream.Position:=stream.Position+len;
 ///  windows.MessageBox(0,'称号リスト',PChar(IntToHex(stream.Position,0)),MB_OK);

   stream.ReadBuffer(len,SizeOf(len));  //称号リスト
   stream.Position:=stream.Position+len;
 //  windows.MessageBox(0,'必要称号',PChar(IntToHex(stream.Position,0)),MB_OK);
   stream.Position:=stream.Position+SizeOf(len);//必要称号数
  // stream.Position:=stream.Position+SizeOf(len);//何かのＩＤ

  // windows.MessageBox(0,'開始エリア',PChar(IntToHex(stream.Position,0)),MB_OK);
   stream.Position:=stream.Position+SizeOf(len);//開始エリア番号
  // windows.MessageBox(0,'ステップ',PChar(IntToHex(stream.Position,0)),MB_OK);
   stream.ReadBuffer(count,SizeOf(count));  //ステップ数

   for i:=1 to count do
   begin

    stream.ReadBuffer(len,SizeOf(len));  //ステップ名
    
    stream.Position:=stream.Position+len;
    stream.Position:=stream.Position+sizeOf(len);  //ステップ初期値

    for j:=0 to 9 do
    begin
     stream.ReadBuffer(len,SizeOf(len));  //ステップ定義
     stream.Position:=stream.Position+len;

    end;
   end;

   stream.ReadBuffer(count,SizeOf(count));  //ステップ数

 
   for i:=1 to count do
   begin

    stream.ReadBuffer(len,SizeOf(len));  //フラグ名
    getMem(text,len);
    stream.ReadBuffer(text^,len);//コイツだけ出力
    result.Add(string(text));
    freeMem(text);

    stream.Position:=stream.Position+1; //フラグ初期値

    for j:=0 to 1 do
    begin
     stream.ReadBuffer(len,SizeOf(len));  //フラグ定義
     stream.Position:=stream.Position+len;
  //   writeln(stream.Position);
    end;

   end;

  finally
   stream.Free();
  end;
 end;
 
end;

end.
