Example #1
0
void GameManager::run()
{
    while (1)
    {
        auto action = _serv->getActions();
        if (action)
        {
            checkDeadClients();
            launchAction(*action);
        }
            auto it = _rooms.begin();
        while (it != _rooms.end())
        {
            if ((*it)->getNbPlayer() == (*it)->getMaxPlayer())
            {
                auto players = (*it)->getPlayers();
                std::string playerNames("");
                Packet packetRdy = Packet::build(READY, "");
                playerNames.append(players[0]->getName());
                playerNames += " ";
                for (unsigned int i=1; i<players.size(); ++i)
                {
                    reinterpret_cast<ASocket *>(players[i])->addData<Packet>(packetRdy, serPacket);
                    playerNames.append(players[i]->getName());
                    playerNames += " ";
                }
                Packet packet = Packet::build(DATAMAP, playerNames);
                reinterpret_cast<ASocket *>(players[0])->addData<Packet>(packet, serPacket);
                ++it;
            }
            else if ((*it)->getNbPlayer() == 0)
            {
                int port =(*it)->getPort();
                std::string roomName = (*it)->getName();
                it = removeRoom((*it)->getName());
                _pool.releaseThread(roomName);
                _ports[port] = false;
            }
            else
                ++it;
        }
        _serv->getCond()->wait();
    }
}
Example #2
0
bool TRoomDB::removeArea( int id )
{
    areaNamesMap.remove( id );
    if( areas.contains( id ) )
    {
        TArea * pA = areas[id];
        QList<int> rl;
        for( int i=0; i< pA->rooms.size(); i++ )
        {
            rl.push_back( pA->rooms[i] );
        }
        for( int i=0; i<rl.size(); i++ )
        {
            removeRoom( rl[i] );
        }
        areas.remove( id );

        mpMap->mMapGraphNeedsUpdate = true;
        return true;
    }
    return false;
}
    createBlankTiles();

    foreach (Room *r, rooms) {
        addRoom(r);
    }

    connect(ui->name, SIGNAL(textEdited(QString)),
            this, SLOT(floorNameChanged(QString)));
    connect(ui->z, SIGNAL(textEdited(QString)),
            this, SLOT(enableOkButton()));
    connect(ui->addRoom, SIGNAL(clicked()),
            this, SLOT(addRoom()));
    connect(ui->editRoom, SIGNAL(clicked()),
            this, SLOT(editRoom()));
    connect(ui->removeRoom, SIGNAL(clicked()),
            this, SLOT(removeRoom()));
}

FloorDialog::~FloorDialog()
{
    delete ui;
}

QString FloorDialog::floorName() const
{
    return ui->name->text();
}

void FloorDialog::addRoom(Room *r)
{
    int row = maxY - r->y + 1;