本文整理汇总了C++中idBitMsg::InitWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ idBitMsg::InitWrite方法的具体用法?C++ idBitMsg::InitWrite怎么用?C++ idBitMsg::InitWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idBitMsg
的用法示例。
在下文中一共展示了idBitMsg::InitWrite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMigrationGameDataUser
/*
========================
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: GetMigrationGameData
/*
========================
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;
}