SRL Archive - MSI Suggestions

MSI_GetDTMInfo


Sir R. M8gic1an

2010-06-09 11:13:10

Here is what it is:
[php]
{******************************************************************************}
{ function MSI_GetDTMInfo(which: Integer): TIntegerArray; }
{ By: The MSI Team }
{ Description: Gets the coodinates for the DTM points }
{******************************************************************************}
function MSI_GetDTMInfo(which: Integer): TIntegerArray;
begin
case which of
HATCHET_BRONZE..HATCHET_RUNE:
Result := [ 586, 243, 587, 249, 574, 261, 575, 248, 587, 240 ];

LOGS_NORMAL..LOGS_YEW:
Result := [ 623, 291, 624, 279, 635, 296, 614, 299, 609, 289 ];

else
MSI_Debug('MSI_GetDTMInfo', 'Invalid item constant!', DEBUG_FUNCTIONS);
end;
end;
[/php]


Here is what I think it should be :
[php]
{******************************************************************************}
{ function MSI_GetDTMInfo(which: Integer): TPointArray; }
{ By: The MSI Team }
{ Description: Gets the coodinates for the DTM points }
{******************************************************************************}
function MSI_GetDTMInfo(which: Integer): TPointArray;
begin
case which of
HATCHET_BRONZE..HATCHET_RUNE:
Result := [
Point(586, 243), // Main Point
Point(587, 249),
Point(574, 261),
Point(575, 248),
Point(587, 240)
];

LOGS_NORMAL..LOGS_YEW:
Result := [
Point(623, 291), // Main Point
Point(624, 279),
Point(635, 296),
Point(614, 299),
Point(609, 289)
];

else
MSI_Debug('MSI_GetDTMInfo', 'Invalid item constant!', DEBUG_FUNCTIONS);
end;
end;
[/php]

Why? Good practice, these are not integers, these are points.
It's a bit more bloated, but definitely much clearer.

~RM

Method

2010-06-09 13:51:36

Perhaps the function name should be changed also if the only 'info' returned is the DTM's coordinates?

Coh3n

2010-06-09 17:26:02

I agree with both of you. Could be changed to MSI_GetDTMPoints I guess.

nickrules

2010-06-09 22:43:01

Agreed 100%
So much cleaner and easier to read. Also, its a bit more informative about what the numbers are, rather than a line of integers…

Not too sure how much work it would be to convert all of the MSI_GetDTMInfo lines into MSI_GetDTMPoints.

Coh3n

2010-06-09 22:46:47

From: nickrules
Agreed 100%
So much cleaner and easier to read. Also, its a bit more informative about what the numbers are, rather than a line of integers…

Not too sure how much work it would be to convert all of the MSI_GetDTMInfo lines into MSI_GetDTMPoints.

That's the beautiful thing about MSI, things like that are suppose to be easy. ;)

I think MSI_LoadDTM is the only function that uses MSI_GetDTMInfo.

Coh3n

2010-06-10 12:39:56

Committed.