GET_OBJ_RNUM() is a macro that finds the "real number" of an item. The "real number" is the corresponding index into the object index.

The line that is crashing is suppoed to make sure that the count of "current objects of this type in game" is updated correctly.
But, something is wrong about the real_number of this object. Potentially two things could be wrong here:
- it could be too low, in the negatives. This would give object_index[-234] which would obviously crash.
- it could be too high, beyond the end of the object_index. Thus object_index[1213334].number would probably point to some memory you don't control.

The check above this line is checking whether the real number is "NOTHING". Depending on your setup, either NOTHING is -1 (if indices can be negative) or the highest possible integer (if indices are limited to positive numbers). Whichever one it is, it is not very interesting. I find it highly unlikely that the real number suddenly has changed into a negative value (unless it was actually a negative NOTHING).

So, the number is corrupted otherwise.
As I see it, there are two options again:
- either the number has changed (through a memory overwrite somewhere else)
- or the object_index has changed, removing the top elements, and this is causing it to be shorter than the current rnum. This only happens one place, in genobj.c, delete_object. And this cleans up after itself.

So, this leaves only one thing - memory corruption. Sorry about that, not really what I think you wanted to hear.