Mirage Source
[BUGFIX] RE9: SpawnItem - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+----- Thread: [BUGFIX] RE9: SpawnItem (/showthread.php?tid=2283)



[BUGFIX] RE9: SpawnItem - shlink - 22-10-2008

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.


Re: [BUGFIX] RE9: SpawnItem - Rian - 09-01-2009

Necroposting bot has been banned.