- 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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue