Пример #1
0
/*
========================
idLobby::GetMigrationGameDataUser
This will setup the passed in idBitMsg to either read or write from the user's migration game data buffer
========================
*/
bool idLobby::GetMigrationGameDataUser( lobbyUserID_t lobbyUserID, idBitMsg & msg, bool reading ) {
	const int userNum = GetLobbyUserIndexByID( lobbyUserID );

	if ( !verify( userNum >=0 && userNum < MAX_PLAYERS ) ) {
		return false;
	}

	lobbyUser_t * u = GetLobbyUser( userNum );
	if ( u != NULL ) {
		if ( reading ) {

			if ( !IsMigratedStatsGame() || !migrationInfo.persistUntilGameEndsData.wasMigratedHost ) {
				// This was not a migrated session, we have no migration data
				return false;
			}

			if ( u->migrationGameData >= 0 && u->migrationGameData < MAX_PLAYERS ) {
				msg.InitRead( migrationInfo.persistUntilGameEndsData.gameDataUser[ u->migrationGameData ], sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[ 0 ] ) );
			} else {
				// We don't have migration data for this user
				idLib::Warning( "No migration data for user %d in a migrated game (%d)", userNum, u->migrationGameData );
				return false;
			}
		} else {
			// Writing
			migrationInfo.persistUntilGameEndsData.hasGameData = true;
			u->migrationGameData = userNum;
			memset( migrationInfo.persistUntilGameEndsData.gameDataUser[ userNum ], 0, sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[0] ) );
			msg.InitWrite( migrationInfo.persistUntilGameEndsData.gameDataUser[ userNum ], sizeof( migrationInfo.persistUntilGameEndsData.gameDataUser[0] ) );
			
		}
		return true;
	}
	return false;
}
Пример #2
0
/*
========================
idLobby::GetMigrationGameData
This will setup the passed in idBitMsg to either read or write from the global migration game data buffer
========================
*/
bool idLobby::GetMigrationGameData( idBitMsg &msg, bool reading ) {
	if ( reading ) {
		if ( !IsMigratedStatsGame() || !migrationInfo.persistUntilGameEndsData.wasMigratedHost ) {
			// This was not a migrated session, we have no migration data
			return false;
		}
		msg.InitRead( migrationInfo.persistUntilGameEndsData.gameData, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
	} else {
		migrationInfo.persistUntilGameEndsData.hasGameData = true;
		memset( migrationInfo.persistUntilGameEndsData.gameData, 0, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
		msg.InitWrite( migrationInfo.persistUntilGameEndsData.gameData, sizeof( migrationInfo.persistUntilGameEndsData.gameData ) );
	}

	return true;
}