-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebug.scar
352 lines (311 loc) · 15.9 KB
/
Debug.scar
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
{==============================================================================\
| MSI Group Scripting Include |
| Debug.scar |
|==============================================================================|
| For all debugging and progress report routines |
| |
| * procedure MSI_Debug(); * by Rasta Magician |
| * procedure MSI_AddToProggy(); * by The MSI Team |
| * function MSI_SkillActions(): TStringArray; * by The MSI Team |
| * procedure MSI_GetReportInfo(); * by Coh3n |
| * function MSI_LocToText(): String; * by The MSI Team |
| * function MSI_LocToCity(): String; * by The MSI Team |
| * function MSI_GroupDigits(): String; * PriSoner and Nava2 |
| * function MSI_PrintSave; * by Naum |
| * Procedure MSI_SaveLog; * by Naum |
| * procedure MSI_ProgressReport(); * by Coh3n |
\_____________________________________________________________________________}
{******************************************************************************}
{ procedure MSI_Debug(ProcName, TheMessage: string; DebugLevel:integer); }
{ By: Rasta Magician }
{ Date: 10 June 2010 }
{ Description: Used for Debugging. Will debug to DebugBox if }
{ DebugLevel >= Debug_LevelToDebug }
{******************************************************************************}
procedure MSI_Debug(ProcName, TheMessage: string; DebugLevel:integer);
var
DebugMSG, path, str: string;
theFile: Integer;
begin
if DebugLevel < Debug_LevelToDebug then exit;
DebugMSG := TheTime+': ';
try
DebugMSG := DebugMSG + Capitalize(Players[CurrentPlayer].Name)+': ';
except end;
case DebugLevel of
//to add some more detail
DEBUG_PLAYER_ACTIONS: DebugMSG := DebugMSG + 'Player Action: ';
DEBUG_FUNCTIONS : DebugMSG := DebugMSG + 'Entering Func: ';
DEBUG_SMALL_DETAILS : DebugMSG := DebugMSG + 'Detail: ';
end;
DebugMSG := DebugMSG + ProcName + ': ';
DebugMSG := DebugMSG + TheMessage;
writeln(DebugMSG);
//Save the message to a file
if (saveDebug) then
try
path := AppPath + 'Includes\SRL\SRL\msi\MSI Logs\';
if FileExists(path + scriptStart + '.txt') then
begin
theFile := OpenFile(path + scriptStart + '.txt', False);
ReadFileString(theFile, str, FileSize(theFile));
CloseFile(theFile);
end;
theFile := RewriteFile(path + scriptStart + '.txt', False);
WriteFileString(theFile, str + #10 + DebugMSG);
CloseFile(theFile);
except
Writeln('Debug saving - error occurred');
end;
end;
{******************************************************************************}
{ procedure MSI_AddToProggy(item, quantity, which: Integer); }
{ By: The MSI Team }
{ Date: 10 June 2010 }
{ Description: Adds specified element to the progress report - if parameter }
{ is unused, set to -1 }
{******************************************************************************}
const
ADD_EXP = 0;
ADD_ITEMS = 1;
ADD_LOADS = 2;
procedure MSI_AddToProggy(item, quantity, which: Integer);
begin
if (quantity = 0) then
Exit;
case which of
ADD_EXP:
begin
IncEx(ProgressReportArray[CurrentPlayer].SkillInfo[CurrentSkill].TotalEXP, quantity);
IncEx(Stats_CustomVars[STATS_EXP], quantity);
end;
ADD_ITEMS:
begin
IncEx(ProgressReportArray[CurrentPlayer].SkillInfo[CurrentSkill].ObjQuants[item], quantity);
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
IncEx(Stats_CustomVars[STATS_LOGS], quantity);
SKILL_MINING:
IncEx(Stats_CustomVars[STATS_ORES], quantity);
end;
end;
ADD_LOADS:
begin
Inc(ProgressReportArray[CurrentPlayer].SkillInfo[CurrentSkill].TotalLoads);
Inc(Stats_CustomVars[STATS_LOADS]);
end;
end;
MSI_SendStats;
end;
{******************************************************************************}
{ function MSI_SkillActions(what: variant): TStringArray; }
{ By: The MSI Team }
{ Date: 10 June 2010 }
{ Description: Gets an array of skill actions }
{******************************************************************************}
function MSI_SkillActions(what: variant): TStringArray;
begin
case what of
{
SKILL_ATTACK : Result := ['Attack', 'Attacked'];
SKILL_STRENGTH : Result := ['Stength', 'Strengthed'];
SKILL_DEFENSE : Result := ['Defence', 'Defended'];
SKILL_RANGE : Result := ['Range', 'Ranged'];
SKILL_PRAYER : Result := ['Prayer', 'Prayed'];
SKILL_MAGE : Result := ['Magic', 'Maged'];
SKILL_RUNECRAFTING : Result := ['Runecrafting', 'RuneCrafted'];
SKILL_HP : Result := ['Hitpoints', 'HPed'];
SKILL_AGILITY : Result := ['Agility', 'Agilised'];
SKILL_HERBLORE : Result := ['Herblore', 'Herblored'];
SKILL_THIEVING : Result := ['Thieving', 'Thieved'];
SKILL_CRAFTING : Result := ['Crafting', 'Crafted'];
SKILL_FLETCHING : Result := ['Flecthing', 'Flecthed'];
SKILL_SLAYER : Result := ['Slayer', 'Slayed'];
SKILL_MINING : Result := ['Mining', 'Mined'];
SKILL_SMITHING : Result := ['Smithing', 'Smithed'];
SKILL_FISHING : Result := ['Fishing', 'Fished'];
SKILL_COOKING : Result := ['Cooking', 'Cooked'];
SKILL_FIREMAKING : Result := ['Firemaking', 'Burned'];
}
SKILL_WOODCUTTING : Result := ['Woodcutting', 'Chopped'];
{
SKILL_FARMING : Result := ['Farming', 'Farmed'];
SKILL_CONSTRUCTION : Result := ['Construction', 'Constructed'];
SKILL_HUNTER : Result := ['Hunter', 'Hunted'];
SKILL_SUMMONING : Result := ['Summoning', 'Summoned'];
}
end;
end;
{******************************************************************************}
{ procedure MSI_GetReportInfo; }
{ By: Coh3n }
{ Date: 10 June 2010 }
{ Description: Gets the necessary proggy info that ISN'T reset during runtime }
{******************************************************************************}
procedure MSI_GetReportInfo;
var
i, level: Integer;
skills: TVariantArray;
theSkill: TStringArray;
begin
//Gets the levels of each skill in the Players array
skills := PlayerSkills[CurrentPlayer];
for i := 0 to High(skills) do
begin
theSkill := MSI_SkillActions(skills[i]);
level := GetSkillLevel(theSkill[0]);
ProgressReportArray[CurrentPlayer].SkillInfo[i].Level := level;
end;
//Gets the player's location
ProgressReportArray[CurrentPlayer].PlayerLoc := Players[CurrentPlayer].Integers[P_LOC];
//Gets teh player's activity
ProgressReportArray[CurrentPlayer].PlayerStatus := Players[CurrentPlayer].Active;
end;
{******************************************************************************}
{ function MSI_LocToText(Which: Integer): string; }
{ By: The MSI Team }
{ Date: 10 June 2010 }
{ Description: Converts the location constant to a string }
{******************************************************************************}
function MSI_LocToText(Which: Integer): string;
begin
case Which of
LOC_POWER_SKILL:
Result := 'Powerskilling';
LOC_LOST:
Result := 'Lost';
LOC_VE_BANK:
Result := 'Varrock east bank';
LOC_VE_TREES:
Result := 'Varrock east trees';
LOC_IN_RANDOM:
Result := 'In random';
else
MSI_Debug('MSI_LocToText', 'Invalid location!', debug_Functions);
end;
end;
{******************************************************************************}
{ function MSI_LocToCity(which: Integer): string; }
{ By: The MSI Team }
{ Date: 10 June 2010 }
{ Description: Converts the location constant to a string of the RS city }
{******************************************************************************}
function MSI_LocToCity(which: Integer): string;
begin
case Which of
LOC_VE_BANK, LOC_VE_TREES:
Result := 'Varrock';
else
Result := 'The wonderful world of Runescape!';
end;
end;
{******************************************************************************}
{ function MSI_GroupDigits(n: integer; token: String): String; }
{ By: PriSoner and Nava2 }
{ Date: 10 June 2010 }
{ Description: Formats an integer into groups of 3 seperated by `token' and }
{ returns a formatted string (i.e 1234567 would become 1,234,567) }
{******************************************************************************}
function MSI_GroupDigits(n: integer; token: String): String;
var
b: integer;
begin
Result := IntToStr(n);
b := length(Result) + 1;
if b > 3 then
repeat
b := b - 3;
if b > 1 then
insert(token, Result, b);
until (b < 3);
end;
{******************************************************************************}
{ procedure MSI_PrintSave(FileH, S : String); }
{ By: Naum }
{ Date: 10 June 2010 }
{ Description: Prints the string in the report and debug box also saves the }
{ report }
{******************************************************************************}
Procedure MSI_PrintSave(FH : Integer; S : String);
Begin
{$IFDEF SIMBA}
Writeln(s);
{$ELSE}
AddToReport(S);
{$ENDIF}
if (saveDebug) then
WriteFileString(FH, S+#13+#10);
End;
{******************************************************************************}
{ procedure MSI_ProgressReport; }
{ By: Coh3n }
{ Date: 10 June 2010 }
{ Description: Prints the progress report of each player }
{******************************************************************************}
function MSI_GetItemList(whichPlayer, whichSkill: Integer): TIntegerArray; forward;
procedure MSI_ProgressReport;
var
i, j, k, FileH: Integer;
skill: TStringArray;
intItems: TIntegerArray;
path: String;
begin
try
if (saveDebug) then
begin
path := AppPath + 'Includes\SRL\SRL\MSI\MSI Progress Reports\';
FileH := ReWriteFile(path + scriptStart + '.txt', False);
WriteFileString(FileH, 'Progress Report Saved:' + #13 + #10);
WriteFileString(fileH, #13 + #10 + 'This proggie was written ' + TheDate(Date_Formal )+ ' at ' + TheTime + #13 + #10);
end;
{$IFNDEF SIMBA}
ClearReport;
{$ENDIF}
ClearDebug;
MSI_GetReportInfo;
MSI_PrintSave(FileH, '{----------------------------------------------------------------}'); //64 from '{' to '}'
MSI_PrintSave(FileH, '{ MSI Phoenix Player Report }');
MSI_PrintSave(FileH, '{------------------------------ ' + MSI_VERSION_NUMBER + ' -----------------------------}');
MSI_PrintSave(FileH, '{ ' + PadR('Time Running: ' + TimeRunning, 59) + '}');
MSI_PrintSave(FileH, '{----------------------------------------------------------------}');
for i := 0 to (HowManyPlayers - 1) do
with ProgressReportArray[i] do
begin
MSI_PrintSave(FileH, '{ }');
MSI_PrintSave(FileH, '{ ' + PadR('Player ' + IntToStr(i) + ': ' + Capitalize(PlayerName), 59) + '}'); //PlayerName
MSI_PrintSave(FileH, '{ ' + PadR('City: ' + PlayerCity, 59) + '}'); //PlayerCity
MSI_PrintSave(FileH, '{ ' + PadR('Location: ' + MSI_LocToText(PlayerLoc), 59) + '}'); //PlayerLoc
MSI_PrintSave(FileH, '{ ' + PadR('Time: ' + MsToTime(PlayerTime, Time_Short), 59) + '}'); //TotalTime
MSI_PrintSave(FileH, '{ ' + PadR('Active: ' + Capitalize(BoolToStr(PlayerStatus)), 59) + '}'); //PlayerStatus
if (not PlayerStatus) then //FalseReason
MSI_PrintSave(FileH, '{ ' + PadR('Reason: ' + FalseReason, 57) + '}');
MSI_PrintSave(FileH, '{ }');
for j := 0 to High(SkillInfo) do //SkillInfo
with SkillInfo[j] do
begin
skill := MSI_SkillActions(PlayerSkills[CurrentPlayer][j]);
MSI_PrintSave(FileH, '{ ' + PadR('Skill: ' + skill[0], 59) + '}');
MSI_PrintSave(FileH, '{ ' + PadR('Time: ' + MsToTime(TotalTime, Time_Short), 57) + '}'); //TotalTime }
MSI_PrintSave(FileH, '{ ' + PadR('Loads: ' + IntToStr(TotalLoads), 57) + '}'); //TotalLoads }
MSI_PrintSave(FileH, '{ ' + PadR('Experience: ' + MSI_GroupDigits(Round(TotalEXP), ','), 57) + '}'); //TotalEXP
if (Level < 1) then
MSI_PrintSave(FileH, '{ ' + PadR('Level: Not yet defined', 57) + '}')
else
MSI_PrintSave(FileH, '{ ' + PadR('Level: ' + IntToStr(Level), 57) + '}'); //Level
intItems := MSI_GetItemList(i, j);
for k := 0 to High(intItems) do //TotalObj
begin
MSI_PrintSave(FileH, '{ ' + PadR('Item: ' + MSI_Item[intItems[k]].Name, 55) + '}');
MSI_PrintSave(FileH, '{ ' + PadR('Amount: ' + MSI_GroupDigits(ObjQuants[k], ','), 55) + '}'); //ObjQuants
end;
MSI_PrintSave(FileH, '{ }');
MSI_PrintSave(FileH, '{----------------------------------------------------------------}');
end;
end;
MSI_PrintSave(FileH, '{----------------------------------------------------------------}');
if (saveDebug) then
CloseFile(FileH);
except
WriteLn('Proggie saving - error occured');
end;
end;