From 3740e0b8933b560879a2610626a4ede012e85204 Mon Sep 17 00:00:00 2001 From: Olly Date: Tue, 19 Apr 2016 05:52:50 +0100 Subject: [PATCH] Let's see if this updates --- lib/misc/smart.simba | 160 +++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 73 deletions(-) diff --git a/lib/misc/smart.simba b/lib/misc/smart.simba index 752987c..47473b8 100644 --- a/lib/misc/smart.simba +++ b/lib/misc/smart.simba @@ -18,14 +18,6 @@ The source for this file can be found `here Result) then - Result := Directories[I]; + Result := Result + Directories[I]; end; function FindDirectory(Directory, Path: String): Boolean; @@ -124,48 +108,80 @@ function findJavaPath(out res: string): boolean; var Drive: String; - CurrentPath: String; + CurrentPath, c: String; + Drives: TStringArray; + i: Integer; begin - result := false; - res := ''; - - drive := Copy(PluginPath, 0, 3); + Result := False; + Res := ''; - if (FindDirectory('Program\sFiles\s\(x86\)', Drive)) then + if (Recursive) then begin - CurrentPath := Drive + 'Program Files (x86)\'; + Drive := Dir + ':/'; end else - CurrentPath := Drive + 'Program Files\'; + Drive := Copy(PluginPath, 0, 3); + + if (x86) then + CurrentPath := Drive + 'Program Files (x86)\' + else + CurrentPath := Drive + 'Program Files\'; if (FindDirectory('Java|java', CurrentPath + '\')) then begin CurrentPath := CurrentPath + 'Java\'; end else - begin - print('Failed To Find Path: ' + CurrentPath + 'Java\', TDebug.ERROR); - exit; - end; + if (Dir <> 'Z') then + Result := _LocateJavaPath(Res, x86, chr(ord(Dir) + 1), True); - Drive := GetDirectoryName('jre', CurrentPath); + if (Result) then + Exit(); - if (length(drive) > 0) then + Drives := GetDirectoryNames('jre', CurrentPath); + + if (Length(Drives) > 0) then begin - if (smartShowConsole) then - CurrentPath := CurrentPath + Drive + '\bin\java.exe' - else - CurrentPath := CurrentPath + Drive + '\bin\javaw.exe'; - end else + c := CurrentPath; + for i := 0 to High(Drives) do + begin + CurrentPath := c; + if (smartShowConsole) then + CurrentPath := CurrentPath + Drives[i] + '\bin\java.exe' + else + CurrentPath := CurrentPath + Drives[i] + '\bin\javaw.exe'; + + Result := FileExists(CurrentPath); + if (Result) then + Break; + end; + end else begin + Drives := GetDirectoryNames('jdk', CurrentPath); + c := CurrentPath; + + for i := 0 to High(Drives) do begin - Drive := GetDirectoryName('jdk', CurrentPath); - + CurrentPath := c; if (smartShowConsole) then - CurrentPath := CurrentPath + Drive + 'jre\bin\java.exe' + CurrentPath := CurrentPath + Drives[i] + '\bin\java.exe' else - CurrentPath := CurrentPath + Drive + 'jre\bin\javaw.exe'; + CurrentPath := CurrentPath + Drives[i] + '\bin\javaw.exe'; + + Result := FileExists(CurrentPath); + if (Result) then + Break; end; + end; + + Result := FileExists(CurrentPath); + Res := CurrentPath; +end; + +function FindJavaPath(out Path: String): Boolean; +begin + if (not _LocateJavaPath(Path, True)) then + if (not _LocateJavaPath(Path, False)) then + Exit(False); - result := FileExists(CurrentPath); - res := currentPath; + Result := True; end; (* @@ -277,24 +293,20 @@ Example: smartGetParameters(tsa); *) -function smartGetParameters(out params: TStringArray): boolean; +function SmartGetParameters(out params: TStringArray): Boolean; var - page: string; + WorldLink: String; + p: Integer; begin - page := getPage(SMART_URL); + WorldLink := Between('var worldLink=', ''',', GetPage('http://www.runescape.com/game-applet')); + if (WorldLink = '') then + Exit(False); - params := explode(',', between('worldLink=''', '''', page)); + p := Pos('com/', WorldLink); + Params := Params + Copy(WorldLink, 2, p + 2); + Params := Params + Copy(WorldLink, p + 4, Length(WorldLink)); - result := (length(params) = 2); - - if (not result) then - begin - print('Error while grabbing parameters', TDebug.ERROR); - print('Make sure you can reach the RS website, and no active firewall is blocking Simba', TDebug.HINT); - exit(false); - end; - - print('smartGetParameters(): Succesfully grabbed paramters', TDebug.SUB); + Result := True; end; (* @@ -369,12 +381,13 @@ begin path := getJavaPath(); plugins := implode(',', smartPlugins); - print('Using parameters ' + toStr(params)); + print('Root: ' + params[0]); + print('Params: ' + params[1]); print('Using plugins "' + plugins + '"'); __smartCurrentTarget := 0; __smartCurrentTarget := smartSpawnClient(path, stringReplace(PluginPath, '\', '/', [rfReplaceAll]), - params[0], ',' + params[1], w, h, smartInitSeq, smartUserAgent, '', plugins); + params[0], params[1], w, h, smartInitSeq, smartUserAgent,'', plugins); if (__smartCurrentTarget <> 0) then begin @@ -647,7 +660,8 @@ begin try smartImage.resetPersistentMemory(); smartImage.free(); - except finally + except + finally __smartIsDrawingSetup := false; end; end;