Dan Cardin
2009-06-19 21:24:17
I am not sure if anything I am doing makes a difference, but whatever.
FindCoins
function CheckArea(area: string): Boolean;
doesnt need the writeln at the end. Its checking to see if one is open, writing it is pointless.
AreaInfo
EDIT: but this is better
Small things, but yah.
I also wonder if all the headings and whatnot are good for being in the code. I can see them being nicely documented somewhere, but having them all inside the code itself just makes the files larger and annoying to navigate through. I would say doing something similar to the php manual, with all nice examples and stuff inside, but that would probably be a large undertaking. Lacking that, I think just making sure there is documentation online of all of the functions would be enough to have and just delete everything out of the code itself.
So far ive only gone through amount.scar, but there will probably be other shortenings that can be done. I dont know what the devs do exactly, but going back through SRL functions, even if its not broken, to see what can be improved upon could prove useful if not already done.
Anyways, I was just perusing SRL and saw a few things i might be able to improve upon.
FindCoins
V: array [0..1] of TVariantArray;//i changed that 1 from a 2 since i couldnt find where a a [2] would be used.function CheckArea(area: string): Boolean;
doesnt need the writeln at the end. Its checking to see if one is open, writing it is pointless.
AreaInfo
procedure AreaInfo(area: string; var startx, starty, rowsize, colsize,
colnumber, rownumber: Integer);
var a: array [0..4] of tintegerarray;
e: integer;
begin
a[0] := [560,212,36,42,4,7];
a[1] := [63,97,55,39,21,4];
a[2] := [35,91,44,44,10,5];
a[3] := [310,75,32,49,4,7];
a[4] := [24,75,32,49,4,7];
case LowerCase(area) of
'inv', 'inventory': e := 0;
'shop': e := 1;
'bank': e := 2;
'trade': e := 3;
'your trade': e := 4;
else writeln('AreaInfo');
end;
startx := a[e][0];
starty := a[e][1];
rowsize := a[e][2];
colsize := a[e][3];
colnumber := a[e][4];
rownumber := a[e][5];
end;That is shortened quite bit.EDIT: but this is better
procedure AreaInfo(area: string; var startx, starty, rowsize, colsize,
colnumber, rownumber: Integer);
var a: array [0..4] of tintegerarray;
s: TStringArray;
e, i: integer;
Opt : TIntegerArray;
begin
a[0] := [560,212,36,42,4,7];
a[1] := [63,97,55,39,21,4];
a[2] := [35,91,44,44,10,5];
a[3] := [310,75,32,49,4,7];
a[4] := [24,75,32,49,4,7];
Opt := [startx, starty, rowsize, colsize, colnumber, rownumber];
s := ['inv', 'inventory', 'shop', 'bank', 'trade', 'your trade'];
for I := 2 to High(S) Do
case LowerCase(area) of
s[I] : e := i - 1;
end;
writeln(e);
for I := 0 To High(Opt) Do
Opt[I] := a[e][I];
end;Small things, but yah.
I also wonder if all the headings and whatnot are good for being in the code. I can see them being nicely documented somewhere, but having them all inside the code itself just makes the files larger and annoying to navigate through. I would say doing something similar to the php manual, with all nice examples and stuff inside, but that would probably be a large undertaking. Lacking that, I think just making sure there is documentation online of all of the functions would be enough to have and just delete everything out of the code itself.
So far ive only gone through amount.scar, but there will probably be other shortenings that can be done. I dont know what the devs do exactly, but going back through SRL functions, even if its not broken, to see what can be improved upon could prove useful if not already done.
Anyways, I was just perusing SRL and saw a few things i might be able to improve upon.