boberman
2008-08-16 11:45:49
It would be great if we could change the findbank function to this
And remove all the opening bank stuff. We already have an open bank function. If that is too much then I would happy if we split this part into a sub function.
The reason is simple. Often I want to check and see if I am in a bank, the find bank function would be the fastest method for that. But I don't want to open the bank. For example, usually I will want to see "Am I in the bank?" then "Do I have a Pickaxe" and finally "Open bank, dump everything and if no pickaxe, get one".
I don't know, it just doesn't seem right that a function named "FindBank" would go and open the bank as well, then it should be named "FindAndOpenBank" because it is doing those two things.
function FindBank(TheBank: string): Boolean;
var
bx, by, TheDTM: Integer;
WhichAngle: Extended;
begin
TheBank := LowerCase(TheBank);
case TheBank of
'feb': TheDTM := DTMFromString('78DA63AC67626088634001FFFFFD63F80FA41' +
'9416C2060AC01AA4987C83141D5FCF9C3C4C0055503028CAD44A8' +
'E924AC0600131E11B5');
'fwb': TheDTM := DTMFromString('78DA636C676260086540038C0CFFC12403C37' +
'F206004A98986C8304155FCF9C3C4C0055503D6D14C849A6EC26A' +
'009F5A0EA1');
'db': TheDTM := DTMFromString('78DA636C67626008644001FFFFFD63F80FA41' +
'9416C2060AC01AAF182C8B140D5FCF9C304A619A17CB09A204C35' +
'22E86AC2F09B0300F8811153');
'veb': TheDTM := DTMFromString('78DA63EC61626008624001FFFFFD63F80FA41' +
'9416C2060EC00AA8982C83141D5FCF9C3C4C0055503028C138850' +
'D343580D00122211A9');
'vwb': TheDTM := DTMFromString('78DA63EC606260B066C000FF819811440301E' +
'354A01A3B88381354FECF1F260611A81A1000AB3125428D2E7E35' +
'0087F80E5E');
'akb': TheDTM := DTMFromString('78DA636C606260F06140019D9D710CFF81342' +
'310FF0702C652A01A37881C1354CD9F3F4C0C5C5035200056E345' +
'841A3FFC6A002A3B0F97');
else
begin
srl_Warn('FindBank', 'Invalid bank name', warn_Warning);
Exit;
end;
end;
Result := FindDtmRotated(TheDTM, bx, by, MMX1, MMY1, MMX2, MMY2,
Radians(-30), Radians(30), 0.05, WhichAngle);
FreeDTM(TheDTM);And remove all the opening bank stuff. We already have an open bank function. If that is too much then I would happy if we split this part into a sub function.
The reason is simple. Often I want to check and see if I am in a bank, the find bank function would be the fastest method for that. But I don't want to open the bank. For example, usually I will want to see "Am I in the bank?" then "Do I have a Pickaxe" and finally "Open bank, dump everything and if no pickaxe, get one".
I don't know, it just doesn't seem right that a function named "FindBank" would go and open the bank as well, then it should be named "FindAndOpenBank" because it is doing those two things.