// // P_ArchivePlayers // void P_SerializePlayers (FArchive &arc, bool skipload) { BYTE numPlayers, numPlayersNow; int i; // Count the number of players present right now. for (numPlayersNow = 0, i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { ++numPlayersNow; } } if (arc.IsStoring()) { // Record the number of players in this save. arc << numPlayersNow; // Record each player's name, followed by their data. for (i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { arc.WriteString (players[i].userinfo.GetName()); players[i].Serialize (arc); } } } else { arc << numPlayers; // If there is only one player in the game, they go to the // first player present, no matter what their name. if (numPlayers == 1) { ReadOnePlayer (arc, skipload); } else { ReadMultiplePlayers (arc, numPlayers, numPlayersNow, skipload); } if (!skipload && numPlayersNow > numPlayers) { SpawnExtraPlayers (); } // Redo pitch limits, since the spawned player has them at 0. players[consoleplayer].SendPitchLimits(); } }
void P_SerializePlayers(FSerializer &arc, bool skipload) { int numPlayers, numPlayersNow; int i; // Count the number of players present right now. for (numPlayersNow = 0, i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { ++numPlayersNow; } } if (arc.isWriting()) { // Record the number of players in this save. arc("numplayers", numPlayersNow); if (arc.BeginArray("players")) { // Record each player's name, followed by their data. for (i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { if (arc.BeginObject(nullptr)) { const char *n = players[i].userinfo.GetName(); arc.StringPtr("playername", n); players[i].Serialize(arc); arc.EndObject(); } } } arc.EndArray(); } } else { arc("numplayers", numPlayers); if (arc.BeginArray("players")) { // If there is only one player in the game, they go to the // first player present, no matter what their name. if (numPlayers == 1) { ReadOnePlayer(arc, skipload); } else { ReadMultiplePlayers(arc, numPlayers, numPlayersNow, skipload); } arc.EndArray(); } if (!skipload && numPlayersNow > numPlayers) { SpawnExtraPlayers(); } // Redo pitch limits, since the spawned player has them at 0. players[consoleplayer].SendPitchLimits(); } }