Exemple #1
0
void Mud::removeInactivePlayers()
{
    PlayerList toRemove = PlayerList();
    for (auto iterator : mudPlayers)
    {
        // Proceed only if the player is not connected and is closing.
        if (!iterator->checkConnection() || iterator->closing)
        {
            // Add the player to the list of players that have to be removed.
            toRemove.insert(iterator);
        }
    }
    for (auto iterator = toRemove.begin(); iterator != toRemove.end(); ++iterator)
    {
        // Get the player at the given position.
        Player * player = *iterator;
        // Log the action of removing.
        Logger::log(LogLevel::Global, "Removing inactive player : " + player->getName());
        // Only if the player has successfully logged in, save its state on DB.
        if (player->logged_in)
        {
            SQLiteDbms::instance().beginTransaction();
            player->updateOnDB();
            SQLiteDbms::instance().endTransaction();
        }
        // Remove the player from the list of players.
        remPlayer(player);
        // Delete the player.
        delete (player);
    }
}
Exemple #2
0
/** Should be used only during serializing/deserializing
 */
SwissGroup::SwissGroup()
: Group( QString( "" ), 2, PlayerList() ),
  _fromPlace( 0 )
{
}