Fix R_SkinUsable crashes in (some) custom addons
Fixes #994 (closed). This was a really nasty bug, because it involves two implicit assumptions made by two different parts of the code, which conflict with each other but only in very specific circumstances. The problem already existed before 2.2.10, but because the checks in R_SkinUsable
were executed in a different order, the part of the code that crashes was never reached, more by luck than by design.
For future reference:
- For the most part, the codebase tries to ensure that the level header for
gamemap
is notNULL
, even whengamemap
is not a valid map. This is because the game will sometimes start a "server" withgamemap
as the current map, for example when loading the character select screen via the unlockable level select. It probably shouldn't do that, but making it not do that will probably require refactoring a lot of code. - Most of the codebase already ensures that
gamemap
has a valid level header, but there's one spot inF_StartTitleScreen
that doesn't. I guess that whoever wrote that code assumed that the game could never reach a state where this causes problems, but turns out it can. - There's no reason for
R_SkinUsable
to assume thatgamemap
has a valid level header, even though the game tries to ensure this. So I added aNULL
check.
Edited by MascaraSnake