Bazaar developer reference

FSerialization::SyncPlayer()

Defined in
CvPlayer.cpp, line 89
Hook name
CivHooks::FSerialization_SyncPlayer

Hooks

static bool BeforeFSerialization_SyncPlayer();static void AfterFSerialization_SyncPlayer();static void ReplaceFSerialization_SyncPlayer(void (*original)());CivRegisterBefore<CivHooks::FSerialization_SyncPlayer>(host, &BeforeFSerialization_SyncPlayer);CivRegisterAfter<CivHooks::FSerialization_SyncPlayer>(host, &AfterFSerialization_SyncPlayer);CivRegisterReplace<CivHooks::FSerialization_SyncPlayer>(host, &ReplaceFSerialization_SyncPlayer);

Code

89void SyncPlayer()90{91	if(GC.getGame().isNetworkMultiPlayer())92	{93		PlayerTypes eAuthoritativePlayerID = GC.getGame().getActivePlayer();94		CvPlayer& authoritativePlayer = GET_PLAYER(eAuthoritativePlayerID);95		const FAutoArchive& archive = authoritativePlayer.getSyncArchive();96		if(archive.hasDeltas())97		{98			FMemoryStream ms;99			std::vector<std::pair<std::string, std::string> > callStacks;100			archive.saveDelta(ms, callStacks);101			gDLL->sendPlayerSyncCheck(eAuthoritativePlayerID, ms, callStacks);102		}103104		// host is authoritative for AI players105106		if(gDLL->IsHost())107		{108			for(int i = 0; i < MAX_PLAYERS; ++i)109			{110				CvPlayer& player = GET_PLAYER(static_cast<PlayerTypes>(i));111				if(!player.isHuman() && player.isAlive())112				{113					const FAutoArchive& aiArchive = player.getSyncArchive();114					FMemoryStream ms;115					std::vector<std::pair<std::string, std::string> > callStacks;116					aiArchive.saveDelta(ms, callStacks);117					gDLL->sendPlayerSyncCheck(static_cast<PlayerTypes>(i), ms, callStacks);118				}119			}120		}121	}122}

Calls

Called by