From 1eaac406b50a689be1e2860b1d4716193d51277c Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 19 May 2010 19:40:07 +0200 Subject: [PATCH] Fixed a lil' bug. Should AddDTM be in the constructor of TMDTM? Now you need to do AddDTM(mdtm) in the script? --- Units/MMLCore/dtm.pas | 12 +++++------- Units/MMLCore/dtmutil.pas | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Units/MMLCore/dtm.pas b/Units/MMLCore/dtm.pas index 4b04acb..dd78536 100644 --- a/Units/MMLCore/dtm.pas +++ b/Units/MMLCore/dtm.pas @@ -34,8 +34,6 @@ type { TMDTM } - { TMDTM } - TMDTM = class(TObject) private FPoints : TMDTMPointArray; @@ -51,6 +49,9 @@ type property Count : integer read FLen write SetPointCount; property Points : TMDTMPointArray read FPoints; end; + + { TMDTMS } + TMDTMS = class(TObject) //Manages the DTMs TMufasaDTMs private Client: TObject; @@ -256,15 +257,12 @@ end; function TMDTM.ToString: string; begin - + Result := ''; end; function TMDTM.Valid: boolean; begin - result := false; - if Count < 1 then - exit; - result := true; + Result := Count > 0; end; end. diff --git a/Units/MMLCore/dtmutil.pas b/Units/MMLCore/dtmutil.pas index 77d8e30..dee0867 100644 --- a/Units/MMLCore/dtmutil.pas +++ b/Units/MMLCore/dtmutil.pas @@ -127,6 +127,7 @@ function SDTMToMDTM(Const DTM: TSDTM): TMDTM; var I: Integer; begin + Result := TMDTM.Create; Result.Count := Length(DTM.SubPoints) + 1; //The mainpoint is in a different structure Result.Points[0].x := DTM.MainPoint.x; @@ -152,7 +153,7 @@ procedure NormalizeDTM(var dtm: TMDTM); var i:integer; begin - if (dtm.count < 1) or ((dtm.Points[0].x = 0) and (dtm.Points[0].y = 0)) then //Already normalized + if (dtm = nil) or (dtm.count < 1) or ((dtm.Points[0].x = 0) and (dtm.Points[0].y = 0)) then //Already normalized exit; for i := 1 to dtm.Count - 1 do begin