mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- fixed: The savegame code for player restoration did some undefined things with the userinfo that only worked due to previous memory leaks. It must ensure that the userinfos get properly transferred and not implicitly rely on the copy assignment being used to copy the actual player data.
This commit is contained in:
parent
a59a886f94
commit
0c86650db0
2 changed files with 14 additions and 4 deletions
|
@ -256,11 +256,20 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
|
|||
{
|
||||
// The userinfo needs to be saved for real players, but it
|
||||
// needs to come from the save for bots.
|
||||
userinfo_t uibackup = dst->userinfo;
|
||||
userinfo_t uibackup;
|
||||
userinfo_t uibackup2;
|
||||
|
||||
uibackup.TransferFrom(dst->userinfo);
|
||||
uibackup2.TransferFrom(src->userinfo);
|
||||
|
||||
int chasecam = dst->cheats & CF_CHASECAM; // Remember the chasecam setting
|
||||
bool attackdown = dst->attackdown;
|
||||
bool usedown = dst->usedown;
|
||||
*dst = *src;
|
||||
|
||||
|
||||
dst->~player_t(); // ensure that the userinfo in dst does not contain anything before copying everything over.
|
||||
*dst = *src; // To avoid memory leaks at this point the userinfo in src must be empty which is taken care of by the TransferFrom call above.
|
||||
|
||||
dst->cheats |= chasecam;
|
||||
|
||||
if (dst->isbot)
|
||||
|
@ -276,10 +285,11 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
|
|||
}
|
||||
bglobal.botnum++;
|
||||
bglobal.botingame[dst - players] = true;
|
||||
dst->userinfo.TransferFrom(uibackup2);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst->userinfo = uibackup;
|
||||
dst->userinfo.TransferFrom(uibackup);
|
||||
}
|
||||
// Validate the skin
|
||||
dst->userinfo.SkinNumChanged(R_FindSkin(skins[dst->userinfo.GetSkin()].name, dst->CurrentPlayerClass));
|
||||
|
|
|
@ -653,7 +653,7 @@ void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass,
|
|||
// If DAMAGE_IN_AIR is used, anything not beneath the 3D floor will be
|
||||
// damaged (so, anything touching it or above it). Other 3D floors between
|
||||
// the actor and this one will not stop this effect.
|
||||
if ((flags & DAMAGE_IN_AIR) || actor->z <= z2))
|
||||
if ((flags & DAMAGE_IN_AIR) || actor->z <= z2)
|
||||
{
|
||||
// Here we pass the DAMAGE_IN_AIR flag to disable the floor check, since it
|
||||
// only works with the real sector's floor. We did the appropriate height checks
|
||||
|
|
Loading…
Reference in a new issue