Skip to content

Commit

Permalink
Fix hex NPC ids not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Muriel-Salvan committed Jan 26, 2021
1 parent 2e1cab9 commit 1e54000
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
54 changes: 54 additions & 0 deletions Data/Source/Scripts/AutoTest_Suite.psc
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,57 @@ function ClearRegisteredTests()
JsonUtil.StringListClear(gJSONRunFile, "tests_to_run")
SaveDb()
endFunction

; Convert a String storing a hex number into an int
;
; Parameters::
; * *hexString* (string): The hexadecimal string
; Result::
; * int: The corresponding number
int function HexToInt(string hexString)
int result = 0
int strLength = StringUtil.GetLength(hexString)
int idx = 0
while (idx < strLength)
string currentDigit = StringUtil.GetNthChar(hexString, idx)
int currentValue
if (currentDigit == "1")
currentValue = 1
elseIf (currentDigit == "2")
currentValue = 2
elseIf (currentDigit == "3")
currentValue = 3
elseIf (currentDigit == "4")
currentValue = 4
elseIf (currentDigit == "5")
currentValue = 5
elseIf (currentDigit == "6")
currentValue = 6
elseIf (currentDigit == "7")
currentValue = 7
elseIf (currentDigit == "8")
currentValue = 8
elseIf (currentDigit == "9")
currentValue = 9
elseIf (currentDigit == "A")
currentValue = 10
elseIf (currentDigit == "B")
currentValue = 11
elseIf (currentDigit == "C")
currentValue = 12
elseIf (currentDigit == "D")
currentValue = 13
elseIf (currentDigit == "E")
currentValue = 14
elseIf (currentDigit == "F")
currentValue = 15
else
currentValue = 0
endIf
if currentValue > 0
result += Math.LeftShift(currentValue, 4 * (strLength - idx - 1))
endIf
idx += 1
endWhile
return result
endFunction
8 changes: 7 additions & 1 deletion Data/Source/Scripts/AutoTest_Suite_NPCs.psc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ endFunction
; * *testName* (string): The test name to run
function RunTest(string testName)
string[] fields = StringUtil.Split(testName, "/")
ScreenshotOf(fields[1] as int, fields[0])
int formId = 0
if (StringUtil.SubString(fields[1], 0, 2) == "0x")
formId = HexToInt(StringUtil.SubString(fields[1], 2))
else
formId = fields[1] as int
endIf
ScreenshotOf(formId, fields[0])
SetTestStatus(testName, "ok")
endFunction

Expand Down

0 comments on commit 1e54000

Please sign in to comment.