Bugzilla – Bug 3752
cs_user_spawn() native does not properly respawn players
Last modified: 2014-02-08 23:51:54 PST
Note: The same bug applies to the fm_cs_user_spawn() stock from fakemeta_util.inc, which is based on the same code. Description: If you try to use this native to respawn a player some time after he dies, he may spawn with the so-called HUD bug (basically the player can't see the crosshair, use the flashlight, or change weapons) or he may not spawn at all and a player "ghost" (static player model floating in the air) may appear on the map. These bugs are caused because the code is incorrectly using the "DEAD_RESPAWNABLE + DLLFunc_Spawn" method. Here's a post explaining the details and a simple solution: http://forums.alliedmods.net/showpost.php?p=678294&postcount=19 Here's an alternate solution posted on the same thread: http://forums.alliedmods.net/showpost.php?p=681963&postcount=21
Created attachment 2479 [details] [review] Fix for cs_user_spawn Builds fine, not tested.
Compiled and tested successfully on : CS 1.6 + Podbots and CZ + CS bots. Here the small plugin used to test : http://pastebin.com/UkpxHJzd
Thanks, let me just point out a small thing you missed. When checking whether it's a CZ Bot you also need to check that their deadflag is still set to DEAD_RESPAWNABLE: (this makes sure it's a bot that definitely hasn't respawned yet) if (is_user_bot(id) && pev(id, pev_deadflag) == DEAD_RESPAWNABLE) dllfunc(DLLFunc_Spawn, id) So the code for the fix should be: + if (((pPlayer->v.flags & FL_FAKECLIENT) == FL_FAKECLIENT) || (auth && (strcmp(auth, "BOT") == 0))) && (pPlayer->v.deadflag == DEAD_RESPAWNABLE) { + MDLL_Spawn(pPlayer);
The flag DEAD_RESPAWNABLE is set before, so this check is not needed.
Yes, the flag is set before. However after calling MDLL_Think(pPlayer), if the bot is successfully respawned, the flag is set to a different value (DEAD_NO). In that case, it means it wasn't a CZ Bot and we don't really need to call MDLL_Spawn(pPlayer). It's really not such a big deal. Calling MDLL_Spawn on a bot that is already alive is pretty much harmless (he would just appear to spawn twice). I'd figure if we are fixing this, better get it right though.
Ok, thanks for the information. I will try myself though, I would like to understand better and if I get the same behavior. Btw, I was wondering why Think() doesn't work on CZ bots, so I've tried to look into the CS code without real success. CBot:Killed() calls directly CBasePlayer::Killed() so SetThink( &CBasePlayer::PlayerDeathThink ) should be called well on CZ bots. Weird. Will try look further.
Comment on attachment 2479 [details] [review] Fix for cs_user_spawn Not tested?
Created attachment 2559 [details] [review] Corrected proposed path This patch adds the missing check as stated by wils. Compiled and tested successfully on CS1.6 (+podbots) and CS:CZ (+CS bots).
Going to pass on this for 1.8.2 - the patch honestly looks fine, but I'm pretty nervous about compatibility issues. We should take this as soon as we branch for 1.8.3.
What compatibility issues do you have in mind ? I think there is no problems about this one. No matter how people have used this native until now, the result will the same without the glitches. About the method itself, it's what uses CS when a player dies. It sounds like safe for me.
Comment on attachment 2559 [details] [review] Corrected proposed path Reviewed and checked again. The way it's used currently will not be an an issue after this patch. Also, honestly there is no more plugin using this old native because was buggy. Asking joropito's thoughts.
Comment on attachment 2559 [details] [review] Corrected proposed path Review of attachment 2559 [details] [review]: ----------------------------------------------------------------- I don't see any compatibility problem with this patch
Pushed changeset: http://hg.alliedmods.net/amxmodx-central/rev/97c16eba7134 Changelog: Fix cs_user_spawn to properly respawn players (bug 3752, r=dvander)
Commit pushed to master at https://github.com/alliedmodders/amxmodx https://github.com/alliedmodders/amxmodx/commit/f606adfa698ca724e5fd0dff37799b58f0663f82 Fix cs_user_spawn to properly respawn players (bug 3752, r=dvander) Former-commit-id: 3bae515741f59ca9679cbacc1f81dce6734fa67b