Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/RoundData.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.6 by h677, Wed Dec 10 13:52:57 2003 UTC revision 1.7 by h677, Thu Dec 11 11:49:09 2003 UTC
# Line 79  const Line 79  const
79          ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch';        //あとでBoardGroupへ移動          ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch';        //あとでBoardGroupへ移動
80          ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //同上          ROUND_ITEM_FILENAME: string  = 'RoundItem.2ch';         //同上
81          ROUND_INDEX_VERSION: string = '2.00';          ROUND_INDEX_VERSION: string = '2.00';
82        ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error行を保管する
83        ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error行を保管する
84  constructor TRoundItem.Create;  constructor TRoundItem.Create;
85  begin  begin
86          inherited Create;          inherited Create;
# Line 305  var Line 306  var
306          i: Integer;          i: Integer;
307          sl: TStringList;          sl: TStringList;
308          FileName: string;          FileName: string;
309        errorSl: TStringList;
310        errorFileName: string;
311          Item: TRoundItem;          Item: TRoundItem;
312  begin  begin
313          sl := TStringList.Create;          sl := TStringList.Create;
314        errorSl := TStringList.Create;
315            errorSl.Duplicates := dupIgnore;
316          try          try
317                  //ボード巡回ファイル読み込み                  //ボード巡回ファイル読み込み
318                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME;
319            //エラー行保存ファイル読み込み
320            errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME;
321                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
322                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
323              Item := TRoundItem.Create;              if FileExists(errorFileName) then begin
324                    try
325                            errorSl.LoadFromFile(errorFileName);
326                    except
327                    end;
328                end;
329                //Item := TRoundItem.Create;
330              //1行目はバージョン              //1行目はバージョン
331                          if sl[0] = ROUND_INDEX_VERSION then begin                          if sl[0] = ROUND_INDEX_VERSION then begin
332                                  for i := 1 to sl.Count - 1 do begin                                  for i := sl.Count - 1 downto 1 do begin
   
333                                          Item := ParseRoundBoardLine(sl[i]);                                          Item := ParseRoundBoardLine(sl[i]);
334                                          FBoardList.Add(Item);                      if Item <> nil then begin
335                                          RoundNameList.Add(Item.RoundName);                                                  FBoardList.Add(Item);
336                                                    RoundNameList.Add(Item.RoundName);
337                        end else begin
338                            errorSl.Add( sl[i] );
339                            sl.Delete(i);
340                        end;
341                                  end;                                  end;
342              end else begin              end else begin
343                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので                  if FOldFileRead then begin  //ギコナビ本体がボードファイルをよみとった後じゃないとクラッシュするので
344                                          for i := 1 to sl.Count - 1 do begin                                          for i := sl.Count - 1 downto  1 do begin
345                                                  Item := ParseOldRoundBoardLine(sl[i]);                                                  Item := ParseOldRoundBoardLine(sl[i]);
346                                                  FBoardList.Add(Item);                          if Item <> nil then begin
347                                                  RoundNameList.Add(Item.RoundName);                                                          FBoardList.Add(Item);
348                                                            RoundNameList.Add(Item.RoundName);
349                            end else begin
350                                    errorSl.Add( sl[i] );
351                                    sl.Delete(i);
352                            end;
353                                          end;                                          end;
354                  end else                  end else
355                          FOldFileRead := true;                          FOldFileRead := true;
356              end;              end;
357                  end;                  end;
358            if errorSl.Count > 0 then
359                    errorSl.SaveToFile(errorFileName);
360          finally          finally
361            errorSl.Free;
362                  sl.Free;                  sl.Free;
363          end;          end;
364  end;  end;
# Line 343  var Line 368  var
368      j: Integer;      j: Integer;
369          sl: TStringList;          sl: TStringList;
370          FileName: string;          FileName: string;
371        errorSl: TStringList;
372        errorFileName: string;
373          Item: TRoundItem;          Item: TRoundItem;
374      boardList : TStringList;      boardList : TStringList;
375  begin  begin
376      boardList := TStringList.Create;      boardList := TStringList.Create;
377      boardList.Duplicates := dupIgnore;      boardList.Duplicates := dupIgnore;
378        errorSl := TStringList.Create;
379            errorSl.Duplicates := dupIgnore;
380          sl := TStringList.Create;          sl := TStringList.Create;
381          try          try
382                  //スレ巡回ファイル読み込み                  //スレ巡回ファイル読み込み
383                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;                  FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME;
384            //エラー行保存ファイル読み込み
385            errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME;
386                  if FileExists(FileName) then begin                  if FileExists(FileName) then begin
387                          sl.LoadFromFile(FileName);                          sl.LoadFromFile(FileName);
388              Item := TRoundItem.Create;              if FileExists(errorFileName) then begin
389                    try
390                            errorSl.LoadFromFile(errorFileName);
391                    except
392                    end;
393                end;
394                //Item := TRoundItem.Create;
395                          //1行目はバージョン                          //1行目はバージョン
396              if sl[0] = ROUND_INDEX_VERSION then begin              if sl[0] = ROUND_INDEX_VERSION then begin
397                                  for i := 1 to sl.Count - 1 do begin                                  for i := sl.Count - 1 downto 1 do begin
   
398                                          Item := ParseRoundThreadLine(sl[i], boardList);                                          Item := ParseRoundThreadLine(sl[i], boardList);
399                                          FItemList.Add(Item);                      if Item <> nil then begin
400                                          RoundNameList.Add(Item.RoundName);                                                  FItemList.Add(Item);
401                                  end;                                                  RoundNameList.Add(Item.RoundName);
402                                            end else begin
403                            errorSl.Add(sl[i]);
404                            sl.Delete(i);
405                        end;
406                    end;
407              end else begin              end else begin
408                  LoadRoundBoardFile;                  LoadRoundBoardFile;
409                  for i := 1 to sl.Count - 1 do begin                  for i := sl.Count - 1 downto 1 do begin
410                                          Item := ParseOldRoundThreadLine(sl[i], boardList);                                          Item := ParseOldRoundThreadLine(sl[i], boardList);
411                                          FItemList.Add(Item);                      if Item <> nil then begin
412                                          RoundNameList.Add(Item.RoundName);                                                  FItemList.Add(Item);
413                                                    RoundNameList.Add(Item.RoundName);
414                        end else begin
415                                                    errorSl.Add(sl[i]);
416                            sl.Delete(i);
417                        end;
418                                  end;                                  end;
419              end;              end;
420                    j := boardList.Count - 1;
421                while j >= 0 do begin
422                            GikoSys.ReadSubjectFile( BBSsFindBoardFromURL( boardList[j] ) );
423                        boardList.Delete(j);
424                    Dec(j);
425                    end;
426                if errorSl.Count > 0 then
427                    errorSl.SaveToFile(errorFileName);
428                  end;                  end;
         j := boardList.Count - 1;  
         while j >= 0 do begin  
                 GikoSys.ReadSubjectFile( BBSsFindBoardFromURL( boardList[j] ) );  
             boardList.Delete(j);  
                 Dec(j);  
         end;  
429          finally          finally
430                  sl.Free;                  sl.Free;
431          boardList.Free;          boardList.Free;
# Line 433  begin Line 481  begin
481      Result.RoundType := grtBoard;      Result.RoundType := grtBoard;
482      for i := 0 to 2 do begin      for i := 0 to 2 do begin
483          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
484          case i of          try
485                    case i of
486                  0:                  0:
487                  begin                  begin
488                          Result.URL := s;                                  Result.URL := s;
489                  end;                          end;
490              1: Result.BoardTitle := s;                  1: Result.BoardTitle := s;
491              2: Result.RoundName := s;                  2: Result.RoundName := s;
492                    end;
493            except
494                    Result := nil;
495                Exit;
496          end;          end;
497      end;      end;
498  end;  end;
# Line 454  begin Line 507  begin
507          Result.RoundType := grtItem;          Result.RoundType := grtItem;
508      for i := 0 to 4 do begin      for i := 0 to 4 do begin
509          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
510          case i of          try
511                  0:              case i of
512                  begin                  0:
513                          Result.URL := s;                  begin
514                  threadItem := BBSsFindThreadFromURL( s );                      Result.URL := s;
515                  if threadItem <> nil then begin                      threadItem := BBSsFindThreadFromURL( s );
516                          BoardList.Add( threadItem.ParentBoard.URL );                      if threadItem <> nil then begin
517                            BoardList.Add( threadItem.ParentBoard.URL );
518                        end;
519                  end;                  end;
520                  end;                  1: Result.BoardTitle := s;
521              1: Result.BoardTitle := s;                  2: Result.FileName := s;
522              2: Result.FileName := s;                  3: Result.ThreadTitle := s;
523              3: Result.ThreadTitle := s;                  4: Result.RoundName := s;
524                          4: Result.RoundName := s;              end;
525            except
526                    Result := nil;
527                Exit;
528          end;          end;
529      end;      end;
530  end;  end;
# Line 483  begin Line 541  begin
541      Result.RoundType := grtBoard;      Result.RoundType := grtBoard;
542      for i := 0 to 2 do begin      for i := 0 to 2 do begin
543          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
544          case i of          try
545                  0:                  case i of
546                  begin                          0:
547                  board := BBSs[ 0 ].FindBBSID( s );                          begin
548                          Result.URL := board.URL;                          board := BBSs[ 0 ].FindBBSID( s );
549                  end;                      if board <> nil then begin
550              1: Result.FBoardTitle := s;                                          Result.URL := board.URL;
551              2: Result.RoundName := s;                      end else begin
552                            raise Exception.Create('この巡回は読み込めないよ(多分外部板)');
553                        end;
554                            end;
555                    1: Result.FBoardTitle := s;
556                    2: Result.RoundName := s;
557                    end;
558            except
559                    Result := nil;
560                Exit;
561          end;          end;
562      end;      end;
563  end;  end;
# Line 501  function TRoundList.ParseOldRoundThreadL Line 568  function TRoundList.ParseOldRoundThreadL
568          s: string;          s: string;
569          buf: string;          buf: string;
570      board: TBoard;      board: TBoard;
571      threadItem: TThreadItem;  //    threadItem: TThreadItem;
572      bbsID: string;      bbsID: string;
573  begin  begin
574          Result := TRoundItem.Create;          Result := TRoundItem.Create;
575      Result.RoundType := grtItem;      Result.RoundType := grtItem;
576      for i := 0 to 4 do begin      for i := 0 to 4 do begin
577          s := GikoSys.GetTokenIndex(Line, #1, i);          s := GikoSys.GetTokenIndex(Line, #1, i);
578          case i of          try
579              0: bbsID := s;                  case i of
580              1: Result.BoardTitle := s;                  0: bbsID := s;
581              2:                      1: Result.BoardTitle := s;
582                  begin                  2:
583                  Result.FileName := s;                          begin
584                  board := BBSs[ 0 ].FindBoardFromTitle(Result.BoardTitle);                          Result.FileName := s;
585                  if board <> nil then begin                          board := BBSs[ 0 ].FindBoardFromTitle(Result.BoardTitle);
586                      BoardList.Add(board.URL);                      if board <> nil then begin
587                      buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);                              BoardList.Add(board.URL);
588                                          Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';                          buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1);
589                  end;                                                  Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50';
590              end;                      end else begin
591              3: Result.ThreadTitle := s;                          raise Exception.Create('この巡回は読み込めないよ(多分外部板)');
592              4: Result.RoundName := s;                      end;
593                        end;
594                    3: Result.ThreadTitle := s;
595                        4: Result.RoundName := s;
596                    end;
597            except
598                    Result := nil;
599                Exit;
600          end;          end;
601      end;      end;
602  end;  end;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26