I've noticed when looking through the include, especially Timing.Scar, there are a lot of while..do loops that could be shortened. So I tested to see if my way of shortening them would make them quicker or not.
Example: (just an example)
SCAR Code:
{*******************************************************************************
Function WaitUpTextMulti(S: TStringArray; Time: integer): Boolean;
By: Marpis & N1ke!
Description: Waits for a TStringArray of UpText, returns true if found
*******************************************************************************}
Function WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean;
var
T, i: Integer;
begin
MarkTime(i);
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) do
begin
if (IsUpTextMultiCustom(S)) then
begin
Result := True;
Writeln(IntToStr(TimeFromMark(i)));
Exit;
end;
Wait(20 + Random(20));
end;
Writeln(IntToStr(TimeFromMark(i)));
end;
That's what I used to test WaitUpTextMulti with. I added all the timing with 'i' so I could time it. It ended up outputting: 47;
Then I edited that function to a shorter version and tested to see how long it took.
SCAR Code:
Function N_WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean;
var
T, i: Integer;
begin
MarkTime(i);
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) and (not Result) do
begin
Result := (IsUpTextMultiCustom(S));
if Result then begin Writeln(IntToStr(TimeFromMark(i))); Exit; end;
Wait(20 + Random(20));
end;
Writeln(IntToStr(TimeFromMark(i)));
end;
Keep in mind that anything to do with the var 'i' is only for testing purposes right now.
And this function output: 31; therefor being faster..right?
This would be the function without the timing stuff, just for reference:
SCAR Code:
Function N_WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean;
var
T: Integer;
begin
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) and (not Result) do
begin
Result := (IsUpTextMultiCustom(S));
Wait(20 + Random(20));
end;
end;
There are many functions in Timing.scar that this pertains to, as well as many other ways to go about this.
Please feel free to comment as I'm curious as to what others think about this.