Skip to content

Commit

Permalink
Merge pull request #699 from ao-org/fix_bad_npc_inv
Browse files Browse the repository at this point in the history
Saninty check when loading NPCs
  • Loading branch information
RecoX authored Jan 8, 2025
2 parents 0f0e2ac + 3fa27e0 commit 8ebe5f9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Codigo/MODULO_NPCs.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,11 @@ Function OpenNPC(ByVal NpcNumber As Integer, _
245 .flags.AIAlineacion = val(Leer.GetValue("NPC" & NpcNumber, "Alineacion"))

246 .invent.NroItems = val(Leer.GetValue("NPC" & NpcNumber, "NROITEMS"))
If .invent.NroItems > UBound(.invent.Object) Then
Debug.Print "Error in NPC " & .name & " configuration, too many items in inventory! Max possible is " & UBound(.invent.Object)
End If
Debug.Assert .invent.NroItems <= UBound(.invent.Object) ' NPC not properly configured, it cannot have more so many items in the inventory
.invent.NroItems = Min(UBound(.invent.Object), .invent.NroItems) 'Clamp the number of items to make sure it's not too big

247 .Humanoide = CBool(val(Leer.GetValue("NPC" & NpcNumber, "Humanoide")))

Expand Down

0 comments on commit 8ebe5f9

Please sign in to comment.