Fix crash when spawning a BOT_2PAI on a dedicated server
On a dedicated server, spawning in a bot with G_AddPlayer
and passing the BOT_2PAI
parameter as a bot type will crash the server with the following error: I_Error(): CV_Set: sessionanalog2 no string set!
The cause for this is due to sessionanalog2
not being registered on a dedicated server, making that setting invalid. Despite that, though, the logic that creates the ticcmd for the bot will still try to set the variable, causing the game to crash. This patch fixes this by checking if it's running on a dedicated server first, and does not attempt to set the variable if it is.
The bug can be reproduced with this script:
COM_AddCommand("addbot", function (player)
G_AddPlayer(1, 1, "bot", BOT_2PAI)
end)
Simply add this script to a dedicated server, join it, and then run this command to trigger the crash.