コード例 #1
0
void TabReplays::keepRemoteReplayFinished(const Response &r, const CommandContainer &commandContainer)
{
    if (r.response_code() != Response::RespOk)
        return;
    
    const Command_ReplayModifyMatch &cmd = commandContainer.session_command(0).GetExtension(Command_ReplayModifyMatch::ext);
    
    ServerInfo_ReplayMatch temp;
    temp.set_do_not_hide(cmd.do_not_hide());
                    
    serverDirView->updateMatchInfo(cmd.game_id(), temp);
}
コード例 #2
0
Response::ResponseCode ServerSocketInterface::cmdReplayList(const Command_ReplayList & /*cmd*/, ResponseContainer &rc)
{
    if (authState != PasswordRight)
        return Response::RespFunctionNotAllowed;

    Response_ReplayList *re = new Response_ReplayList;

    QSqlQuery query1(sqlInterface->getDatabase());
    query1.prepare("select a.id_game, a.replay_name, b.room_name, b.time_started, b.time_finished, b.descr, a.do_not_hide from cockatrice_replays_access a left join cockatrice_games b on b.id = a.id_game where a.id_player = :id_player and (a.do_not_hide = 1 or date_add(b.time_started, interval 7 day) > now())");
    query1.bindValue(":id_player", userInfo->id());
    sqlInterface->execSqlQuery(query1);
    while (query1.next()) {
        ServerInfo_ReplayMatch *matchInfo = re->add_match_list();

        const int gameId = query1.value(0).toInt();
        matchInfo->set_game_id(gameId);
        matchInfo->set_room_name(query1.value(2).toString().toStdString());
        const int timeStarted = query1.value(3).toDateTime().toTime_t();
        const int timeFinished = query1.value(4).toDateTime().toTime_t();
        matchInfo->set_time_started(timeStarted);
        matchInfo->set_length(timeFinished - timeStarted);
        matchInfo->set_game_name(query1.value(5).toString().toStdString());
        const QString replayName = query1.value(1).toString();
        matchInfo->set_do_not_hide(query1.value(6).toBool());

        {
            QSqlQuery query2(sqlInterface->getDatabase());
            query2.prepare("select player_name from cockatrice_games_players where id_game = :id_game");
            query2.bindValue(":id_game", gameId);
            sqlInterface->execSqlQuery(query2);
            while (query2.next())
                matchInfo->add_player_names(query2.value(0).toString().toStdString());
        }
        {
            QSqlQuery query3(sqlInterface->getDatabase());
            query3.prepare("select id, duration from " + servatrice->getDbPrefix() + "_replays where id_game = :id_game");
            query3.bindValue(":id_game", gameId);
            sqlInterface->execSqlQuery(query3);
            while (query3.next()) {
                ServerInfo_Replay *replayInfo = matchInfo->add_replay_list();
                replayInfo->set_replay_id(query3.value(0).toInt());
                replayInfo->set_replay_name(replayName.toStdString());
                replayInfo->set_duration(query3.value(1).toInt());
            }
        }
    }

    rc.setResponseExtension(re);
    return Response::RespOk;
}
コード例 #3
0
RemoteReplayList_TreeModel::MatchNode::MatchNode(const ServerInfo_ReplayMatch &_matchInfo)
    : RemoteReplayList_TreeModel::Node(QString::fromStdString(_matchInfo.game_name())), matchInfo(_matchInfo)
{
    for (int i = 0; i < matchInfo.replay_list_size(); ++i)
        append(new ReplayNode(matchInfo.replay_list(i), this));
}