Fixed +playerclass not being respected when new players join a save
This commit is contained in:
parent
4cc5fe942d
commit
d6ead264ed
2 changed files with 21 additions and 2 deletions
|
|
@ -1867,6 +1867,9 @@ void Net_ReadGameInfo(TArrayView<uint8_t>& stream)
|
|||
Args->AppendArg(load);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset this immediately so any further RNG calls the engine has to make will be synced.
|
||||
FRandom::StaticClearRandom();
|
||||
}
|
||||
|
||||
// Connects players to each other if needed.
|
||||
|
|
|
|||
|
|
@ -549,6 +549,19 @@ static void InitPlayerClasses ()
|
|||
}
|
||||
}
|
||||
|
||||
// Account for additional players joining from a save file.
|
||||
static void UpdatePlayerClass(int i)
|
||||
{
|
||||
if (!savegamerestore || !playeringame[i])
|
||||
return;
|
||||
|
||||
SinglePlayerClass[i] = players[i].userinfo.GetPlayerClassNum();
|
||||
if (SinglePlayerClass[i] < 0)
|
||||
SinglePlayerClass[i] = (pr_classchoice()) % PlayerClasses.Size();
|
||||
players[i].cls = nullptr;
|
||||
players[i].CurrentPlayerClass = SinglePlayerClass[i];
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
@ -2018,7 +2031,7 @@ void G_WriteVisited(FSerializer &arc)
|
|||
}
|
||||
|
||||
// Store player classes to be used when spawning a random class
|
||||
if (multiplayer)
|
||||
if (!multiplayer || !deathmatch)
|
||||
{
|
||||
arc.Array("randomclasses", SinglePlayerClass, MAXPLAYERS);
|
||||
}
|
||||
|
|
@ -2102,7 +2115,10 @@ void G_ReadVisited(FSerializer &arc)
|
|||
for (unsigned int i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
FStringf key("%d", i);
|
||||
arc(key.GetChars(), players[i].cls);
|
||||
if (!arc.HasKey(key.GetChars()))
|
||||
UpdatePlayerClass(i);
|
||||
else
|
||||
arc(key.GetChars(), players[i].cls);
|
||||
}
|
||||
arc.EndObject();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue