Skip to content

Fix segfault when trying to spawn an MT_PLAYER from Lua

Hanicef requested to merge Hanicef/SRB2:fix-segfault-player-spawnmobj into next

when trying to spawn an MT_PLAYER using P_SpawnMobj or P_SpawnMobjFromMobj, the game would segfault due to a missing parameter for that specific type. this is a special case that exists to prevent Lua from removing a player mobj before it has gotten assigned it's corresponding player, which used to cause segfaults in prior versions. however, that parameter was not passed when being called from Lua, and will thus segfault when trying to spawn an MT_PLAYER. the fix simply works by passing NULL for that special parameter, which will set the player field on the mobj to NULL instead of an undefined address.

Merge request reports