blackdtools / Blackd-Proxy-CLASSIC

Blackd Proxy CLASSIC
MIT License
9 stars 7 forks source link

"exiva useitemonname" can freeze BlackD Proxy #99

Open divinity76 opened 5 years ago

divinity76 commented 5 years ago

for some bizarre reason, the command exiva useitemonname:81 0C, Red Arrow will freeze BlackD Proxy. if we add a space before the item id: exiva useitemonname: 81 0C, Red Arrow it does not freeze.

the freeze occurs in


Public Function UseItemOnName(idConnection As Integer, ByVal strTile As String) As Long 'HHBCODE 'use first found item with ID on first found creature with name....
'will use the item and return 0 (if item and name found), or -1.

    #If FinalMode = 1 Then
        On Error GoTo goterr
    #End If
    Dim ItemID As Long
    Dim skipBytes As Integer
    Dim ItemIDHexStr As String
    Dim LowByte As Byte
    Dim HighByte As Byte
    Dim success As Boolean
    ItemIDHexStr = UCase(Left(strTile, 5))
    ItemID = GetTheLongFromFiveChr(ItemIDHexStr)
    LowByte = LowByteOfLong(ItemID)
    HighByte = HighByteOfLong(ItemID)
    strTile = Mid(strTile, 7) '7?? with the comma, i thought it'd be 6?? ...
    Dim name As String

    While Left(strTile, 1) = " "
    strTile = Mid(strTile, 1) 'ignore spaces..
    Wend

... the While condition is true:

image

... and the Mid(strTile, 1) command which is supposed to remove the first character (because it's a space)... image

does absolutely nothing!!!!! which makes the While() condition true again, which cause an infinite loop freezing BlackD Proxy

why is Mid(strTile, 1) doing nothing? i don't know.. and why does it not occur when adding the extra space? ... again, i don't know.. anybody have any idea how to fix this?