forked from J-Flight/AeroLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAeroLib.simba
More file actions
194 lines (162 loc) · 5.05 KB
/
AeroLib.simba
File metadata and controls
194 lines (162 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{$DEFINE Aerolib}
{$include_once core/engine/Boxes.simba}
{$include_once core/Globals.simba}
{$include_once core/engine/TPA.simba}
{$include_once core/engine/DTM.simba}
{$include_once core/engine/Time.simba}
{$include_once core/engine/Math.simba}
{$include_once core/engine/Color.simba}
{$include_once core/engine/SimbaEx.simba}
{$include_once misc/Graphics.simba}
{$include_once misc/Debugging.simba}
{$IFDEF SMART}
{$include_once misc/connection/Smart.simba}
{$ENDIF}
{$include_once core/engine/InputHandler.simba}
{$include_once core/Timing.simba}
{$include_once core/Text.simba}
{$include_once core/Menu.simba}
{$include_once core/Interfaces.simba}
{$include_once core/Animation.simba}
{$include_once core/Chat.simba}
{$include_once entities/items/Items.simba}
{$include_once misc/Combat.simba}
{$include_once entities/EntityHandler.simba}
{$include_once entities/player/Player.simba}
{$include_once entities/player/Login.simba}
{$include_once entities/player/WorldHandler.simba}
{$include_once core/Bank.simba}
{$include_once misc/connection/Highscores.simba}
{$include_once misc/connection/ItemInfo.simba}
{$include_once misc/connection/Stats.simba}
{$include_once misc/ezForm.simba}
{$include_once entities/object/Object.simba}
{$include_once entities/npc/NPC.simba}
{$include_once core/minimap/Minimap.simba}
{$include_once core/Breaking.simba}
{$include_once core/gametabs/GameTab.simba}
{$include_once core/Antiban.simba}
{$include_once core/gametabs/WorldSwitcher.simba}
{$include_once core/gametabs/Prayer.simba}
{$include_once misc/randomsolvers/Master.simba}
{$include_once misc/Reports.simba}
{$IFDEF WALKER}
{$include_once core/minimap/Walker/Walker.simba}
{$ENDIF}
Const
AL_VERSION_MAIN = 1.2;
AL_VERSION_SUB = 6;
AL_GITURL = 'https://github.com/J-Flight/AeroLib';
procedure AL_Update();
const
GitHead = 'https://github.com/';
RawGitHead = 'https://raw.githubusercontent.com/';
MasterHead = 'https://codeload.github.com/';
MasterFoot = '/zip/master';
var
hFile,hZip,i,P: Integer;
ZipData,RepoName: String;
Begin
warn('Updating AeroLib...', WT_CORE);
P := -1;
for i := 1 To Length(AL_GITURL) Do
if (AL_GITURL[i] = '/') Then
P := i + 1;
RepoName := Copy(AL_GITURL, P, Length(AL_GITURL) - P + 1);
ZipData := Copy(AL_GITURL, Length(GitHead) + 1, Length(AL_GITURL) - Length(GitHead) + 1);
ZipData := PS_GetPage(MasterHead + ZipData + MasterFoot);
hZip := RewriteFile(IncludePath + RepoName + '.zip', False);
if (hZip <> -1) Then
begin
if (not WriteFileString(hZip, ZipData)) Then
begin
warn('Failed to download AeroLib from GitHub.', WT_CORE);
Exit;
end;
If (hFile <> 0) Then
CloseFile(hFile);
CloseFile(hZip);
UnzipFile(IncludePath + RepoName + '.zip', IncludePath);
DeleteFile(IncludePath + RepoName + '.zip');
RenameFile(IncludePath + 'AeroLib', IncludePath + 'AeroLib_Old');
RenameFile(IncludePath + RepoName + '-master', IncludePath + RepoName);
warn('Successfully updated AeroLib, please restart the script.', WT_CORE);
TerminateScript;
end else
begin
if (hFile <> 0) Then
CloseFile(hFile);
if (hZip <> 0) Then
CloseFile(hZip);
Exit;
end;
if (hFile <> 0) Then
CloseFile(hFile);
end;
procedure AL_CheckVersion();
var
Page,vM,vS : String;
begin
warn('Checking version...', WT_CORE);
try
Page := GetPage('http://pastebin.com/raw/RHP62Pi7');
except
warn('Error while checking version', WT_CORE);
Exit;
end;
vM := Between('<_MAIN>', '</_MAIN>', Page);
vS := Between('<_SUB>', '</_SUB>', Page);
if (vM = '') or (vS = '') then
begin
warn('Error while checking version', WT_CORE);
Exit;
end;
if ((AL_VERSION_MAIN >= strToFloat(vM)) and (AL_VERSION_SUB >= strToFloat(vS))) then
begin
warn('Currently up to date.', WT_CORE);
exit;
end;
if (AL_VERSION_MAIN < strToFloat(vM)) then
begin
warn('There'#39's a major update available for AeroLib.', WT_CORE);
AL_Update();
exit;
end;
if (AL_VERSION_SUB < strToFloat(vS)) then
warn('There'#39's a minor update available for AeroLib.', WT_CORE);
AL_Update();
end;
procedure initAL();
begin
AL_InitMessage(AL_VERSION_MAIN, AL_VERSION_SUB);
warn('Initiating AeroLib...', WT_CORE);
if DirectoryExists(IncludePath + 'AeroLib_Old') then
begin
warn('Removing old AeroLib files...', WT_CORE);
if not DeleteDirectory(IncludePath + 'AeroLib_Old', True) then
warn('Error deleting old AeroLib', WT_CORE)
else
warn('Old AeroLib deleted', WT_CORE);
end;
AL_CheckVersion();
setupGauss();
loadObjDB();
MouseSpeed := 20;
ocr_LoadFont(AppPath + 'Fonts\UpChars07_s\', UpFont);
addOnTerminate('freeSFonts');
setLength(IgnoreWorlds, 3);
IgnoreWorlds := [325, 337, 365];
setupInterfaces();
setupRandoms();
{$IFDEF SMART}
OS_SMART.Create(765, 503, SMART_UserAgent, ['']);
if not RSReady() then
begin
warn('Failed to initiate SMART, terminating script', WT_CORE);
terminateScript();
end;
OS_Smart.Graphics.Clear;
{$ENDIF}
Me.ModelSet := False;
warn('Startup complete!', WT_CORE);
end;