Esempio n. 1
0
int    	import(t_root *root)
{
  if (!(root->History = getHistory(root->Env)) ||
      !(root->Aliases = getAliases(root->Env)))
    return (1);
  return (0);
}
Esempio n. 2
0
void Exchange_BitCurex::secondSlot()
{
    static int sendCounter=0;
    switch(sendCounter)
    {
    case 0:
        if(!isReplayPending(103))sendToApi(103,baseValues.currentPair.currBStrLow.toLatin1()+"/ticker",false);
        break;
    case 1:
        if(!isReplayPending(202))sendToApi(202,"balance/",true,"nonce="+QByteArray::number(++privateNonce));
        break;
    case 2:
        if(!isReplayPending(109))sendToApi(109,baseValues.currentPair.currBStrLow.toLatin1()+'/'+QByteArray::number(lastTradesDate)+"/trades",false);
        break;
    case 3:
        if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"offers/",true,"nonce="+QByteArray::number(++privateNonce));
        break;
    case 4:
        if(isDepthEnabled()&&(forceDepthLoad||!isReplayPending(111)))
        {
            emit depthRequested();
            sendToApi(111,baseValues.currentPair.currBStrLow.toLatin1()+"/"+baseValues.depthCountLimitStr+"/orderbook",false);
            forceDepthLoad=false;
        }
        break;
    case 5:
        if(lastHistory.isEmpty())getHistory(false);
        break;
    default: break;
    }
    if(sendCounter++>=5)sendCounter=0;

	Exchange::secondSlot();
}
static void SeamlessChannel_process_sync(void) {
	SeamlessWindow* sw = NULL;

	SeamlessChannel_sendSyncBegin();

	sw = getHistory();
	if (sw == NULL)
		goto end;

	while(sw){
		// Check window visibility
		if (! WindowUtil_isVisible(sw->windows)) {
			removeHWNDFromHistory(sw->windows);

			sw = sw->next;
			continue;
		}

		SeamlessWindow_synchronize(sw);

		sw = sw->next;
	}

	end: 
		SeamlessChannel_sendSyncEnd();
}
Esempio n. 4
0
// Get the most recent move of a given player
void lastMove(DracView currentView, PlayerID player,
             LocationID *start, LocationID *end) {

   LocationID trail[TRAIL_SIZE];
   getHistory(currentView->gv, player, trail);
   *end = trail[0];
   *start = trail[1];
}
Esempio n. 5
0
// Get the most recent move of a given player
// may need modification when Queue ADT is confirmed
void lastMove(DracView currentView, PlayerID player,
			  LocationID *start, LocationID *end) {
	LocationID *trail = malloc(sizeof(LocationID) * TRAIL_SIZE);
	getHistory(currentView->g, player, trail);
	*start = trail[1];
	*end = trail[0];
	free(trail);
}
Esempio n. 6
0
// Fills the trail array with the location ids of the last 6 turns
void giveMeTheTrail(HunterView currentView, PlayerID player,
                            LocationID trail[TRAIL_SIZE])
{
    assert(currentView != NULL);
    assert(0 <= player && player < NUM_PLAYERS);
    assert(trail != NULL);

    return getHistory(currentView->g, player, trail);
}
Esempio n. 7
0
static really_inline
void report_eod_matches(hs_stream_t *id, hs_scratch_t *scratch,
                        match_event_handler onEvent, void *context) {
    DEBUG_PRINTF("--- report eod matches at offset %llu\n", id->offset);
    assert(onEvent);

    const struct RoseEngine *rose = id->rose;
    char *state = getMultiState(id);

    if (getBroken(state)) {
        DEBUG_PRINTF("stream is broken, just freeing storage\n");
        return;
    }

    populateCoreInfo(scratch, rose, state, onEvent, context, NULL, 0,
                     getHistory(state, rose, id->offset),
                     getHistoryAmount(rose, id->offset), id->offset, 0);

    if (rose->somLocationCount) {
        loadSomFromStream(scratch, id->offset);
    }

    if (!id->offset) {
        if (rose->boundary.reportZeroEodOffset) {
            processReportList(rose, rose->boundary.reportZeroEodOffset, 0,
                              scratch);
        }
    } else {
        if (rose->boundary.reportEodOffset) {
            processReportList(rose, rose->boundary.reportEodOffset,
                              id->offset, scratch);
        }

        if (rose->requiresEodCheck) {
            switch (rose->runtimeImpl) {
            default:
            case ROSE_RUNTIME_PURE_LITERAL:
                assert(0);
            case ROSE_RUNTIME_FULL_ROSE:
                rawEodExec(id, scratch);
                break;
            case ROSE_RUNTIME_SINGLE_OUTFIX:
                soleOutfixEodExec(id, scratch);
                break;
            }
        }
    }

    if (rose->hasSom && !told_to_stop_matching(scratch)) {
        int halt = flushStoredSomMatches(scratch, ~0ULL);
        if (halt) {
            DEBUG_PRINTF("told to stop matching\n");
            scratch->core_info.broken = BROKEN_FROM_USER;
            DEBUG_PRINTF("broken = %hhd\n", scratch->core_info.broken);
        }
    }
}
/**
 * \brief Get the complete history
 *
 * The tracking history contains the information in both the guiding record
 * as well as all the tracking points.
 */
TrackingHistory	TrackingStore::get(long id) {
	GuidingRunTable	table(_database);
	TrackingHistory	history(table.byid(id));
	std::list<TrackingPointRecord>	track = getHistory(id);
	for (auto ptr = track.begin(); ptr != track.end(); ptr++) {
		history.points.push_back(*ptr);
	}
	return history;
}
string GameState::toString() const
{
    stringstream ss;
    ss<<"Board:\n"<< board.toString() << endl;
    ss<<"Cost so far:\n" << getCostSoFar() << endl;
    ss<<"Estimated work:\n" << getEstimatedCost() << endl;
    ss<<"Priority:\n" << getPriority() << endl;
    ss<<"History:\n" << getHistory() << endl;
    return ss.str();
}
Esempio n. 10
0
WebWidget* QtWebKitWebWidget::clone(ContentsWidget *parent)
{
	QtWebKitWebWidget *widget = new QtWebKitWebWidget(isPrivate(), parent);
	widget->setDefaultTextEncoding(getDefaultTextEncoding());
	widget->setQuickSearchEngine(m_searchEngine);
	widget->setUrl(getUrl());
	widget->setHistory(getHistory());
	widget->setZoom(getZoom());

	return widget;
}
Esempio n. 11
0
void Logbook::updateHistoryCounter(const QString &url) {
   QDEBUG_EXP("Logbook::addHistory()", "url: " << url);
   m_query.prepare(UPDATE_HISTORY_LCOUNT_SQL);
   m_query.bindValue(0, url);
   // Let's query!
   if ( !m_query.exec() ) {
      QWARNING_EXP("Logbook::addHistory()", "Query exec error: " << m_query.lastError().text() << " Query: " << m_query.lastQuery());
   } else {
      emit historyChanged( getHistory(url)->id );
   }
}
Esempio n. 12
0
void Server::incomingConnection(qintptr socketDescriptor)
{
    Client *client = new Client(socketDescriptor);
    clients->push_back(client);
    QObject::connect(client,SIGNAL(sendMessageToAll(QString)),this,SLOT(sendMessageToAll(QString)));
    QObject::connect(client,SIGNAL(showDialog(QString)),this,SLOT(onShowDialog(QString)));
    QObject::connect(client,SIGNAL(signalDisconnected(QString)),this,SLOT(onClientDisconnected(QString)));
    QObject::connect(client,SIGNAL(signalConnected(QString)),this,SLOT(onClientConnected(QString)));
    QObject::connect(client,SIGNAL(saveHistory(QString)),this,SLOT(onSaveHistory(QString)));
    QObject::connect(client,SIGNAL(getHistory()),this,SLOT(onGetHistory(Client*)));
    onGetHistory(client);
}
Esempio n. 13
0
static vi_key historyFilter( input_buffer *input, vi_key event )
{
    history_data    *h;

    if( input->h == NULL || input->h->curr == 0 ) {
        return( event );
    }
    h = input->h;
    switch( event ) {
    case VI_KEY( UP ):
        if( h->curr > 0 ) {
            input->curr_hist -= 1;
            if( input->curr_hist < 0 || input->curr_hist < h->curr - h->max ) {
                input->curr_hist = h->curr - 1;
            }
            getHistory( input );
        }
        break;
    case VI_KEY( DOWN ):
        if( h->curr > 0 ) {
            input->curr_hist += 1;
            if( input->curr_hist >= h->curr ) {
                input->curr_hist = h->curr - h->max;
                if( input->curr_hist < 0 ) {
                    input->curr_hist = 0;
                }
            }
            getHistory( input );
        }
        break;
    case VI_KEY( CTRL_TAB ):
    case VI_KEY( ALT_TAB ):
        doHistorySearch( input );
        break;
    default:
        return( event );
    }
    return( VI_KEY( NULL ) );

} /* historyFilter */
Esempio n. 14
0
void
TUIGame::play() {
    handleCommand("new");
    while (true) {
        // Print last move
        if (currentMove > 0) {
            Position prevPos(getPos());
            prevPos.unMakeMove(moveList[currentMove - 1], uiInfoList[currentMove - 1]);
            std::string moveStr= TextIO::moveToString(prevPos, moveList[currentMove - 1], false);
            if (haveDrawOffer())
                moveStr += " (offer draw)";
            std::cout << "Last move: " << prevPos.getFullMoveCounter()
                    << (prevPos.isWhiteMove() ? "." : "...")
                    << ' ' << moveStr << std::endl;
        }
        /*
        {
            std::stringstream ss;
            ss << "Hash: " << std::hex << std::setw(16) << std::setfill('0') << pos.zobristHash();
            std::cout << ss.str() << std::endl;
        }
        */
        {
            auto et = Evaluate::getEvalHashTables();
            Evaluate eval(*et);
            int evScore = eval.evalPos(getPos()) * (getPos().isWhiteMove() ? 1 : -1);
            std::stringstream ss;
            ss.precision(2);
            ss << std::fixed << "Eval: " << (evScore / 100.0);
            std::cout << ss.str() << std::endl;
        }

        // Check game state
        std::cout << TextIO::asciiBoard(getPos());
        std::string stateStr = getGameStateString();
        if (stateStr.length() > 0)
            std::cout << stateStr << std::endl;
        if (getGameState() != Game::ALIVE)
            activateHumanPlayer();

        // Get command from current player and act on it
        Player& pl = getPos().isWhiteMove() ? *whitePlayer : *blackPlayer;
        std::vector<Position> posList;
        getHistory(posList);
        std::string moveStr = pl.getCommand(getPos(), haveDrawOffer(), posList);
        if (moveStr == "quit")
            return;
        bool ok = processString(moveStr);
        if (!ok)
            std::cout << "Invalid move: " << moveStr << std::endl;
    }
}
Esempio n. 15
0
void Logbook::addHistory(const QString &title, const QString &url, const linkItemId &historyItemId) {
   QDEBUG_EXP("Logbook::addHistory()", "title: " << title << " url: " << url << " id: " << historyItemId);
   if ( historyItemId != LINK_ITEM_ID_UNDEFINED ) { // Update history
      QDEBUG_EXP("Logbook::addHistory()", "Provided Bookmark Id -> Updating");
      m_query.prepare(UPDATE_HISTORY_SQL_BY_ID);
      m_query.bindValue(0, url); m_query.bindValue(1, title); m_query.bindValue(2, historyItemId);
   } else { // Insert History, or Update
      if ( NULL != getHistory(url) ) { // Update, there is already this URL
         QDEBUG_EXP("Logbook::addHistory()", "Updating History");
         m_query.prepare(UPDATE_HISTORY_SQL_BY_URL);
         m_query.bindValue(0, title); m_query.bindValue(1, url);
      } else { // Insert, never stored this URL
         QDEBUG_EXP("Logbook::addHistory()", "Inserting History");
         m_query.prepare(INSERT_HISTORY_SQL);
         m_query.bindValue(0, url); m_query.bindValue(1, title);
      }
   }
   // Let's query!
   if ( !m_query.exec() ) {
      QWARNING_EXP("Logbook::addHistory()", "Query exec error: " << m_query.lastError().text() << " Query: " << m_query.lastQuery());
   } else {
      emit historyChanged( getHistory(url)->id );
   }
}
Esempio n. 16
0
void PediaMainForm::updateNavigationButtons()
{
    const LookupHistory& history=getHistory();

    bool enabled = history.hasPrevious();
    if (enabled)
        backButton_.setGraphics(backBitmap);
    else
        backButton_.setGraphics(backDisabledBitmap);
        
    enabled = history.hasNext();
    if (enabled)
        forwardButton_.setGraphics(forwardBitmap);
    else
        forwardButton_.setGraphics(forwardDisabledBitmap);
}
Esempio n. 17
0
void PediaMainForm::setDisplayMode(PediaMainForm::DisplayMode mode) 
{
    
    switch (mode) 
    {
        case showAbout:
            articleRenderer_.hide();
            prepareAbout();
            infoRenderer_.show();
            break;
            
        case showArticle: 
        {
            infoRenderer_.hide();
            const LookupHistory& history = getHistory();
            if (history.hasCurrentTerm())
                setTitle(history.currentTerm().c_str());
            else
                setTitle("iPedia");
            articleRenderer_.show();
            break;
        }
        
        case showRegister:
            articleRenderer_.hide();
            prepareHowToRegister();
            infoRenderer_.show();
            break;
            
        case showTutorial:
            articleRenderer_.hide();
            prepareTutorial();
            infoRenderer_.show();
            break;
            
        case showWikipedia:
            articleRenderer_.hide();
            prepareWikipedia();
            infoRenderer_.show();
            break;
 
        default:
            assert(false);          
    }
    displayMode_ = mode;

}
Esempio n. 18
0
VWallSession::VWallSession(const QString& id, VAccount* account): Conference(account), d_ptr(new VWallSessionPrivate)
{
    Q_D(VWallSession);
    d->q_ptr = this;
    d->id = id;
    d->me = account->getContact(account->uid(),true);
    d->me->setContactName(account->name());
    d->owner = d->account()->getContact(d->id,true);
    d->historyCount = 10;

    MessageList list = History().read(this,1);
    if (list.count())
        d->timeStamp = list.first().time().toTime_t();
    d->updateTimer.setInterval(5000);

    connect(&d->updateTimer,SIGNAL(timeout()),d,SLOT(getHistory()));
    connect(d->owner,SIGNAL(destroyed()),SLOT(deleteLater()));
}
void Exchange_BitMarket::secondSlot()
{
    static int sendCounter=0;
    switch(sendCounter)
    {
    case 0:
        if(!isReplayPending(103))sendToApi(103,"ticker.json",false,true);
        break;
    case 1:
        if(!isReplayPending(202))sendToApi(202,"info",true,true);
        break;
    case 2:
        if(!isReplayPending(109))sendToApi(109,"trades.json?since="+lastTradesTid,false,true);
        break;
    case 3:
        if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"orders&market="+baseValues.currentPair.symbol.toLatin1(),true,true);
        break;
    case 4:
        if(isDepthEnabled()&&(forceDepthLoad||!isReplayPending(111)))
        {
            emit depthRequested();
            sendToApi(111,"orderbook.json",false,true);
            forceDepthLoad=false;
        }
        break;
    case 5:
        if(lastHistory.isEmpty())getHistory(false);
        break;
    default: break;
    }
    if(sendCounter++>=5)sendCounter=0;

    static int nonceCounter=0;
    if(++nonceCounter>9)
	{
        nonceCounter=0;
        quint32 syncNonce=(TimeSync::getTimeT()-1371854884)*10;
		if(privateNonce<syncNonce)privateNonce=syncNonce;
	}
	Exchange::secondSlot();
}
Esempio n. 20
0
// Fills the trail array with the location ids of the last 6 turns
void giveMeTheTrail(DracView currentView, PlayerID player,
					LocationID trail[TRAIL_SIZE]) {
	getHistory(currentView->g, player, trail);
}
bool CK2Title::hasHolders() const
{
	return ((getHolder() != NULL) || !getHistory().empty());
}
Esempio n. 22
0
 void CMessageBrokerControllerPhone::processRequest(Json::Value& root)
 {
    DBG_MSG(("CMessageBrokerControllerPhone::processRequest()\n"));
    if (getControllersName() == getDestinationComponentName(root))
    {
       Json::Value response;
       response["jsonrpc"] = root["jsonrpc"];
       response["id"] = root["id"];
       if ("makeCall" == getMethodName(root))
       {
          if (root.isMember("params"))
          {
             Json::Value params = root["params"];
             if (params.isMember("phoneNumber") && params["phoneNumber"].isString())
             {
                makeCall(params["phoneNumber"].asString(), response);
             } else
             {
                DBG_MSG_ERROR(("Wrong params!\n"));
                prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Wrong params!", response);
             }
          } else
          {
             DBG_MSG_ERROR(("Not possible to parse phone number!\n"));
             prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Not possible to parse phone number!", response);
          }
       } else if ("endCall" == getMethodName(root))
       {
          endCall(root["params"].asString(), response);
       } else if ("holdCall" == getMethodName(root))
       {
          holdCall(root["params"].asString(), response);
       } else if ("getContacts" == getMethodName(root))
       {
          if (root.isMember("params"))
          {
             Json::Value params = root["params"];
             if (params.isMember("firstLetter") && params["firstLetter"].isString()
              && params.isMember("offset") && params["offset"].isInt()
              && params.isMember("numberOfItems") && params["numberOfItems"].isInt())
             {
                getContacts(params["firstLetter"].asString(), params["offset"].asInt(), params["numberOfItems"].asInt(), response);
             } else
             {
                DBG_MSG_ERROR(("Wrong params of getContacts()!\n"));
                prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Wrong params of getContacts()!", response);
             }
          } else
          {
             DBG_MSG_ERROR(("Params is not an object!\n"));
             prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Params is not an object!", response);
          }
       } else if ("getHistory" == getMethodName(root))
       {
          if (root.isMember("params"))
          {
             Json::Value params = root["params"];
             if (params.isMember("typeOfContacts") && params["typeOfContacts"].isString()
              && params.isMember("offset") && params["offset"].isInt()
              && params.isMember("numberOfItems") && params["numberOfItems"].isInt())
             {
                getHistory(params["typeOfContacts"].asString(), params["offset"].asInt(), params["numberOfItems"].asInt(), response);
             } else
             {
                DBG_MSG_ERROR(("Wrong params of getHistory()!\n"));
                prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Wrong params of getHistory()!", response);
             }
          } else
          {
             DBG_MSG_ERROR(("Params is not an object!\n"));
             prepareErrorMessage(NsMessageBroker::INVALID_PARAMS, "Params is not an object!", response);
          }
       } else
       {
          DBG_MSG_ERROR(("Method has not been found!\n"));
          Json::Value err;
          err["code"] = NsMessageBroker::INVALID_REQUEST;
          err["message"] = "Method has not been found.";
          response["error"] = err;
       }
       sendJsonMessage(response);
    } else
    {
       DBG_MSG_ERROR(("Wrong message destination!\n"));
    }
 }
Esempio n. 23
0
static inline
hs_error_t hs_scan_stream_internal(hs_stream_t *id, const char *data,
                                   unsigned length, UNUSED unsigned flags,
                                   hs_scratch_t *scratch,
                                   match_event_handler onEvent, void *context) {
    if (unlikely(!id || !scratch || !data || !validScratch(id->rose, scratch))) {
        return HS_INVALID;
    }

    const struct RoseEngine *rose = id->rose;
    char *state = getMultiState(id);

    u8 broken = getBroken(state);
    if (broken) {
        DEBUG_PRINTF("stream is broken, halting scan\n");
        if (broken == BROKEN_FROM_USER) {
            return HS_SCAN_TERMINATED;
        } else {
            assert(broken == BROKEN_EXHAUSTED);
            return HS_SUCCESS;
        }
    }

    // We avoid doing any work if the user has given us zero bytes of data to
    // scan. Arguably we should define some semantics for how we treat vacuous
    // cases here.
    if (unlikely(length == 0)) {
        DEBUG_PRINTF("zero length block\n");
        assert(getBroken(state) != BROKEN_FROM_USER);
        return HS_SUCCESS;
    }

    u32 historyAmount = getHistoryAmount(rose, id->offset);
    populateCoreInfo(scratch, rose, state, onEvent, context, data, length,
                     getHistory(state, rose, id->offset), historyAmount,
                     id->offset, flags);
    assert(scratch->core_info.hlen <= id->offset
           && scratch->core_info.hlen <= rose->historyRequired);

    prefetch_data(data, length);

    if (rose->somLocationCount) {
        loadSomFromStream(scratch, id->offset);
    }

    if (!id->offset && rose->boundary.reportZeroOffset) {
        DEBUG_PRINTF("zero reports\n");
        processReportList(rose, rose->boundary.reportZeroOffset, 0, scratch);
    }

    switch (rose->runtimeImpl) {
    default:
        assert(0);
    case ROSE_RUNTIME_FULL_ROSE:
        rawStreamExec(id, scratch);
        break;
    case ROSE_RUNTIME_PURE_LITERAL:
        pureLiteralStreamExec(id, scratch);
        break;
    case ROSE_RUNTIME_SINGLE_OUTFIX:
        soleOutfixStreamExec(id, scratch);
    }

    if (rose->hasSom && !told_to_stop_matching(scratch)) {
        int halt = flushStoredSomMatches(scratch, ~0ULL);
        if (halt) {
            setBroken(state, BROKEN_FROM_USER);
            scratch->core_info.broken = BROKEN_FROM_USER;
        }
    }

    if (likely(!can_stop_matching(scratch))) {
        maintainHistoryBuffer(id->rose, getMultiState(id), data, length);
        id->offset += length; /* maintain offset */

        if (rose->somLocationCount) {
            storeSomToStream(scratch, id->offset);
        }
    } else if (told_to_stop_matching(scratch)) {
        return HS_SCAN_TERMINATED;
    } else { /* exhausted */
        setBroken(state, BROKEN_EXHAUSTED);
    }

    return HS_SUCCESS;
}
Esempio n. 24
0
int main()
{
    int i;
    GameView gv;

    printf("Test basic empty initialisation\n");
    PlayerMessage messages1[] = {};
    gv = newGameView("", messages1);
    assert(getCurrentPlayer(gv) == PLAYER_LORD_GODALMING);
    assert(getRound(gv) == 0);
    assert(getHealth(gv,PLAYER_DR_SEWARD) == GAME_START_HUNTER_LIFE_POINTS);
    assert(getHealth(gv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS);
    assert(getScore(gv) == GAME_START_SCORE);
    assert(getLocation(gv,PLAYER_LORD_GODALMING) == UNKNOWN_LOCATION);
    printf("passed\n");
    disposeGameView(gv);

    printf("Test for Dracula trail and basic functions\n");
    PlayerMessage messages2[] = {"Hello","Rubbish","Stuff","","Mwahahah"};
    gv = newGameView("GST.... SAO.... HZU.... MBB.... DC?....", messages2);
    assert(getCurrentPlayer(gv) == PLAYER_LORD_GODALMING);
    assert(getRound(gv) == 1);
    assert(getLocation(gv,PLAYER_LORD_GODALMING) == STRASBOURG);
    assert(getLocation(gv,PLAYER_DR_SEWARD) == ATLANTIC_OCEAN);
    assert(getLocation(gv,PLAYER_VAN_HELSING) == ZURICH);
    assert(getLocation(gv,PLAYER_MINA_HARKER) == BAY_OF_BISCAY);
    assert(getLocation(gv,PLAYER_DRACULA) == CITY_UNKNOWN);
    assert(getHealth(gv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS);
    printf("passed\n");
    disposeGameView(gv);

    printf("Test for encountering Dracula and hunter history\n");
    PlayerMessage messages3[] = {"Hello","Rubbish","Stuff","","Mwahahah","Aha!"};
    gv = newGameView("GST.... SAO.... HCD.... MAO.... DGE.... GGED...", messages3);
    assert(getLocation(gv,PLAYER_DRACULA) == GENEVA);
    assert(getHealth(gv,PLAYER_LORD_GODALMING) == 5);
    assert(getHealth(gv,PLAYER_DRACULA) == 30);
    assert(getLocation(gv,PLAYER_LORD_GODALMING) == GENEVA);
    LocationID history[TRAIL_SIZE];
    getHistory(gv,PLAYER_DRACULA,history);
    assert(history[0] == GENEVA);
    assert(history[1] == UNKNOWN_LOCATION);
    getHistory(gv,PLAYER_LORD_GODALMING,history);
    assert(history[0] == GENEVA);
    assert(history[1] == STRASBOURG);
    assert(history[2] == UNKNOWN_LOCATION);
    getHistory(gv,PLAYER_DR_SEWARD,history);
    assert(history[0] == ATLANTIC_OCEAN);
    assert(history[1] == UNKNOWN_LOCATION);
    printf("passed\n");
    disposeGameView(gv);

    printf("Test for Dracula doubling back at sea, and losing blood points (Hunter View)\n");
    PlayerMessage messages4[] = {"Hello","Rubbish","Stuff","","Mwahahah","Aha!","","","","Back I go"};
    gv = newGameView("GGE.... SGE.... HGE.... MGE.... DS?.... "
                     "GST.... SST.... HST.... MST.... DD1....", messages4);
    assert(getLocation(gv,PLAYER_DRACULA) == DOUBLE_BACK_1);
    getHistory(gv,PLAYER_DRACULA,history);
    assert(history[0] == DOUBLE_BACK_1);
    assert(history[1] == SEA_UNKNOWN);
    assert(getHealth(gv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS - 4);
    assert(getCurrentPlayer(gv) == 0);
    printf("passed\n");
    disposeGameView(gv);

    printf("Test for Dracula doubling back at sea, and losing blood points (Drac View)\n");
    PlayerMessage messages5[] = {"Hello","Rubbish","Stuff","","Mwahahah","Aha!","","","","Back I go"};
    gv = newGameView("GGE.... SGE.... HGE.... MGE.... DEC.... "
                     "GST.... SST.... HST.... MST.... DD1....", messages5);
    assert(getLocation(gv,PLAYER_DRACULA) == DOUBLE_BACK_1);
    getHistory(gv,PLAYER_DRACULA,history);
    assert(history[0] == DOUBLE_BACK_1);
    assert(history[1] == ENGLISH_CHANNEL);
    assert(getHealth(gv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS - 4);
    assert(getCurrentPlayer(gv) == 0);
    printf("passed\n");
    disposeGameView(gv);

    printf("Test for connections\n");
    int size, seen[NUM_MAP_LOCATIONS], *edges;
    gv = newGameView("", messages1);
    printf("Checking Galatz road connections\n");
    edges = connectedLocations(gv,&size,GALATZ,PLAYER_LORD_GODALMING,0,1,0,0);
    memset(seen, 0, NUM_MAP_LOCATIONS*sizeof(int));
    for (i = 0; i< size ; i++) seen[edges[i]] = 1;
    assert(size == 5);
    assert(seen[GALATZ]);
    assert(seen[CONSTANTA]);
    assert(seen[BUCHAREST]);
    assert(seen[KLAUSENBURG]);
    assert(seen[CASTLE_DRACULA]);
    free(edges);
    printf("Checking Ionian Sea sea connections\n");
    edges = connectedLocations(gv,&size,IONIAN_SEA,PLAYER_LORD_GODALMING,0,0,0,1);
    memset(seen, 0, NUM_MAP_LOCATIONS*sizeof(int));
    for (i = 0; i < size; i++) seen[edges[i]] = 1;
    assert(size == 7);
    assert(seen[IONIAN_SEA]);
    assert(seen[BLACK_SEA]);
    assert(seen[ADRIATIC_SEA]);
    assert(seen[TYRRHENIAN_SEA]);
    assert(seen[ATHENS]);
    assert(seen[VALONA]);
    assert(seen[SALONICA]);
    free(edges);
    printf("Checking Athens rail connections (none)\n");
    edges = connectedLocations(gv,&size,ATHENS,PLAYER_LORD_GODALMING,0,0,1,0);
    assert(size == 1);
    assert(edges[0] == ATHENS);
    free(edges);
    printf("passed\n");
    disposeGameView(gv);


    return 0;
}
void DisplayContestContact::processMinosStanza( const std::string &methodName, MinosTestImport * const mt )
{
   std::string updtg;

   int itemp;
   if ( mt->getStructArgMemberValue( "lseq", itemp ) )     // should already be done...
      logSequence = ( unsigned long ) itemp;
   mt->getStructArgMemberValueDTG( "uDTG", updtg );

   if ( methodName == "MinosLogComment" )
   {
      std::string ctime;
      mt->getStructArgMemberValueDTG( "logTime", ctime );
      time.setIsoDTG( ctime );

      bool btemp = false;
      unsigned short cf = contactFlags.getValue();
      if ( mt->getStructArgMemberValue( "LocalComment", btemp ) )
         mt->setBit( cf, LOCAL_COMMENT, btemp );
      if ( mt->getStructArgMemberValue( "dontPrint", btemp ) )
         mt->setBit( cf, DONT_PRINT, btemp );
      contactFlags.setInitialValue( cf );
      mt->getStructArgMemberValue( "comment", comments );

   }
   else
      if ( methodName == "MinosLogQSO" )
      {
         modificationCount++;

         updtime.setIsoDTG( updtg );

         std::string ctime;
         if ( mt->getStructArgMemberValueDTG( "logTime", ctime ) )
            time.setIsoDTG( ctime );

         unsigned short cf = contactFlags.getValue();
         bool btemp = false;
         if ( mt->getStructArgMemberValue( "validDistrict", btemp ) )
            mt->setBit( cf, VALID_DISTRICT, btemp );
         mt->setBit( cf, VALID_DISTRICT, btemp );
         if ( mt->getStructArgMemberValue( "countryForced", btemp ) )
            mt->setBit( cf, COUNTRY_FORCED, btemp );
         if ( mt->getStructArgMemberValue( "unknownCountry", btemp ) )
            mt->setBit( cf, UNKNOWN_COUNTRY, btemp );
         if ( mt->getStructArgMemberValue( "nonScoring", btemp ) )
            mt->setBit( cf, NON_SCORING, btemp );
         if ( mt->getStructArgMemberValue( "manualScore", btemp ) )
            mt->setBit( cf, MANUAL_SCORE, btemp );
         if ( mt->getStructArgMemberValue( "dontPrint", btemp ) )
            mt->setBit( cf, DONT_PRINT, btemp );
         if ( mt->getStructArgMemberValue( "validDuplicate", btemp ) )
            mt->setBit( cf, VALID_DUPLICATE, btemp );
         if ( mt->getStructArgMemberValue( "toBeEntered", btemp ) )
            mt->setBit( cf, TO_BE_ENTERED, btemp );
         if ( mt->getStructArgMemberValue( "xBand", btemp ) )
            mt->setBit( cf, XBAND, btemp );
         if ( mt->getStructArgMemberValue( "Forced", btemp ) )
            mt->setBit( cf, FORCE_LOG, btemp );

         contactFlags.setInitialValue( cf );

         mt->getStructArgMemberValue( "modeTx", mode );
         mt->getStructArgMemberValue( "rstTx", reps );
         mt->getStructArgMemberValue( "serialTx", serials );
         mt->getStructArgMemberValue( "exchangeTx", contest->location );
         mt->getStructArgMemberValue( "modeRx", mode );
         mt->getStructArgMemberValue( "callRx", cs.fullCall );
         mt->getStructArgMemberValue( "rstRx", repr );
         mt->getStructArgMemberValue( "serialRx", serialr );
         mt->getStructArgMemberValue( "exchangeRx", extraText );
         if ( mt->getStructArgMemberValue( "locRx", loc.loc ) )
            loc.validate();
         mt->getStructArgMemberValue( "commentsTx", comments );
         mt->getStructArgMemberValue( "commentsRx", comments );

         mt->getStructArgMemberValue( "power", contest->power );
         mt->getStructArgMemberValue( "band", contest->band );
         mt->getStructArgMemberValue( "claimedScore", contactScore );
         mt->getStructArgMemberValue( "forcedMult", forcedMult );

         mt->getStructArgMemberValue( "op1", op1 );
         mt->getStructArgMemberValue( "op2", op2 );

         int maxct = atoi( serials.getValue().c_str() );
         if ( maxct > contest->maxSerial )
            contest->maxSerial = maxct;

         contest->validationPoint = this;
         checkContact();                 // processMinosStanza - Do we need to? scanContest will repeat it. Except we push the contact in it's current state into history
         BaseContact bc( *this );   // this should get it now??
         getHistory().push_back( bc );
      }

}
Esempio n. 26
0
int GnuPGConnector::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: ready(); break;
        case 1: errorOccured(); break;
        case 2: gpgFinished((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: gpgError((*reinterpret_cast< QProcess::ProcessError(*)>(_a[1]))); break;
        case 4: { QString _r = encrypt((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 5: { QString _r = decrypt((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 6: { QString _r = showKeys();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 7: { QString _r = showSecretKeys();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 8: { QString _r = getData((*reinterpret_cast< bool(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 9: { QString _r = getFromClipboard();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 10: setToClipboard((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 11: { QString _r = getKey((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 12: { QString _r = getKey((*reinterpret_cast< int(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 13: { QString _r = getKeyByID((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 14: { QString _r = getPrivateKeyIDs((*reinterpret_cast< bool(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 15: { QString _r = getPrivateKeyIDs();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 16: { int _r = getNumOfPubKeys((*reinterpret_cast< int(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; }  break;
        case 17: { int _r = getNumOfPubKeys();
            if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; }  break;
        case 18: { bool _r = generateKeyPair((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])),(*reinterpret_cast< QString(*)>(_a[4])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 19: { bool _r = setOwnerTrust((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 20: { bool _r = checkGPGVersion((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 21: { QString _r = getGPGVersionString();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 22: { bool _r = importKeysFromFile((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 23: { bool _r = importKeysFromClipboard();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 24: { bool _r = searchKeysOnKeyserver((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 25: { bool _r = importKeysFromKeyserver((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 26: { bool _r = deleteKey((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 27: { bool _r = signKey((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 28: { bool _r = exportKeys((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 29: { QString _r = getHistory();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 30: { bool _r = saveHistory((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 31: settingsSetValue((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 32: { QString _r = settingsGetValue((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 33: settingsReset(); break;
        default: ;
        }
        _id -= 34;
    }
    return _id;
}
Esempio n. 27
0
// What are my (Dracula's) possible next moves (locations)
//
// * connectedLocations Conditions:
//
// connectedLocations() returns an array of LocationID that represent
//   all locations that are connected to the given LocationID.
// road, rail and sea are connections should only be considered
//   if the road, rail, sea parameters are TRUE.
// The size of the array is stored in the variable pointed to by numLocations
// The array can be in any order but must contain unique entries
// Your function must take into account the round and player id for rail travel
// Your function must take into account that Dracula can't move to
//   the hospital or travel by rail but need not take into account Dracula's trail
// The destination 'from' should be included in the array
//
// FREE THIS ARRAY IN THE AI
//
// This function only returns a list of locations where duckula can go
// This does not include HIDE or DOUBLE_BACK. Will need to account for
// this somewhere.. somehow
LocationID *whereCanIgo(DracView currentView, int *numLocations,
                        int road, int sea) {

// whereCanIgo() returns an array of LocationIDs giving
//   all locations that Dracula could reach in his next move
// road and/or sea connections should only be considered
//   if the road and/or sea parameters are TRUE.
// The size of the array is stored in the variable pointed to by numLocations
// The array can be in any order but must contain unique entries
// Should not include the hospital nor any locations only reachable by rail
// The current location should be included in the array
// The set of possible locations must be consistent with the rules on Dracula's
//   movement (e.g. can't MOVE to a location currently in his trail)

   LocationID *locations;
   LocationID trail[TRAIL_SIZE];
   LocationID myLocation;
   int i;
   int j;
   int rail;

   rail = 0;
   myLocation = whereIs(currentView, PLAYER_DRACULA);
   // printf("in DV.c; whereCanIGo: myLocation: %d (%s)\n", myLocation, idToAbbrev(myLocation));

   // printf("here0 connectedLocations(%p, %d, %d, %d, %d, %d, %d, %d)\n", currentView->gv, *numLocations, whereIs(currentView, PLAYER_DRACULA), PLAYER_DRACULA, giveMeTheRound(currentView), road, rail, sea);
//   fprintf(stderr,"from %d, round %d\n", whereIs(currentView,PLAYER_DRACULA),giveMeTheRound(currentView));

   locations = connectedLocations(currentView->gv, numLocations, 
                  myLocation, PLAYER_DRACULA, 
                  giveMeTheRound(currentView), road, rail, sea);

   //fprintf(stderr, "in DV.c: connLocs: \n");
   //for (i = 0; i < *numLocations; i++) {
   //   fprintf(stderr, "\tlocations[%d]: %d (%s)\n", i, locations[i], idToAbbrev(locations[i]));
   //}

   getHistory(currentView->gv, PLAYER_DRACULA, trail);

   // check locations aren't in the trail except for trail[0] (current location)
   for (i = 0; i < *numLocations; i++) {
      // printf("in DV.c: locations[%d] = %d (%s)\n", i, locations[i], idToAbbrev(locations[i]));
      for (j = 0; j < TRAIL_SIZE; j++) {
         
         if (locations[i] == myLocation && idToType(myLocation) == SEA) {
            // I'm currently at sea. Remove currently location
            locations[i] = -1;

            int h;

            // shuffle the locations one index to the 'left'
            for (h = i; h < *numLocations; h++) {
               if ((h+1) < *numLocations) {
                  locations[h] = locations[h+1];
               }
            }
            *numLocations -= 1;

         } else if (locations[i] == trail[j] && locations[i] != UNKNOWN_LOCATION && j != 0) {
            // this location is in the trail, remove it
            // printf("in DV.c: locations[%d] (%d : %s) == trail[%d] (%d : %s)\n", i, locations[i], idToAbbrev(locations[i]), j, trail[j], idToAbbrev(trail[j]));
            locations[i] = -1;
            // printf("\tupdated locations[%d] -> %d\n", i, locations[i]);

            int h;

            // shuffle the locations one index to the 'left'
            for (h = i; h < *numLocations; h++) {
               if ((h+1) < *numLocations) {
                  locations[h] = locations[h+1];
               }
            }

            *numLocations -= 1;
         }
      }
   }

   //fprintf(stderr, "new locs: \n");
   //for (i = 0; i < *numLocations; i++) {
   //       fprintf(stderr, "\tin DV.c: locations[%d] (%d : %s)\n", i, locations[i], idToAbbrev(locations[i]));
   //}

   return locations;
}
Esempio n. 28
0
static PyObject *
rps_enemyhistory(PyObject *self, PyObject *args)
{
    return getHistory(ENEMYHISTORY, args);
}
Esempio n. 29
0
// Fills the trail array with the location ids of the last 6 turns
void giveMeTheTrail(HunterView currentView, PlayerID player,
                            LocationID trail[TRAIL_SIZE])
{
    return getHistory(currentView->g, player, trail);
}
Esempio n. 30
0
// Find out what minions are placed at the specified location
void whatsThere(DracView currentView, LocationID where,
                   int *numTraps, int *numVamps) {
   
   DracView dv;
   int count;
   LocationID trail[TRAIL_SIZE] = { -1 };
   LocationID whereType;
   int index;
   int round;
   int trapSetRound;

   dv = currentView;
   count = 0;
   whereType = idToType(where);
   *numTraps = 0;
   *numVamps = 0;
   index = dv->pastPlaysIndex[PLAYER_DRACULA];
   round = getLastRound(dv, PLAYER_DRACULA);
   trapSetRound = -1;

   // printf("whatsThere: round is: %d, currRound: %d\n", round, getRound(dv->gv));

   /* 
    * 1. Get minions placed by Drac
    *       1a. Get Drac's trail
    *       1b. if city is in the trail: increment for any traps/vamps
    *
    * 2. If traps found: 
    *       2a. get each hunter's trail
    *       2b. check if city is in hunter's trail, AND if traps/vamps
    *             have been encountered
    *       2c. if traps/vamps have been encountered, decrement them
    */ 


   // 1. Get minions placed by Drac

   // 'where' restrictions:
   //    - not in the sea,
   //    - is a valid city number,
   //    - not the hospital

   if (whereType != SEA && validPlace(where) && 
                  where != ST_JOSEPH_AND_ST_MARYS) {

      // 1a.
      getHistory(dv->gv, PLAYER_DRACULA, trail);

      
      // 1b. Store the traps set by Drac within that city, if applicable

      // if 'where' is within the trail
      while (count < TRAIL_SIZE) {
         // Starting at the latest round, check if the city the user 
         // wants to check is in drac's trail. 
         // If so, increment if any traps or vamps are there and note
         // which round in which they were set by Drac

         if (trail[count] == where) {

            // index+3 and index+4: the indices where
            //             dracula's encounters will be stored

            if (dv->past[((round - count) * ROUND_LENGTH) + (index + MINION_ONE)] == 'T') {
               *numTraps += 1;
               //printf("yep0: loc[%c%c], round: %d, count: %d\n",dv->past[((round-count) * ROUND_LENGTH) + index+1], dv->past[((round-count) * ROUND_LENGTH) + index+2], round, count);
            } else if (dv->past[((round - count) * ROUND_LENGTH) + (index + MINION_ONE)] == 'V') {
               *numVamps += 1;
            }

            if (dv->past[((round - count) * ROUND_LENGTH) + (index + MINION_TWO)] == 'T') {
               *numTraps += 1;
            } else if (dv->past[((round - count) * ROUND_LENGTH) + (index + MINION_TWO)] == 'V') {
               *numVamps += 1;
            }

            // break out of the loop since 'where' can only be 
            // in the trail once
            trapSetRound = round - count;
            count = TRAIL_SIZE;
         }

         count += 1;
      }
   }

   //printf("found drac's: at %s, traps: %d, vamps: %d\n", idToName(where), *numTraps, *numVamps);


   // 2. If traps found

   // Traps have been found at the given city.
   // Check to see if any hunters have visited that city since,
   // hence encountering and disabling that trap/vamp
   if (trapSetRound != -1 && *numTraps > 0 && *numVamps > 0) {
      int hunter;
      int index;

      hunter = 0;

      // go through all hunter's (NUM_PLAYERS-1) trails**
      // if a hunter has visited the 'where' city, and has
      // encountered a trap/vamp, then decrement trap/vamp
      //
      // **since drac's and hunter's giveMeTheTrails are out of sync,
      // go through the pastPlays string
      // Will need to do that anyway because we need to check the string
      // for T&V encounters
      while (hunter < NUM_PLAYERS-1) {
         index = dv->pastPlaysIndex[hunter];
         round = getLastRound(dv, hunter);
         

         for (count = 0; count < TRAIL_SIZE; count++) {
            if (getRoundLocation(dv, round, hunter) == where) {
               if (dv->past[(round * ROUND_LENGTH) + (index + MINION_ONE)] == 'T') {
                  *numTraps -= 1;
               } else if (dv->past[(round * ROUND_LENGTH) + (index + MINION_ONE)] == 'V') {
                  *numTraps -= 1;
               }

               if (dv->past[(round * ROUND_LENGTH) + (index + MINION_TWO)] == 'T') {
                  *numTraps -= 1;
               } else if (dv->past[(round * ROUND_LENGTH) + (index + MINION_TWO)] == 'V') {
                  *numTraps -= 1;
               }
            }

            round -= 1;
         }
         
         hunter += 1;
      }
   }

   // printf("where: %s (%d), numTraps: %d, numVamps: %d\n", idToName(where), where, *numTraps, *numVamps);
}