Changeset 84 for trunk/UEngine.pas
- Timestamp:
- Dec 31, 2021, 9:48:23 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r78 r84 188 188 end; 189 189 190 TMetroTrain = class; 191 192 TMetroCarriage = class 193 Train: TMetroTrain; 194 end; 195 196 TMetroCarriages = class(TFPGObjectList<TMetroCarriage>) 197 end; 198 190 199 { TMetroTrain } 191 200 … … 204 213 InStation: Boolean; 205 214 TargetStation: TLineStation; 215 Carriages: TMetroCarriages; 206 216 function GetTargetStationDistance: Integer; 207 217 function GetPosition: TPoint; … … 421 431 422 432 uses 423 UGeometric, UFormMain, ULanguages , UPixelPointer;433 UGeometric, UFormMain, ULanguages; 424 434 425 435 resourcestring … … 433 443 SNewHighScore = 'New high score!'; 434 444 SOldHighScore = 'Old high score was %d passengers in %d days.'; 445 STrackPointNotFound = 'Track point %d not found'; 446 SStationNotDefined = 'Station have to be defined'; 447 SNoOldStationToConnectNew = 'No old line station to connect new station'; 448 SStationWithoutMapStation = 'Station have to have MapStation'; 435 449 436 450 { TTrackLinks } … … 475 489 destructor TTrack.Destroy; 476 490 begin 477 Points.Free;478 Links.Free;491 FreeAndNil(Points); 492 FreeAndNil(Links); 479 493 inherited; 480 494 end; … … 490 504 destructor TTrackLink.Destroy; 491 505 begin 492 Points.Free;506 FreeAndNil(Points); 493 507 inherited; 494 508 end; … … 512 526 destructor TMap.Destroy; 513 527 begin 514 Rivers.Free;528 FreeAndNil(Rivers); 515 529 inherited; 516 530 end; … … 618 632 destructor TTrackPointsAngle.Destroy; 619 633 begin 620 TrackLinks.Free;634 FreeAndNil(TrackLinks); 621 635 inherited; 622 636 end; … … 744 758 destructor TTrackPoint.Destroy; 745 759 begin 746 NeighLinks.Free;747 NeighPoints.Free;760 FreeAndNil(NeighLinks); 761 FreeAndNil(NeighPoints); 748 762 inherited; 749 763 end; … … 917 931 begin 918 932 if not Assigned(Station) then 919 raise Exception.Create( 'Station have to be defined');933 raise Exception.Create(SStationNotDefined); 920 934 if not Assigned(LineStationDown) and not Assigned(LineStationUp) and (LineStations.Count > 0) then 921 raise Exception.Create( 'No old line station to connect new station');935 raise Exception.Create(SNoOldStationToConnectNew); 922 936 NewLineStation := TLineStation.Create; 923 937 NewLineStation.Line := Self; … … 1061 1075 Index2 := Points.IndexOf(TP2); 1062 1076 if (Index1 = -1) then 1063 raise Exception.Create( 'TrackPoint1 not found');1077 raise Exception.Create(Format(STrackPointNotFound, [1])); 1064 1078 if (Index2 = -1) then 1065 raise Exception.Create( 'TrackPoint2 not found');1079 raise Exception.Create(Format(STrackPointNotFound, [2])); 1066 1080 if Index1 > Index2 then begin 1067 1081 Temp := Index1; … … 1095 1109 destructor TMetroLine.Destroy; 1096 1110 begin 1097 Trains.Free;1098 LineStations.Free;1099 Track.Free;1111 FreeAndNil(Trains); 1112 FreeAndNil(LineStations); 1113 FreeAndNil(Track); 1100 1114 inherited; 1101 1115 end; … … 1184 1198 Passengers := TMetroPassengers.Create; 1185 1199 Passengers.FreeObjects := False; 1200 Carriages := TMetroCarriages.Create; 1186 1201 Direction := 1; 1187 1202 Line := nil; … … 1190 1205 destructor TMetroTrain.Destroy; 1191 1206 begin 1192 Passengers.Free; 1207 FreeAndNil(Passengers); 1208 FreeAndNil(Carriages); 1193 1209 inherited; 1194 1210 end; … … 1791 1807 // Load new passengers 1792 1808 if Assigned(CurrentStation) and not Assigned(CurrentStation.MapStation) then 1793 raise Exception.Create( 'Station have to have MapStation');1809 raise Exception.Create(SStationWithoutMapStation); 1794 1810 if Assigned(CurrentStation) then 1795 1811 for P := CurrentStation.MapStation.Passengers.Count - 1 downto 0 do begin
Note:
See TracChangeset
for help on using the changeset viewer.