nekitdev/gd.py

`check_id` validator in `entity` crash

Closed this issue · 4 comments

This validator checks if the id is at least 0, but in reality it can be -1: a level with id 92984940 uses the song with this id - Practice: Stay Inside Me. When trying to fetch info about this level, an unhandled exception is thrown.

The overall assumption that id is at least 0 is not wrong, and allows for some optimizations. The question is whether this -1 case is worth removing that check; for instance we could handle it separately or clamp the value somehow. Even GD doesn't properly handle this -1 as far as I'm aware at the moment:

What I'm saying is that some pieces of code depend on the id >= 0 invariant, and we need to look into possible solutions to this.

some pieces of code depend on the id >= 0

My bad, didn't see that. Will think of something else.

Closing this as there is only one edge case that needs to be handled.