// receive coin Coin<FIELD> decrypt(const SecretAddr<FIELD>& secretAddr, const PublicAddr<FIELD>& publicAddr) const { DECRYPTOR DEC(secretAddr.cryptoKey()); RANDPOOL RNG; // recovered text length const std::size_t rtextLen = DEC.MaxPlaintextLength(m_cipherText.size()); if (rtextLen) { // recovered text bytes std::vector<byte> rtext(rtextLen, 0xfb); if (DEC.Decrypt(RNG, m_cipherText.data(), m_cipherText.size(), rtext.data()).isValidCoding) { // convert recovered text to stream std::stringstream ss(std::string(rtext.begin(), rtext.end())); Coin<FIELD> coin; if (coin.marshal_in(ss, false)) { // false means omit public address // set public address of recovered coin coin.addr(publicAddr); // must check: // 1. cm matches pour transaction cm (coin exists in ledger) // 2. serial number is not in ledger (not already spent) if (coin.valid()) return coin; } } } return Coin<FIELD>(); // failed }
ivocab() { static int direct, kword, mm, mark; if( (F3=fopen("advvocab","r")) == NULL ) fatal(); printf("vocabulary words :"); while(getlin()) { mark=line(1); if( mark=='m' ) { /* message */ rtext(mm)=putmes(); } else { if( mark=='d' ) { /* directional words */ direct=direct+1; kword=direct; } else if( mark=='s' ) { /* special words */ mm=ranm-mesimp; kword=mm+(specwr*1000); mesimp=mesimp+1; } else { printf("\n%s%.10s\n","неверный маркер: ",_line); fatal(); } p=4 /* read list of words */; while(getwrd()) { if( vocab(_word) >= 0 ) { printf("\n%s%.4s\n","дважды определено: ",_word); fatal(); } nvoc=nvoc+1; ktab(nvoc)=kword; atab(nvoc) = *rword; screen(nvoc); } } } printf("%8d %s %6d %s\n",nvoc,"of",vocw,"used"); fclose(F3); }
void TextEventDialog::slotTextChanged(const QString &qtext) { std::string type(getTextType()); QString qtrunc(qtext); if (qtrunc.length() > 20) qtrunc = qtrunc.left(20) + "..."; std::string text(qstrtostr(qtrunc)); if (text == "") text = "Sample"; Text rtext(text, type); m_textExampleLabel->setPixmap(m_notePixmapFactory->makeTextPixmap(rtext)); }
void MoveUnit(Unit* u) { UnitT* t = &g_utype[u->type]; u->prevpos = u->cmpos; u->collided = false; if(u->threadwait) return; if(Magnitude(u->goal - u->cmpos) <= t->cmspeed) return; if(u->underorder && u->target < 0 && Magnitude(u->goal - u->cmpos) <= PATHNODE_SIZE) return; if(u->path.size() <= 0 || *u->path.rbegin() != u->goal) { #if 1 if(t->military) { if(g_simframe - u->lastpath < u->pathdelay) { return; } //u->pathdelay += 1; //u->pathdelay *= 2; u->pathdelay += 10; u->lastpath = g_simframe; int nodesdist = Magnitude( u->goal - u->cmpos ) / PATHNODE_SIZE; #if 1 PartialPath(u->type, u->mode, u->cmpos.x, u->cmpos.y, u->target, u->target2, u->targtype, &u->path, &u->subgoal, u, NULL, NULL, u->goal.x, u->goal.y, u->goal.x, u->goal.y, u->goal.x, u->goal.y, nodesdist*10); //TILE_SIZE*4/PATHNODE_SIZE); #else JPSPartPath(u->type, u->mode, u->cmpos.x, u->cmpos.y, u->target, u->target2, u->targtype, &u->path, &u->subgoal, u, NULL, NULL, u->goal.x, u->goal.y, u->goal.x, u->goal.y, u->goal.x, u->goal.y, nodesdist*4); #endif #if 0 RichText rtext("ppathf"); NewTransx(u->drawpos + Vec3f(0,t->size.y,0), &rtext); #endif } else if(!u->pathblocked) #endif { #if 0 if(!FullPath(0, u->type, u->mode, u->cmpos.x, u->cmpos.y, u->target, u->target, u->target2, u->path, u->subgoal, u, NULL, NULL, u->goal.x, u->goal.y, u->goal.x, u->goal.y, u->goal.x, u->goal.y)) #endif JPSPath( u->type, u->mode, u->cmpos.x, u->cmpos.y, u->target, u->target2, u->targtype, &u->path, &u->subgoal, u, NULL, NULL, u->goal.x, u->goal.y, u->goal.x, u->goal.y, u->goal.x, u->goal.y); } return; } u->freecollider(); Vec2i dir = u->subgoal - u->cmpos; if(Magnitude2(u->subgoal - u->cmpos) <= t->cmspeed * t->cmspeed) { u->cmpos = u->subgoal; if(u->path.size() >= 2) { u->path.erase( u->path.begin() ); u->subgoal = *u->path.begin(); dir = u->subgoal - u->cmpos; } #if 0 else { u->fillcollider(); u->drawpos.x = u->cmpos.x; u->drawpos.z = u->cmpos.y; u->drawpos.y = g_hmap.accheight(u->drawpos.x, u->drawpos.z); u->rotation.y = GetYaw(dir.x, dir.y); return; } #endif } if(dir.x != 0 || dir.y != 0) { u->rotation.y = GetYaw(dir.x, dir.y); int mag = Magnitude(dir); #if 0 if(mag <= 0) mag = 1; #endif Vec2i scaleddir = dir * t->cmspeed / mag; u->cmpos = u->cmpos + scaleddir; #if 1 if(UnitCollides(u, u->cmpos, u->type)) #else if(Trace(u->type, u->mode, u->prevpos, u->cmpos, u, NULL, NULL) != COLLIDER_NONE) #endif { u->collided = true; u->cmpos = u->prevpos; u->path.clear(); u->subgoal = u->cmpos; u->fillcollider(); return; } #if 0 u->collided = false; #endif } if(UnitCollides(u, u->cmpos, u->type)) u->collided = true; u->fillcollider(); u->drawpos.x = u->cmpos.x; u->drawpos.z = u->cmpos.y; u->drawpos.y = g_hmap.accheight(u->cmpos.x, u->cmpos.y); }
void uwHexCtrl::OnPaint(wxPaintEvent& event) { // Setup DC wxBufferedPaintDC dc(this); PrepareDC(dc); dc.BeginDrawing(); dc.SetFont(Font); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); // Get native renderer wxRendererNative& renderer = wxRendererNative::Get(); // Get client rectangle wxRect rectClient(wxPoint(0,0), GetClientSize()); wxRect rectUnscrolled(rectClient); CalcUnscrolledPosition(rectClient.x, rectClient.y, &rectUnscrolled.x, &rectUnscrolled.y); // Paint headers background wxRect columnRect(rectClient); columnRect.y = 0; columnRect.height = ColumnHeight+1; CalcUnscrolledPosition(columnRect.x, columnRect.y, &columnRect.x, &columnRect.y); PaintRectangle( dc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), columnRect ); // Paint items background wxRect windowRect(rectClient); windowRect.y = columnRect.height; windowRect.height -= windowRect.y; CalcUnscrolledPosition(windowRect.x, windowRect.y, &windowRect.x, &windowRect.y); PaintRectangle( dc, GetBackgroundColour(), windowRect ); // return if no columns if( Columns.empty() ) return; // Ignore first event, client size is equal virtual size if( ++PaintCount == 1 ) return; // Paint headers for( dword column=0; column!=Columns.size(); ++column ) { wxRect rbox(Columns.at(column).BoxRect); wxRect rtext(Columns.at(column).TextRect); CalcUnscrolledPosition(rbox.x-rectUnscrolled.x, rbox.y, &rbox.x, &rbox.y); CalcUnscrolledPosition(rtext.x-rectUnscrolled.x, rtext.y, &rtext.x, &rtext.y); renderer.DrawHeaderButton( this, dc, rbox, 0 ); dc.DrawText( Columns.at(column).Caption, rtext.x, rtext.y ); } // Paint header filler wxCoord cwidth = Columns.back().BoxRect.x + Columns.back().BoxRect.width-rectUnscrolled.x; wxRect rbox( cwidth, 0, rectClient.width-cwidth-1, ColumnHeight ); if( rbox.width > 0 ) { CalcUnscrolledPosition(rbox.x, rbox.y, &rbox.x, &rbox.y); renderer.DrawHeaderButton( this, dc, rbox, 0 ); } // Get potential line numbers size_t lineFrom = (rectUnscrolled.y+ColumnHeight) / ItemHeight; size_t lineTo = (rectUnscrolled.GetBottom()) / ItemHeight; // Cap line numbers if( lineTo > HexLines - 1) lineTo = HexLines - 1; // Get first item pos wxCoord y = ColumnHeight + (lineFrom * ItemHeight) + ItemMarginY; wxCoord x = 0; for( size_t line = lineFrom; line <= lineTo; ++line ) { //wxCoord yPhys; //CalcScrolledPosition(0, y, NULL, &yPhys); //wxLogMessage("[%d] lineFrom=%d lineTo=%d y=%d yPhys=%d upd=%d,%d uns=%d,%d" // ,line,lineFrom,lineTo,y,yPhys,rectClient.y,rectClient.height,rectUnscrolled.y,rectUnscrolled.height); for( dword column=0; column!=Columns.size(); ++column ) { const uwHexCtrlColumn& it = Columns.at(column); if( column == 0 ) { dword pos = (line * HexWidth) + DataOffset; wxString item = wxString::Format( FmtOffset, pos ); dc.DrawText( item, it.BoxRect.x+ColumnMarginX, y ); } else if ( column == 1 ) { dword pos = (line * HexWidth); wxString item = wxString::Format( FmtOffset, pos ); dc.DrawText( item, it.BoxRect.x+ColumnMarginX, y ); } else if( column >= ColHexBegin && column < ColHexEnd ) { dword pos = (line * HexWidth) + (column - ColHexBegin); if( pos < DataCache.size() ) { if( HighlightBegin != -1 && pos >= HighlightBegin && pos < HighlightEnd ) { wxRect hlrect = it.BoxRect; hlrect.y = y; PaintRectangle( dc, wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), hlrect ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); dc.DrawText( HexStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } else { dc.DrawText( HexStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); } } } else if( column >= ColAsciiBegin && column < ColAsciiEnd ) { dword pos = (line * HexWidth) + column - ColAsciiBegin; if( pos < DataCache.size() ) { if( HighlightBegin != -1 && pos >= HighlightBegin && pos < HighlightEnd ) { wxRect hlrect = it.BoxRect; hlrect.y = y; PaintRectangle( dc, wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), hlrect ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); dc.DrawText( AsciiStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } else { dc.DrawText( AsciiStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); } } } } y += HexCharHeight + ItemMarginY + ItemMarginY; } dc.EndDrawing(); }
void TextEventDialog::slotTypeChanged(const QString &) { std::string type(getTextType()); QString qtrunc(m_text->text()); if (qtrunc.length() > 20) qtrunc = qtrunc.left(20) + "..."; std::string text(qstrtostr(qtrunc)); if (text == "") text = "Sample"; Text rtext(text, type); m_textExampleLabel->setPixmap(m_notePixmapFactory->makeTextPixmap(rtext)); // // swap widgets in and out, depending on the current text type // if (type == Text::Dynamic) { m_optionLabel->setCurrentWidget(m_dynamicShortcutLabel); m_optionWidget->setCurrentWidget(m_dynamicShortcutCombo); slotDynamicShortcutChanged(strtoqstr(text)); } if (type == Text::Direction) { m_optionLabel->setCurrentWidget(m_directionShortcutLabel); m_optionWidget->setCurrentWidget(m_directionShortcutCombo); slotDirectionShortcutChanged(strtoqstr(text)); } if (type == Text::LocalDirection) { m_optionLabel->setCurrentWidget(m_localDirectionShortcutLabel); m_optionWidget->setCurrentWidget(m_localDirectionShortcutCombo); slotLocalDirectionShortcutChanged(strtoqstr(text)); } if (type == Text::Tempo) { m_optionLabel->setCurrentWidget(m_tempoShortcutLabel); m_optionWidget->setCurrentWidget(m_tempoShortcutCombo); slotTempoShortcutChanged(strtoqstr(text)); } if (type == Text::LocalTempo) { m_optionLabel->setCurrentWidget(m_localTempoShortcutLabel); m_optionWidget->setCurrentWidget(m_localTempoShortcutCombo); slotLocalTempoShortcutChanged(strtoqstr(text)); } if (type == Text::Lyric) { m_optionLabel->setCurrentWidget(m_verseLabel); m_optionWidget->setCurrentWidget(m_verseSpin); } if (type == Text::Annotation || type == Text::Chord || type == Text::UnspecifiedType) { m_optionLabel->setCurrentWidget(m_blankLabel); m_optionWidget->setCurrentWidget(m_blankWidget); } // restore previous text of appropriate type if (type == Text::Lyric) m_text->setText(m_prevLyric); else if (type == Text::Chord) m_text->setText(m_prevChord); else if (type == Text::Annotation) m_text->setText(m_prevAnnotation); // // LilyPond directives only taking temporary residence here; will move out // into some new class eventually // if (type == Text::LilyPondDirective) { m_optionWidget->setCurrentWidget(m_lilyPondDirectiveCombo); m_optionLabel->setCurrentWidget(m_directiveLabel); m_staffAboveLabel->hide(); m_staffBelowLabel->show(); m_text->setReadOnly(true); m_text->setEnabled(false); slotLilyPondDirectiveChanged(strtoqstr(text)); } else { m_text->setReadOnly(false); m_text->setEnabled(true); if (type == Text::Dynamic || type == Text::LocalDirection || type == Text::UnspecifiedType || type == Text::Lyric || type == Text::Annotation) { m_staffAboveLabel->show(); m_staffBelowLabel->hide(); } else { m_staffAboveLabel->hide(); m_staffBelowLabel->show(); } } adjustSize(); }