OSDN Git Service

まちBBSで削除レスがあるレス番号とスレの件数がずれる不具合を修正
[gikonavigoeson/gikonavi.git] / RoundData.pas
index 6ee36b8..631222a 100644 (file)
@@ -12,11 +12,15 @@ type
 
        TRoundList = class(TObject)
        private
+        FOldFileRead: Boolean;
                FBoardList: TList;
                FItemList: TList;
                function GetCount(RoundType: TGikoRoundType): Integer;
                function GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
-               function ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;
+               function ParseRoundBoardLine(Line: string):             Boolean;
+               function ParseRoundThreadLine(Line: string):    Boolean;
+               function ParseOldRoundBoardLine(Line: string):  Boolean;
+               function ParseOldRoundThreadLine(Line: string): Boolean;
        public
                RoundNameList: TStringList;
 
@@ -26,38 +30,43 @@ type
                function Add(ThreadItem: TThreadItem): Integer; overload;
                procedure Delete(Board: TBoard); overload;
                procedure Delete(ThreadItem: TThreadItem); overload;
+        procedure Delete(URL: string; RoundType: TGikoRoundType); overload;
                procedure Clear;
                function Find(Board: TBoard): Integer; overload;
                function Find(ThreadItem: TThreadItem): Integer; overload;
+        function Find(URL: string; RoundType: TGikoRoundType): Integer; overload;
                property Count[RoundType: TGikoRoundType]: Integer read GetCount;
+        property OldFileRead: Boolean read FOldFileRead;
                property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem;
-               procedure SetRoundName(Board: TBoard; RoundName: string); overload;
-               procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload;
-
-               procedure LoadRoundFile;
+               procedure LoadRoundBoardFile;
+        procedure LoadRoundThreadFile;
                procedure SaveRoundFile;
+
+        procedure URLReplace(oldURLs: TStringList; newURLs :TStringList);
        end;
 
        TRoundItem = class(TObject)
        private
-//             FBBSType: TGikoBBSType;
-               FRoundName: string;
+               FItem           : TObject;
                FRoundType: TGikoRoundType;
-    FItem                      : TObject;
-    FURL                       : string;
-               FBoardTitle: string;
-               FThreadTitle: string;
-               FFileName: string;
+               FTmpURL : string;
                FBoolData: Boolean;             //\82¢\82ë\82¢\82ë\8eg\82¤\82å\82£
+               function GetBoardTitle : string;
+               function GetThreadTitle : string;
+               function GetURL : string;
+               function GetFileName : string;
+        //! \8f\84\89ñ\96¼\8eæ\93¾
+        function GetRoundName : string;
        public
-//             property BBSType: TGikoBBSType read FBBSType write FBBSType;
-               property RoundName: string read FRoundName write FRoundName;
+               constructor Create;
+               property Item : TObject read FItem;
+               property RoundName: string read GetRoundName;
                property RoundType: TGikoRoundType read FRoundType write FRoundType;
-    property Item : TObject read FItem write FItem;
-    property URL : string read FURL write FURL;
-               property BoardTitle: string read FBoardTitle write FBoardTitle;
-               property ThreadTitle: string read FThreadTitle write FThreadTitle;
-               property FileName: string read FFileName write FFileName;
+               property URL : string read GetURL;
+               property TmpURL : string read FTmpURL write FTmpURL;
+               property BoardTitle: string read GetBoardTitle;
+               property ThreadTitle: string read GetThreadTitle;
+               property FileName: string read GEtFileName;
                property BoolData: Boolean read FBoolData write FBoolData;
        end;
 
@@ -68,8 +77,71 @@ implementation
 const
        ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch';        //\82 \82Æ\82ÅBoardGroup\82Ö\88Ú\93®
        ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //\93¯\8fã
-       ROUND_INDEX_VERSION: string = '1.00';
-
+       ROUND_INDEX_VERSION: string = '2.00';
+    ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error\8ds\82ð\95Û\8aÇ\82·\82é
+    ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error\8ds\82ð\95Û\8aÇ\82·\82é
+//! \8f\84\89ñ\83A\83C\83e\83\80\83R\83\93\83X\83g\83\89\83N\83^
+constructor TRoundItem.Create;
+begin
+       inherited Create;
+end;
+//! \94Â\96¼\8eæ\93¾
+function TRoundItem.GetBoardTitle : string;
+begin
+       Result := '';
+       if( Self.FItem <> nil) then begin
+               if( Self.FItem is TBoard) then begin
+                       Result := TBoard(Self.FItem).Title;
+               end else if( Self.FItem is TThreadItem) then begin
+                       Result := TThreadItem(Self.FItem).ParentBoard.Title;
+               end;
+       end;
+end;
+//! \83X\83\8c\83b\83h\96¼\8eæ\93¾
+function TRoundItem.GetThreadTitle : string;
+begin
+       Result := '';
+       if( Self.FItem <> nil) then begin
+               if( Self.FItem is TThreadItem) then begin
+                       Result := TThreadItem(Self.FItem).Title;
+               end;
+       end;
+end;
+//! URL\8eæ\93¾
+function TRoundItem.GetURL     : string;
+begin
+       Result := '';
+       if( Self.FItem <> nil) then begin
+               if( Self.FItem is TBoard) then begin
+                       Result := TBoard(Self.FItem).URL;
+               end else if( Self.FItem is TThreadItem) then begin
+                       Result := TThreadItem(Self.FItem).URL;
+               end;
+       end;
+end;
+//! \83X\83\8c\83b\83h\82Ì\83t\83@\83C\96¼\8eæ\93¾
+function TRoundItem.GetFileName : string;
+begin
+       Result := '';
+       if( Self.FItem <> nil) then begin
+               if( Self.FItem is TThreadItem) then begin
+                       Result := TThreadItem(Self.FItem).FileName;
+               end;
+       end;
+end;
+//! \8f\84\89ñ\96¼\8eæ\93¾
+function TRoundItem.GetRoundName : string;
+begin
+       Result := '';
+       if( Self.FItem <> nil) then begin
+               if( Self.FItem is TBoard) then begin
+                       Result := TBoard(Self.FItem).RoundName;
+               end else if( Self.FItem is TThreadItem) then begin
+                       Result := TThreadItem(Self.FItem).RoundName;
+               end;
+       end;
+end;
+//! \8f\84\89ñ\83\8a\83X\83g\83R\83\93\83X\83g\83\89\83N\83^
 constructor TRoundList.Create;
 begin
        inherited;
@@ -78,17 +150,18 @@ begin
        RoundNameList := TStringList.Create;
        RoundNameList.Sorted := True;
        RoundNameList.Duplicates := dupIgnore;
+    FOldFileRead := false;
 end;
-
+//! \8f\84\89ñ\83\8a\83X\83g\83f\83X\83g\83\89\83N\83^
 destructor TRoundList.Destroy;
 begin
        RoundNameList.Free;
        Clear;
        FBoardList.Free;
        FItemList.Free;
-       inherited;
+       //inherited;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\92Ç\89Á\81i\94Â\81j
 function TRoundList.Add(Board: TBoard): Integer;
 var
        idx: Integer;
@@ -98,17 +171,13 @@ begin
        idx := Find(Board);
        if idx = -1 then begin
                Item := TRoundItem.Create;
+               Item.FItem := Board;
 //             Item.BBSType := gbt2ch; //\82Æ\82è\82 \82¦\82¸
                Item.RoundType := grtBoard;
-    Item.Item := Board;
-               Item.BoardTitle := Board.Title;
-               Item.ThreadTitle := '';
-               Item.FileName := '';
-               Item.RoundName := Board.RoundName;
                Result := FBoardList.Add(Item);
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\92Ç\89Á\81i\83X\83\8c\83b\83h\81j
 function TRoundList.Add(ThreadItem: TThreadItem): Integer;
 var
        idx: Integer;
@@ -118,57 +187,55 @@ begin
        idx := Find(ThreadItem);
        if idx = -1 then begin
                Item := TRoundItem.Create;
+               Item.FItem := ThreadItem;
 //             Item.BBSType := gbt2ch; //\82Æ\82è\82 \82¦\82¸
                Item.RoundType := grtItem;
-               Item.Item := ThreadItem;
-               Item.BoardTitle := ThreadItem.ParentBoard.Title;
-               Item.ThreadTitle := ThreadItem.Title;
-               Item.FileName := ThreadItem.FileName;
-               Item.RoundName := ThreadItem.RoundName;
                Result := FItemList.Add(Item);
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\8dí\8f\9c\81i\94Â\81j
 procedure TRoundList.Delete(Board: TBoard);
 var
        idx: Integer;
-       Item: TRoundItem;
 begin
        idx := Find(Board);
        if idx <> -1 then begin
-               Item := TRoundItem(FBoardList[idx]);
-               Item.Free;
+               TBoard(TRoundItem(FBoardList[idx]).FItem).RoundName := '';
+               TRoundItem(FBoardList[idx]).Free;
                FBoardList.Delete(idx);
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\8dí\8f\9c\81i\83X\83\8c\83b\83h\81j
 procedure TRoundList.Delete(ThreadItem: TThreadItem);
 var
        idx: Integer;
-       Item: TRoundItem;
 begin
        idx := Find(ThreadItem);
        if idx <> -1 then begin
-               Item := TRoundItem(FItemList[idx]);
-               Item.Free;
+        TThreadItem(TRoundItem(FItemList[idx]).FItem).RoundName := '';
+               TRoundItem(FItemList[idx]).Free;
                FItemList.Delete(idx);
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\8fÁ\8b\8e
 procedure TRoundList.Clear;
 var
        i: Integer;
 begin
        for i := FBoardList.Count - 1 downto 0 do begin
-               TRoundItem(FBoardList[i]).Free;
+        if FBoardList[i] <> nil then
+                       TRoundItem(FBoardList[i]).Free;
                FBoardList.Delete(i);
        end;
+    FBoardList.Capacity := FBoardList.Count;
        for i := FItemList.Count - 1 downto 0 do begin
-               TRoundItem(FItemList[i]).Free;
+        if FItemList[i] <> nil then
+                       TRoundItem(FItemList[i]).Free;
                FItemList.Delete(i);
        end;
+    FItemList.Capacity := FItemList.Count;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\8c\9f\8dõ\81i\94Â\81j
 function TRoundList.Find(Board: TBoard): Integer;
 var
        i: Integer;
@@ -178,13 +245,13 @@ begin
        for i := 0 to FBoardList.Count - 1 do begin
                Item := TRoundItem(FBoardList[i]);
                if Item.FRoundType <> grtBoard then Continue;
-               if Item.Item = Board then begin
+               if Item.FItem = Board then begin
                        Result := i;
                        Exit;
                end;
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\8c\9f\8dõ\81i\83X\83\8c\83b\83h\81j
 function TRoundList.Find(ThreadItem: TThreadItem): Integer;
 var
        i: Integer;
@@ -194,37 +261,73 @@ begin
        for i := 0 to FItemList.Count - 1 do begin
                Item := TRoundItem(FItemList[i]);
                if Item.FRoundType <> grtItem then Continue;
-               if Item.Item = ThreadItem then begin
+               if Item.FItem = ThreadItem then begin
                        Result := i;
                        Exit;
                end;
        end;
 end;
-
-procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string);
+//! \8f\84\89ñ\97\\96ñ\8c\9f\8dõ\81iURL\81{\83A\83C\83e\83\80\83^\83C\83v\81j
+function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer;
 var
-       idx: Integer;
+       i: Integer;
        Item: TRoundItem;
 begin
-       idx := Find(Board);
-       if idx <> -1 then begin
-               Item := TRoundItem(FBoardList[idx]);
-               Item.RoundName := RoundName;
-       end;
+       Result := -1;
+    if RoundType = grtItem then begin
+               for i := 0 to FItemList.Count - 1 do begin
+                       Item := TRoundItem(FItemList[i]);
+                       if Item.FRoundType <> RoundType then Continue;
+                       if Item.URL = URL then begin
+                               Result := i;
+                               Exit;
+                       end;
+               end;
+       end else begin
+               for i := 0 to FBoardList.Count - 1 do begin
+                       Item := TRoundItem(FBoardList[i]);
+                       if Item.FRoundType <> RoundType then Continue;
+                       if Item.URL = URL then begin
+                               Result := i;
+                               Exit;
+                       end;
+               end;
+    end;
 end;
-
-procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string);
+//! \8f\84\89ñ\97\\96ñ\8dí\8f\9c\81iURL\81{\83A\83C\83e\83\80\83^\83C\83v\81j
+procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
 var
        idx: Integer;
        Item: TRoundItem;
+    board: TBoard;
+    threadItem: TThreadItem;
 begin
-       idx := Find(ThreadItem);
+       idx := Find(URL, RoundType);
        if idx <> -1 then begin
-               Item := TRoundItem(FItemList[idx]);
-               Item.RoundName := RoundName;
+
+        if RoundType = grtBoard then begin
+                       Item := TRoundItem(FBoardList[idx]);
+                       board := TBoard(Item);
+                       Item.Free;
+                       FBoardList.Delete(idx);
+                       if board <> nil then begin
+                               board.Round := False;
+                               board.RoundName := '';
+                       end;
+               end else begin
+                       Item := TRoundItem(FItemList[idx]);
+                       threadItem := TThreadItem(Item.FItem);
+                       Item.Free;
+                       FItemList.Delete(idx);
+
+            if threadItem <> nil then begin
+                   threadItem.Round := false;
+               threadItem.RoundName := '';
+            end;
+        end;
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\90\94\8eæ\93¾
 function TRoundList.GetCount(RoundType: TGikoRoundType): Integer;
 begin
        Result := 0;
@@ -233,7 +336,7 @@ begin
        else if RoundType = grtItem then
                Result := FItemList.Count;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\8eæ\93¾
 function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem;
 begin
        Result := nil;
@@ -245,43 +348,140 @@ begin
                        Result := TRoundItem(FItemList[Index]);
        end;
 end;
-
-procedure TRoundList.LoadRoundFile;
+//! \83{\81[\83h\8f\84\89ñ\97\\96ñ\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
+procedure TRoundList.LoadRoundBoardFile;
 var
        i: Integer;
        sl: TStringList;
-       FileName: string;
-       Item: TRoundItem;
+       FileName, bFileName: string;
+       errorSl: TStringList;
+       errorFileName: string;
+       delCount: Integer;
 begin
        sl := TStringList.Create;
+       errorSl := TStringList.Create;
+       errorSl.Duplicates := dupIgnore;
        try
                //\83{\81[\83h\8f\84\89ñ\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
                FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
+               bFileName := GikoSys.GetConfigDir + '~' + ROUND_BOARD_FILENAME;
+               //\83G\83\89\81[\8ds\95Û\91\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
+               errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME;
+
                if FileExists(FileName) then begin
                        sl.LoadFromFile(FileName);
-                       //\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93\82È\82Ì\82Å\96³\8e\8b
-                       for i := 1 to sl.Count - 1 do begin
-                               Item := ParseRoundLine(sl[i], grtBoard);
-                               FBoardList.Add(Item);
-                               RoundNameList.Add(Item.RoundName);
-                       end;
+                       if FileExists(bFileName) then
+                               DeleteFile(bFileName);
+                       //\83o\83b\83N\83A\83b\83v\97p\82Ì\83t\83@\83C\83\8b\82ð\8dì\90¬\82·\82é
+                       sl.SaveToFile(bFileName);
+                       if FileExists(errorFileName) then begin
+                               try
+                       errorSl.LoadFromFile(errorFileName);
+                except
+                end;
+            end;
+            //Item := TRoundItem.Create;
+
+            if sl.Count = 0 then begin
+                //\83G\83\89\81[\97\8e\82¿\82·\82é\82È\82Ç\82µ\82Ä\83t\83@\83C\83\8b\82Ì\93à\97e\82ª\8bó\82¾\82Æ\83G\83\89\81[\82É\82È\82é\91Î\8dô
+                sl.Add(ROUND_INDEX_VERSION);
+            end;
+
+            delCount := 0;
+            //\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93
+                       if sl[0] = ROUND_INDEX_VERSION then begin
+                               for i := 1 to sl.Count - 1 do begin
+                                       if not ParseRoundBoardLine(sl[i - delCount]) then begin
+                                               errorSl.Add( sl[i - delCount] );
+                        sl.Delete(i- delCount);
+                        Inc(delCount);
+                    end;
+                               end;
+            end else begin
+                if FOldFileRead then begin  //\83M\83R\83i\83r\96{\91Ì\82ª\83{\81[\83h\83t\83@\83C\83\8b\82ð\82æ\82Ý\82Æ\82Á\82½\8cã\82\82á\82È\82¢\82Æ\83N\83\89\83b\83V\83\85\82·\82é\82Ì\82Å
+                                       for i := 1 to sl.Count - 1 do begin
+                                               if not ParseOldRoundBoardLine(sl[i - delCount]) then begin
+                                                       errorSl.Add( sl[i- delCount] );
+                               sl.Delete(i- delCount);
+                            Inc(delCount);
+                        end;
+                                       end;
+                end else
+                       FOldFileRead := true;
+            end;
                end;
+        if errorSl.Count > 0 then
+               errorSl.SaveToFile(errorFileName);
+       finally
+       errorSl.Free;
+               sl.Free;
+       end;
+end;
+//! \83X\83\8c\83b\83h\8f\84\89ñ\97\\96ñ\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
+procedure TRoundList.LoadRoundThreadFile;
+var
+       i: Integer;
+       sl: TStringList;
+       FileName, bFileName: string;
+    errorSl: TStringList;
+    errorFileName: string;
+    delCount: Integer;
+begin
+    errorSl := TStringList.Create;
+       errorSl.Duplicates := dupIgnore;
+       sl := TStringList.Create;
+       try
                //\83X\83\8c\8f\84\89ñ\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
                FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
+               bFileName := GikoSys.GetConfigDir + '~' + ROUND_ITEM_FILENAME;
+               //\83G\83\89\81[\8ds\95Û\91\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
+        errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME;
                if FileExists(FileName) then begin
                        sl.LoadFromFile(FileName);
-                       //\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93\82È\82Ì\82Å\96³\8e\8b
-                       for i := 1 to sl.Count - 1 do begin
-                               Item := ParseRoundLine(sl[i], grtItem);
-                               FItemList.Add(Item);
-                               RoundNameList.Add(Item.RoundName);
-                       end;
+                       if FileExists(bFileName) then
+                               DeleteFile(bFileName);
+                       sl.SaveToFile(bFileName);
+                       if FileExists(errorFileName) then begin
+               try
+                       errorSl.LoadFromFile(errorFileName);
+                except
+                end;
+            end;
+            //Item := TRoundItem.Create;
+            if sl.Count = 0 then begin
+                //\83G\83\89\81[\97\8e\82¿\82·\82é\82È\82Ç\82µ\82Ä\83t\83@\83C\83\8b\82Ì\93à\97e\82ª\8bó\82¾\82Æ\83G\83\89\81[\82É\82È\82é\91Î\8dô
+                sl.Add(ROUND_INDEX_VERSION);
+            end;
+
+            delCount := 0;
+                       //\82P\8ds\96Ú\82Í\83o\81[\83W\83\87\83\93
+            if sl[0] = ROUND_INDEX_VERSION then begin
+                               for i := 1 to sl.Count - 1 do begin
+                                       if not ParseRoundThreadLine(sl[i - delCount]) then begin
+                                               errorSl.Add(sl[i - delCount]);
+                        sl.Delete(i - delCount);
+                        Inc(delCount);
+                    end;
+                end;
+                       end else begin
+                               LoadRoundBoardFile;
+                               for i := 1 to sl.Count - 1 do begin
+                                       if not ParseOldRoundThreadLine(sl[i - delCount]) then begin
+                                               errorSl.Add(sl[i - delCount]);
+                        sl.Delete(i - delCount);
+                        Inc(delCount);
+                    end;
+                               end;
+            end;
+            if errorSl.Count > 0 then
+               errorSl.SaveToFile(errorFileName);
                end;
        finally
+               errorSl.Free;
                sl.Free;
        end;
 end;
-
+//! \8f\84\89ñ\97\\96ñ\83t\83@\83C\83\8b\95Û\91
 procedure TRoundList.SaveRoundFile;
 var
        i: integer;
@@ -298,10 +498,19 @@ begin
                sl.Add(ROUND_INDEX_VERSION);
                for i := 0 to FBoardList.Count - 1 do begin
                        Item := TRoundItem(FBoardList[i]);
-                       s := Item.URL + #1
-                                + Item.BoardTitle + #1
-                                + Item.RoundName;
-                       sl.Add(s);
+                       try
+                               if Item.TmpURL <> '' then begin
+                                       s := Item.TmpURL + #1
+                                                + Item.BoardTitle + #1
+                                                + Item.RoundName;
+                               end else begin
+                                       s := Item.URL + #1
+                                                + Item.BoardTitle + #1
+                                                + Item.RoundName;
+                               end;
+                               sl.Add(s);
+                       except
+                       end;
                end;
                sl.SaveToFile(FileName);
                sl.Clear;
@@ -309,58 +518,259 @@ begin
                sl.Add(ROUND_INDEX_VERSION);
                for i := 0 to FItemList.Count - 1 do begin
                        Item := TRoundItem(FItemList[i]);
-                       s := Item.URL + #1
-                                + Item.BoardTitle + #1
-                                + Item.FileName + #1
-                                + Item.ThreadTitle + #1
-                                + Item.RoundName;
-                       sl.Add(s);
+                       try
+                               if Item.TmpURL <> '' then begin
+                                       s := Item.TmpURL + #1
+                                        + Item.BoardTitle + #1
+                                        + Item.FileName + #1
+                                        + Item.ThreadTitle + #1
+                                        + Item.RoundName;
+                               end else begin
+                                       s := Item.URL + #1
+                                        + Item.BoardTitle + #1
+                                        + Item.FileName + #1
+                                        + Item.ThreadTitle + #1
+                                        + Item.RoundName;
+                               end;
+                               sl.Add(s);
+                       except
+                       end;
                end;
                sl.SaveToFile(FileName);
        finally
                sl.Free;
        end;
 end;
+function TRoundList.ParseRoundBoardLine(Line: string): Boolean;
+var
+       s: string;
+       roundname: string;
+       board: TBoard;
+       i: Integer;
+begin
+       //Result := TRoundItem.Create;
+       //Result.ThreadTitle := '';
+       //Result.FileName := '';
+       //Result.RoundType := grtBoard;
+       board := nil;
+       for i := 0 to 2 do begin
+               s := GikoSys.GetTokenIndex(Line, #1, i);
+               try
+                       case i of
+                               0:
+                               begin
+                                       board := BBSsFindBoardFromURL(s);
+                                       //Result.URL := s;
+                               end;
+                               //1: Result.BoardTitle := s;
+                               2: roundname := s;
+                       end;
+               except
+                       Result := false;
+                       Exit;
+               end;
+       end;
+       if( board <> nil ) then begin
+               if not board.Round then begin
+                       board.RoundName := roundname;
+                       RoundNameList.Add(roundname);
+                       //RoundNameList.Find(roundname, i);
+                       //board.RoundName := PChar(RoundNameList[i]);
+                       board.Round := true;
+               end;
+               Result := true;
+       end else begin
+               Result := false;
+       end;
+end;
 
-function TRoundList.ParseRoundLine(Line: string; RoundType: TGikoRoundType): TRoundItem;
+function TRoundList.ParseRoundThreadLine(Line: string): Boolean;
 var
        s: string;
+       roundname: string;
+       threadItem: TThreadItem;
        i: Integer;
+//    threadItem: TThreadItem;
 begin
-       Result := TRoundItem.Create;
-       if RoundType = grtBoard then begin
-               Result.ThreadTitle := '';
-               Result.FileName := '';
-               Result.RoundType := grtBoard;
-               for i := 0 to 2 do begin
-                       s := GikoSys.GetTokenIndex(Line, #1, i);
+       //Result := TRoundItem.Create;
+       //Result.RoundType := grtItem;
+       threadItem := nil;
+       for i := 0 to 4 do begin
+               s := GikoSys.GetTokenIndex(Line, #1, i);
+               try
                        case i of
                                0:
-               begin
-               Result.URL := s;
-            Result.Item := BBSsFindBoardFromURL( s );
-          end;
-                               1: Result.BoardTitle := s;
-                               2: Result.RoundName := s;
+                               begin
+                                       //Result.URL := s;
+                                       threadItem := BBSsFindThreadFromURL( s );
+                                       //if threadItem <> nil then begin
+                                       //    BoardList.Add( threadItem.ParentBoard.URL );
+                                       //end;
+                               end;
+                               //1: Result.BoardTitle := s;
+                               //2: Result.FileName := s;
+                               //3: Result.ThreadTitle := s;
+                               4: roundname := s;
                        end;
+               except
+                       Result := false;
+                       Exit;
                end;
-       end else if RoundType = grtItem then begin
-               Result.RoundType := grtItem;
-               for i := 0 to 4 do begin
-                       s := GikoSys.GetTokenIndex(Line, #1, i);
+       end;
+       if( threadItem <> nil ) then begin
+               if not threadItem.Round then begin
+                       threadItem.RoundName := roundname;
+                       RoundNameList.Add(roundname);
+                       //RoundNameList.Find(roundname, i);
+                       //threadItem.RoundName := PChar(RoundNameList[i]);
+                       threadItem.Round := True;
+               end;
+               Result := true;
+       end else begin
+               Result := false;
+       end;
+end;
+
+function TRoundList.ParseOldRoundBoardLine(Line: string): Boolean;
+       var
+       i: Integer;
+       s: string;
+       roundname: string;
+       board: TBoard;
+begin
+       //Result := TRoundItem.Create;
+       //Result.ThreadTitle := '';
+       //Result.FileName := '';
+       //Result.RoundType := grtBoard;
+       board := nil;
+       for i := 0 to 2 do begin
+               s := GikoSys.GetTokenIndex(Line, #1, i);
+               try
                        case i of
                                0:
-               begin
-               Result.URL := s;
-            Result.Item := BBSsFindThreadFromURL( s );
-          end;
-                               1: Result.BoardTitle := s;
-                               2: Result.FileName := s;
-                               3: Result.ThreadTitle := s;
-                               4: Result.RoundName := s;
+                               begin
+                                       board := BBSs[ 0 ].FindBBSID( s );
+                                       if board = nil then begin
+                                               raise Exception.Create('\82±\82Ì\8f\84\89ñ\82Í\93Ç\82Ý\8d\9e\82ß\82È\82¢\82æ\81i\91½\95ª\8aO\95\94\94Â\81j');
+                                       end;
+                               end;
+                               //1: Result.FBoardTitle := s;
+                               2: roundname := s;
                        end;
+               except
+                       Result := false;
+                       Exit;
+               end;
+       end;
+       if( board <> nil ) then begin
+               if not board.Round then begin
+                       board.RoundName := roundname;
+                       RoundNameList.Add(roundname);
+                       //RoundNameList.Find(roundname, i);
+                       //board.RoundName := PChar(RoundNameList[i]);
+                       board.Round := true;
                end;
+               Result := true;
+       end else begin
+               Result := false;
        end;
 end;
 
+function TRoundList.ParseOldRoundThreadLine(Line: string): Boolean;
+       var
+       i: Integer;
+       s: string;
+       roundname : string;
+       buf: string;
+       board: TBoard;
+       threadItem: TThreadItem;
+       bbsID: string;
+begin
+//     Result := TRoundItem.Create;
+//     Result.RoundType := grtItem;
+       threadItem := nil;
+       for i := 0 to 4 do begin
+               s := GikoSys.GetTokenIndex(Line, #1, i);
+               try
+                       case i of
+                               0: bbsID := s;
+                               //1: Result.BoardTitle := s;
+                               2:
+                               begin
+                                       //Result.FileName := s;
+                                       board := BBSs[ 0 ].FindBBSID(bbsID);
+                                       if board <> nil then begin
+                                               buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
+                                               buf := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
+                                               threadItem := BBSsFindThreadFromURL(buf);
+                                       end else begin
+                                               raise Exception.Create('\82±\82Ì\8f\84\89ñ\82Í\93Ç\82Ý\8d\9e\82ß\82È\82¢\82æ');
+                                       end;
+                               end;
+                               //3: Result.ThreadTitle := s;
+                               4: roundname := s;
+                       end;
+               except
+                       Result := false;
+                       Exit;
+               end;
+       end;
+       if( threadItem <> nil ) then begin
+               if not threadItem.Round then begin
+                       threadItem.RoundName := roundname;
+                       RoundNameList.Add(roundname);
+                       //RoundNameList.Find(roundname, i);
+                       //threadItem.RoundName := PChar(RoundNameList[i]);
+                       threadItem.Round := true;
+               end;
+               Result := true;
+       end else begin
+               Result := false;
+       end;
+
+end;
+procedure  TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList);
+var
+       i: Integer;
+       j: Integer;
+       tempString: string;
+       tmpURL: string;
+       oldHost: string;
+       oldBoardName: string;
+       newHost: string;
+       newBoardName: string;
+begin
+       if oldURLs.Count <> newURLs.Count then
+               Exit;
+       //\82±\82±\82©\82ç\81ABoard\82ÌURL\82Ì\95Ï\8dX
+       for j :=0 to oldURLs.Count - 1 do begin
+               for i :=0 to FBoardList.Count - 1 do begin
+                       if TRoundItem(FBoardList[i]).URL = oldURLs[j] then
+                               TRoundItem(FBoardList[i]).TmpURL := newURLs[j];
+               end;
+       end;
+       //\82±\82±\82Ü\82Å\81ABoard\82ÌURL\82Ì\95Ï\8dX
+
+       //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
+       //\96Ê\93|\82¾\82¯\82Çthread\82Í\82»\82ê\82¼\82êURL\82ð\83`\83\83\83b\83N\82µ\82È\82ª\82ç\82â\82Á\82Ä\82©\82È\82«\82á\82¢\82¯\82È\82¢\81B
+       for i := 0 to oldURLs.Count - 1 do begin
+               tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
+               oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
+               oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
+               tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
+               newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
+               newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
+
+               for j := 0 to FItemList.Count - 1 do begin
+                       tempString := TRoundItem(FItemList[j]).URL;
+                       if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
+                               tempString := StringReplace(tempString, oldHost, newHost,[]);
+                               TRoundItem(FItemList[j]).TmpURL := tempString;
+                       end;
+               end;
+       end;
+       //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
+
+end;
+
 end.