Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[BUGFIX] RE9: SpawnItem
#1
Miniscule, but annoying.

Code:
Sub SpawnItem(ByVal ItemNum As Long, ByVal ItemVal As Long, ByVal MapNum As Long, ByVal x As Long, ByVal y As Long)
Dim i As Long

    ' Check for subscript out of range
    If ItemNum < 0 Or ItemNum > MAX_ITEMS Or MapNum  MAX_MAPS Then
        Exit Sub
    End If
    
    ' Find open map item slot
    i = FindOpenMapItemSlot(MapNum)
    
    Call SpawnItemSlot(i, ItemNum, ItemVal, Item(ItemNum).Data1, MapNum, x, y)
End Sub
As commented, there is a check for this runtime error. But if an NPC doesn't drop an item, it will still cause this error. I'm sure there is a more appropriate fix towards this, perhaps somewhere in the NPC coding. But the following fix works 100% to my knowledge.

In the Sub above, replace:
Code:
ItemNum < 0
with:
Code:
ItemNum < 1

That's it. Now you truely shouldn't get the dreaded runtime error 9. If there is a more appropriate fix, post it or thou shalt be smited! ...or not... :evil:
And if this fix is wrong in some way, by all means, let me know and consider this a bug report rather than a fix. But from testing, it fixes the error 100% with no problems to the rest of the game that I've seen.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)