Bugfixes "Segfault when debug-killing mon_yugg"
Summary
Bugfixes "Segfault when debug-killing mon_yugg"
Purpose of change
Fixes #80911
Describe the solution
Describe alternatives you've considered
- Making a monster the alpha_talker.
- Adding check for nullptr alpha_talker before trying to activate EoC
Allowing for null talker is easier than making yugg the alpha_talker. Second option is a good alternative.
Testing
- Spawned yugg
- Debug-killed the monster
- Got debug messege that talker is null
- The game didn't crash afterward.
Additional context
For me it looks like the opposite of fixing it, is there a reason old handling do not work? It itself was part of a fix, see #75295
UPD: yeah i fully remembered what was the issue, and the actual issue here is that if you check EOC_YUGG_DEATH, the only effect that uses alpha talker is condition player_see_u; it was added to prevent message appearing if you do not see yugg dying; i suspect that player_see_u need additionally check if alpha talker is even presented, and if not, return false (you cannot see if you do not exist)
I was not happy with my solution; that's why I put it into the draft. After some digging I realized that adding null alpha talker into the dialogue does not solves the issue and it just masks the problem. The actual problem is in condition.cpp. Pretty much whole code in the file assumes that const_actor returns valid, not nullptr value but it is not true. In 2 cases it will return nullptr:
- is_beta == true; has_beta == false;
- is_beta == false; has_alpha == false;
Edit 1.
The function const_actor warns about this problem, but it is not checked by other functions.
Superseded by #81774