/* ======================== 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; }
/* ======================== idSnapShot::GetObjectMsgByIndex ======================== */ int idSnapShot::GetObjectMsgByIndex( int i, idBitMsg& msg, bool ignoreIfStale ) const { if( i < 0 || i >= objectStates.Num() ) { return -1; } objectState_t& state = *objectStates[i]; if( state.stale && ignoreIfStale ) { return -1; } msg.InitRead( state.buffer.Ptr(), state.buffer.Size() ); return state.objectNum; }
/* ======================== 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; }