Exemplo n.º 1
0
String WebInspectorServer::inspectorUrlForPageID(int pageId)
{
    if (pageId <= 0 || serverState() == Closed)
        return String();
    StringBuilder builder;
    builder.appendLiteral("http://");
    builder.append(bindAddress());
    builder.append(':');
    builder.appendNumber(port());
    builder.append(remoteInspectorPagePath());
    builder.appendNumber(pageId);
    return builder.toString();
}
Exemplo n.º 2
0
//response [0] - function [1-5] - parameters
std::array<int, BUFFER_SIZE> Lobby::parse_request(std::array<int, BUFFER_SIZE> &request) {
    std::array<int, BUFFER_SIZE> response = std::array<int, BUFFER_SIZE>();
    switch (request[0]) {
        case SERVER_STATE:
            response[0] = serverState();
            break;
        case IS_LOCKED:
            response[0] = isLocked(request[1]);
            break;
        case REGISTER:
            response[0] = registerPlayer(request[1]);
            response[1] = lobby_id;
            break;
        case MAKESTEP:
            response[0] = makeStep(request[1], Step(request[2], request[3], request[4]));
            break;
        case GETSTEP: {
            Step tmp = getStep(request[1]);
            response[0] = tmp.X;
            response[1] = tmp.Y;
            response[2] = tmp.team;
        }
            break;
        case PASSSTEP:
            response[0] = passStep(request[1]);
            break;
        case GET_GAMEOVER:
            state = GAMEOVER;
            response[0] = true;
            break;
        default:
            std::cout << "error happended" << std::endl;
    }

    return response;
}
ServerWindow::ServerWindow(QWidget* parent)
    :QWidget(parent)
{
    setWindowTitle("Qt TasServer Ui");

    monitor = new ServerMonitor();

    statusButton = new QPushButton("Check status");
    stopButton = new QPushButton("Stop");
    startButton = new QPushButton("Start");
    resetButton =  new QPushButton ("Reset server");
    loadPluginsButton = new QPushButton("Load Plugins");
#ifdef Q_OS_SYMBIAN
    pluginButton = new QPushButton ("Enable tas");    
    autoStart = new QCheckBox("Autostart"); 
    autoStart->setTristate(false);
    if(monitor->autostartState()){
        autoStart->setCheckState(Qt::Checked);
    }
    connect(autoStart, SIGNAL(toggled(bool)), monitor, SLOT(setAutoStart(bool)));
#endif

    QLabel* stateLabel = new QLabel("Server state:");
    QLabel* versionLabel = new QLabel("Server version:");   
    QLabel* stateValue = new QLabel("Unknown");
    QLabel* versionValue = new QLabel(TAS_VERSION);


    QLabel* hostBindingLabel =  new QLabel("Server Address Binding:");
    anyBindRadioButton = new QRadioButton("Any");
    localBindRadioButton = new QRadioButton("Localhost");
    anyBindRadioButton->setDisabled(true);
    localBindRadioButton->setDisabled(true);

    connect(monitor, SIGNAL(serverState(const QString&)), stateValue, SLOT(setText(const QString&)));
    connect(monitor, SIGNAL(beginMonitor()), this, SLOT(disableButtons()));
    connect(monitor, SIGNAL(stopMonitor()), this, SLOT(enableButtons()));
    connect(monitor, SIGNAL(disableReBinding()), this, SLOT(disableRadioButtons()));
    connect(monitor, SIGNAL(enableReBinding(const QString&)), this, SLOT(enableRadioButtons(const QString&)));

    QTextEdit* editField = new QTextEdit();
    editField->setReadOnly(true);
    connect(monitor, SIGNAL(serverDebug(const QString&)), editField, SLOT(append(const QString&)));

    connect(startButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(stopButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(resetButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(statusButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(loadPluginsButton, SIGNAL(clicked()), editField, SLOT(clear()));


    connect(anyBindRadioButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(localBindRadioButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(anyBindRadioButton, SIGNAL(clicked()), monitor, SLOT(setAnyBinding()));
    connect(localBindRadioButton, SIGNAL(clicked()), monitor, SLOT(setLocalBinding()));


#ifdef Q_OS_SYMBIAN
    connect(pluginButton, SIGNAL(clicked()), editField, SLOT(clear()));
    connect(pluginButton, SIGNAL(clicked()), monitor, SLOT(enablePluginLoad()));
#endif

    connect(statusButton, SIGNAL(clicked()), monitor, SLOT(serverState()));    
    connect(stopButton, SIGNAL(clicked()), monitor, SLOT(stopServer()));
    connect(startButton, SIGNAL(clicked()), monitor, SLOT(startServer()));
    connect(resetButton, SIGNAL(clicked()), monitor, SLOT(restartServer()));    
    connect(loadPluginsButton, SIGNAL(clicked()),monitor, SLOT(loadPlugins()));

    QPushButton* quitButton = new QPushButton("Quit");
    connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));

    QGridLayout* mainLayout = new QGridLayout();
    mainLayout->addWidget(stateLabel, 0, 0, 1, 1);
    mainLayout->addWidget(stateValue, 0, 1, 1, 1);
    mainLayout->addWidget(versionLabel, 1, 0);
    mainLayout->addWidget(versionValue, 1, 1);

    // Server binding Radio
    mainLayout->addWidget(hostBindingLabel, 2, 0);
    mainLayout->addWidget(anyBindRadioButton, 2, 1);
    mainLayout->addWidget(localBindRadioButton, 3, 1);

    mainLayout->addWidget(editField, 4,0, 1, 2);
#ifdef Q_OS_SYMBIAN
    mainLayout->addWidget(statusButton, 5, 0);
    mainLayout->addWidget(pluginButton, 5, 1);
#else
    mainLayout->addWidget(statusButton, 5, 0);
    mainLayout->addWidget(loadPluginsButton, 5, 1);
#endif
    mainLayout->addWidget(stopButton, 6, 0);
    mainLayout->addWidget(startButton, 6, 1);
    mainLayout->addWidget(resetButton, 7, 0);
    mainLayout->addWidget(quitButton, 7, 1);
#ifdef Q_OS_SYMBIAN
    mainLayout->addWidget(autoStart, 8, 0);
    mainLayout->addWidget(loadPluginsButton, 8, 1);
#endif
    setLayout(mainLayout);     

//    QRect rect = qApp->desktop()->screenGeometry();    
//    if(rect.width() > 864)
//        setFixedSize(350,600);
//    else{
//        showFullScreen();    
//    }

}
Exemplo n.º 4
0
void ServerImpl::onCarState(
    CL_NetGameConnection *p_conn,
    const CL_NetGameEvent &p_event)
{
    // state check precision
    static const float PRECISSION = 0.5f;


    // register last car state
    Player &player = m_connections[p_conn];
    player.m_lastCarState.parseEvent(p_event);

    // player name may be not set by client
    player.m_lastCarState.setName(player.m_name);

    sendToAll(player.m_lastCarState.buildEvent(), p_conn);


    // validate client physics calculations
    // and kick player when his state differs from server one
    if (player.m_car->getIterationId() != -1) {

        try {
            CL_NetGameEvent serverState("");

            player.m_car->updateToIteration(
                player.m_lastCarState.getIterationId()
            );

            // compare server and client car position

            // this is position calculated by server
            const CL_Pointf servPos = player.m_car->getPosition();

            // apply client data and retrieve his position
            player.m_car->deserialize(
                player.m_lastCarState.getSerializedData()
            );
            const CL_Pointf &cliPos = player.m_car->getPosition();


            if (!player.m_lastCarState.isAfterCollision()) {
                if (
                    !Math::Float::cmp(servPos.x, cliPos.x, PRECISSION)
                    || !Math::Float::cmp(servPos.y, cliPos.y, PRECISSION)
                ) {
                    cl_log_event(
                        LOG_WARN,
                        CL_String("diff in client and server states:\n")
                        + "client x: %1  y: %2\nserver x: %3  y: %4",
                        cliPos.x, cliPos.y,
                        servPos.x, servPos.y
                    );

//					kick(p_conn, GR_CHEATING);
                }
            }

        } catch (CL_Exception &e) {
            // something went wrong while comparing states
            // this also may be a cheater doing
            cl_log_event(LOG_WARN, "%1", e.message);
//			kick(p_conn, GR_CHEATING);
        }

    } else {
        // this is first iteration, read data without checking it
        player.m_car->deserialize(player.m_lastCarState.getSerializedData());
    }

}