When objp is nullptr, ai_door_is_openable assumes Buddy_objnum is a
valid object number, but this assumption is not guaranteed to be true.
When it is false, the game crashes. This crash can be triggered by a
brain robot trying to make nearby robots snipe.
Fix the crash by passing the robot of interest.
Reported-by: Yarn <http://www.dxx-rebirth.com/frm/index.php/topic,2165.0.html>
Macro LINE_SPACING previously used global grd_curcanv implicitly.
Change it to take a canvas argument. Change all callers to pass
grd_curcanv, so that usage is explicit.
Yarn reported that Descent 2: Counterstrike level 9 can place the
guidebot in a situation where
(Escort_goal_index == object_guidebot_cannot_reach &&
Escort_special_goal != ESCORT_GOAL_UNSPECIFIED)
If this happens and the player grabs a powerup, then the game crashes
trying to check if the grabbed powerup was of the type that the guidebot
sought. Since the guidebot was not seeking any object, the answer is
that this is not the sought object.
The design ought not set Escort_goal_index to an invalid object index,
but it does. Fixing that is too invasive for now. Add a special case
to prevent this crash.
Reported-by: Yarn <http://www.dxx-rebirth.com/frm/index.php/topic,2158.0.html>
Contains 2 calls - to obj_create and init_ai_object. For safety reasons and tidiness compared to using obj_create directly. The call to init_ai_object in recreate_thief was already redundant.
Conflicts:
common/arch/sdl/window.cpp - Remove unused EVENT_WINDOW_CLOSED and w_callback local var
common/ui/dialog.cpp - Remove unused EVENT_WINDOW_CLOSED
escort_get_goal_segment expected exists_in_mine to return object_none or
a valid object. In some mines, exists_in_mine will return
object_guidebot_cannot_reach, which is neither object_none nor a valid
object. Exclude reading the segment of the unreachable object.
Replace delete dcx::window kludge with a better solution: instead of requiring every handler to delete the window, add a window_event_result::deleted, which gets returned if the window was deleted by the handler, so window_close knows not to attempt to delete it again.