PDA

View Full Version : Worldswitcher->QuickSelect fix



loragnor
06-29-2013, 11:46 AM
I noticed that when logging in, my script would not click on a favorite world button even if it corresponded with the world I told my script to log in to and that number contained a '1'. In generating output from QuickSelect, I saw that the OCR was reading a '1' on the button as an 'I' (capital i). Here is a suggestion for a slight rework:


function QuickSelect(World: Integer): Integer;
var
txt : array [0..1] of String;
i,H : integer;
FilePath: String;
begin
{*** Read the ini file and get the number of world servers ******************}
H := 139; // A default in case we cannot read the ini file
FilePath := IncludePath + 'SRL/SRL/misc/worlds.ini';
try
H := StrToInt(ReadINI('Worlds', 'High', FilePath));
except
Writeln('QuickSelect: Could not load world arrays, attempting to rewrite Worlds.INI');
if not UpdateWorlds then
SRL_Warn('QuickSelect', 'Could not Load World arrays, please download mixster''s world parser, and replace Worlds.ini', Warn_AllVersions);
end;
{************************************************* ***************************}

Result := -1;
for i := 0 to 1 do
begin
// if inRange(world, 1, 99) then // Replaced to check all the server numbers
if inRange(world, 1, H) then
txt[i] := GetTextAtExWrap(569+(i*43), 448, 597+(i*47), 472, 0, 5, 2, 12378347, 2, 'LoginChars')
else
txt[i] := GetTextAtExWrap(569+(i*43), 448, 597+(i*47), 472, 0, 5, 2, 12378347, 2, 'SmallCharsNS');
// Replace any 'I' with a '1'
txt[i] := Replace(txt[i],'I','1');
txt[i] := Copy(txt[i], 0, High(txt[i]));
if strToIntDef(txt[0], 0) = world then
result := 1
else if strToIntDef(txt[1], 0) = world then
result := 2;
if inrange(result, 1, 2) then exit;
end;
end;


Just another suggestion.