void Polynomial::print() { int n = ci.rows(); std::cout << "P(x) = "; if (n == 0) { std::cout << "?" << std::endl; } else { for (int i = n - 1; i >= 0; i--) { if (i > 0) { std::cout << ci(i) << " + "; } else { std::cout << ci(i); } if (i > 0) { if (ri(i) == 0) { std::cout << "x * "; } else { std::cout << "(x - " << ri(i) << ") * "; } if (i > 1) std::cout << "( "; } } for (int i = n - 1; i > 1; i--) { std::cout << " )"; } std::cout << std::endl; } }
//------------------------------------------------------------------------------ void Canvas::DrawAnnulus(int x, int y, unsigned inner_r, unsigned outer_r, Angle start, Angle end) { QPainterPath p; QRectF ri(x - inner_r, y - inner_r, 2 * inner_r, 2 * inner_r); QRectF ro(x - outer_r, y - outer_r, 2 * outer_r, 2 * outer_r); // Draw the inner radius of the annulus. p.arcMoveTo(ri, start.Degrees()); p.arcTo(ri, start.Degrees(), end.Degrees() - start.Degrees()); if (start != end) { // Only draw the end caps when needed. // The currentPosition() will be at the end of the inner circle. Draw // one side of the annulus. // \todo This doesn't work because Angle(360) != Angle(0)! double xx = (outer_r - inner_r) * cos(end.Radians()) + p.currentPosition().rx(); double yy = (outer_r - inner_r) * -sin(end.Radians()) + p.currentPosition().ry(); p.lineTo(xx, yy); } else p.arcMoveTo(ro, end.Degrees()); // Set up for the outer circle. // The currentPosition() will be at the 'end' of the outer circle. Draw the // outer to the start. p.arcTo(ro, end.Degrees(), start.Degrees() - end.Degrees()); if (start != end) {// And close it off to finish up. p.closeSubpath(); } this->pushObject(p, this->pen(), this->brush()); }
void KSysTrayCmd::execContextMenu( const QPoint &pos ) { KPopupMenu *menu = new KPopupMenu(); menu->insertTitle( *pixmap(), i18n( "KSysTrayCmd" ) ); int hideShowId = menu->insertItem( isVisible ? i18n( "&Hide" ) : i18n( "&Restore" ) ); int undockId = menu->insertItem( SmallIcon("close"), i18n( "&Undock" ) ); int quitId = menu->insertItem( SmallIcon("exit"), i18n( "&Quit" ) ); int cmd = menu->exec( pos ); if ( cmd == quitId ) quitClient(); else if ( cmd == undockId ) quit(); else if ( cmd == hideShowId ) { if ( lazyStart && ( !hasRunningClient() ) ) { start(); isVisible=true; } else if ( quitOnHide && ( hasRunningClient() ) && isVisible ) { NETRootInfo ri( qt_xdisplay(), NET::CloseWindow ); ri.closeWindowRequest( win ); isVisible=false; } else toggleWindow(); } delete menu; }
float Animal_Wild_Flee::postCondition() { /* * Fleeing from an approaching player has the following postconditions: * - There is no character in flight range. * - There is an character attacking us. * - Our owner has come in range. * */ if( m_npc->attackTarget() ) return 1.0f; RegionIterator4Chars ri( m_npc->pos(), SrvParams->animalWildFleeRange() ); bool found = false; for(ri.Begin(); !ri.atEnd(); ri++) { P_PLAYER pPlayer = dynamic_cast<P_PLAYER>(ri.GetData()); if( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() ) found = true; if( pPlayer && m_npc->owner() == pPlayer ) return 1.0f; } if( found ) return 0.0f; return 1.0f; }
void KPager::clientPopupActivated( int id ) { switch ( id ) { case MaximizeOp: if ( (m_winfo.state() & NET::Max) == 0 ) { NETWinInfo ni( qt_xdisplay(), m_winfo.win(), qt_xrootwin(), 0); ni.setState( NET::Max, NET::Max ); } else { NETWinInfo ni( qt_xdisplay(), m_winfo.win(), qt_xrootwin(), 0); ni.setState( 0, NET::Max ); } break; case IconifyOp: if ( !m_winfo.isMinimized() ) { KWin::iconifyWindow( m_winfo.win()); } else { KWin::forceActiveWindow( m_winfo.win() ); } break; case StickyOp: if ( m_winfo.onAllDesktops() ) { KWin::setOnAllDesktops(m_winfo.win(), false); } else { KWin::setOnAllDesktops(m_winfo.win(), true); } break; case CloseOp: { NETRootInfo ri( qt_xdisplay(), 0 ); ri.closeWindowRequest( m_winfo.win() ); } break; default: break; } }
U32 Mesh::Manager::Report() { U32 countT = 0, memT = 0; NBinTree<MeshRoot>::Iterator ri(&rootTree); while (MeshRoot * root = ri++) { if (!root->isChunk) { memT += root->GetMem(); countT++; } } U32 countE = 0, memE = 0; NList<MeshEnt>::Iterator ei(&entList); while (MeshEnt * ent = ei++) { memE += ent->GetMem(); countE++; } U32 mem = memT + memE + endVar - startVar; // namespace CON_DIAG( ("%4d %-31s: %9d", countT, "mesh types", memT ) ); LOG_DIAG( ("%4d %-31s: %9d", countT, "mesh types", memT ) ); CON_DIAG( ("%4d %-31s: %9d", countE, "mesh instances", memE ) ); LOG_DIAG( ("%4d %-31s: %9d", countE, "mesh instances", memE ) ); return mem; }
void RenderThread::run() { DEBUGOUT << "RenderThread for" << renderMe << "started"; QImage renderImage = RenderUtils::renderPagePart(m_page.page, renderMe.requestedPageSize(), renderMe.pagePart()); if ( renderImage.isNull() ) { qWarning() << "RenderThread for" << renderMe << "failed"; QSharedPointer<RenderingIdentifier> ri( new RenderingIdentifier(renderMe) ); emit renderingFailed(ri); return; } QList< AdjustedLink > links; for( Poppler::Link* link: m_page.page->links() ) { QSharedPointer<Poppler::Link> ptrLink(link); try{ AdjustedLink al(renderMe, ptrLink); links.append(al); } catch( AdjustedLink::OutsidePage & e) { // no-op } } QSharedPointer<RenderedPage> renderResult(new RenderedPage( renderImage, links, renderMe )); DEBUGOUT << "RenderThread for" << renderMe << "successful, image has size" << renderResult->getImage().size(); emit renderingFinished(renderResult); }
void inductive_property::to_model(model_ref& md) const { md = alloc(model, m); vector<relation_info> const& rs = m_relation_info; expr_ref_vector conjs(m); for (unsigned i = 0; i < rs.size(); ++i) { relation_info ri(rs[i]); func_decl * pred = ri.m_pred; expr_ref prop = fixup_clauses(ri.m_body); func_decl_ref_vector const& sig = ri.m_vars; expr_ref q(m); expr_ref_vector sig_vars(m); for (unsigned j = 0; j < sig.size(); ++j) { sig_vars.push_back(m.mk_const(sig[sig.size()-j-1])); } expr_abstract(m, 0, sig_vars.size(), sig_vars.c_ptr(), prop, q); if (sig.empty()) { md->register_decl(pred, q); } else { func_interp* fi = alloc(func_interp, m, sig.size()); fi->set_else(q); md->register_decl(pred, fi); } } TRACE("pdr", model_smt2_pp(tout, m, *md, 0););
void TLevelWriterMov::save(const TImageP &img, int frameIndex) { TRasterImageP ri(img); if (!img) throw TImageException(getFilePath(), "Unsupported image type"); TRasterP ras(ri->getRaster()); int lx = ras->getLx(), ly = ras->getLy(), pixSize = ras->getPixelSize(); if (pixSize != 4) throw TImageException(getFilePath(), "Unsupported pixel type"); int size = lx * ly * pixSize; // Send messages QLocalSocket socket; tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); tipc::Stream stream(&socket); tipc::Message msg; // Send the write message. stream << (msg << QString("$LWMovImageWrite") << m_id << frameIndex << lx << ly); // Send the data through a shared memory segment { t32bitsrv::RasterExchanger<TPixel32> exch(ras); tipc::writeShMemBuffer(stream, msg << tipc::clr, size, &exch); } if (tipc::readMessage(stream, msg) != "ok") throw TImageException(getFilePath(), "Couln't save image"); }
void CShadowController::AttachObject( void ) { IVP_Real_Object *pivp = m_pObject->GetObject(); IVP_Core *pCore = pivp->get_core(); m_saveRot = pCore->rot_speed_damp_factor; m_savedRI = *pCore->get_rot_inertia(); m_savedMass = pCore->get_mass(); m_savedMaterialIndex = m_pObject->GetMaterialIndexInternal(); m_pObject->SetMaterialIndex( MATERIAL_INDEX_SHADOW ); pCore->rot_speed_damp_factor = IVP_U_Float_Point( 100, 100, 100 ); if ( !m_allowPhysicsRotation ) { IVP_U_Float_Point ri( 1e15f, 1e15f, 1e15f ); pCore->set_rotation_inertia( &ri ); } if ( !m_allowPhysicsMovement ) { m_pObject->SetMass( 1e6f ); //pCore->inv_rot_inertia.hesse_val = 0.0f; m_pObject->EnableGravity( false ); } pCore->calc_calc(); pivp->get_environment()->get_controller_manager()->add_controller_to_core( this, pCore ); m_shadow.lastPosition.set_to_zero(); }
RationalNumber RationalNumber::operator/(const int i) const { RationalNumber ri(i); RationalNumber rr(*this); rr /= ri; rr.normalize(); return rr; }
int main (int argc, char **argv) { /* YOUR CODE HERE */ ssize_t raw_sklen = 32; char* skfname = argv[1]; if (argc != 2) { usage (argv[0]); } else { setprogname (argv[0]); /* first, let's create a new symmetric key */ ri (); /* Note that since we'll need to do both AES-CTR and AES-CBC-MAC, there are actuall *two* symmetric keys, which could, e.g., be stored contiguosly in a buffer */ /* YOUR CODE HERE */ char* buffer = (char*)malloc(raw_sklen * sizeof(char)); prng_getbytes(buffer, raw_sklen); /* now let's armor and dump to disk the symmetric key buffer */ /* YOUR CODE HERE */ write_skfile(skfname, buffer, raw_sklen); bzero(buffer, raw_sklen); free(buffer); /* finally, let's scrub the buffer that held the random bits by overwriting with a bunch of 0's */ } return 0; }
Application *Application::GetGlobalApplication(String &applicationName) { StartTrace(Application.GetGlobalApplication); Application *application = 0; if (!fgConfig.IsNull()) { Anything applicationConf; if (fgConfig.LookupPath(applicationConf, "Application") ) { for (long i = 0, sz = applicationConf.GetSize() && !application; i < sz; ++i) { // iterate over the applicationname list applicationName = applicationConf[i].AsCharPtr(0); if ( applicationName.Length() > 0 ) { // return the first application object found by name application = Application::FindApplication(applicationName); break; } } } else { // if no application object is configured in the config any // return the first in the list RegistryIterator ri(MetaRegistry::instance().GetRegistry("Application"), false); for ( ; ri.HasMore() && !application ; application = SafeCast(ri.Next(applicationName), Application)); } } return application; }
int response(UOXSOCKET s, P_CHAR pPlayer, char* SpeechUpr) { char *comm=SpeechUpr; if (strstr( comm, "#EMPTY") && online(currchar[s]) && !pPlayer->dead && pPlayer->isGM()) { // restricted to GMs for now. It's too powerful (Duke, 5.6.2001) target(s, 0, 1, 0, 71, "Select container to empty:"); return 1; } if (!online(DEREF_P_CHAR(pPlayer)) || pPlayer->dead) return 0; P_CHAR pc; cRegion::RegionIterator4Chars ri(pPlayer->pos); for (ri.Begin(); (pc=ri.GetData()) != ri.End(); ri++) { if (pc->isPlayer()) // only npcs will respond automagically, players still have to do that themselves ;) continue; if (pPlayer->dist(pc) > 16) // at least they should be on the screen continue; if (pPlayer->isSameAs(pc)) // not talking to ourselves continue; if (StableSpeech(pc, comm, pPlayer, s)) return 1; if (UnStableSpeech(pc, comm, pPlayer, s)) return 1; if (ShieldSpeech(pc, comm, pPlayer, s)) return 1; if (QuestionSpeech(pc, comm, pPlayer, s)) return 1; if (PackupSpeech(pc, comm, pPlayer, s)) return 1; if (TriggerSpeech(pc, comm, pPlayer, s)) return 1; if (EscortSpeech(pc, comm, pPlayer, s)) return 1; if (BankerSpeech(pc, comm, pPlayer, s)) return 1; if (TrainerSpeech(pc, comm, pPlayer, s)) return 1; if (PetCommand(pc, comm, pPlayer, s)) return 1; if (VendorSpeech(pc, comm, pPlayer, s)) return 1; } return 0; }
DrawableTextureDataP texture_utils::getTextureData( const TXshSimpleLevel *sl, const TFrameId &fid, int subsampling) { const std::string &texId = sl->getImageId(fid); // Now, we must associate a texture DrawableTextureDataP data(TTexturesStorage::instance()->getTextureData(texId)); if (data) return data; // There was no associated texture. We must bind the texture and repeat // First, retrieve the image to be used as texture TRasterImageP ri(::getTexture(sl, fid, subsampling)); if (!ri) return DrawableTextureDataP(); TRaster32P ras(ri->getRaster()); assert(ras); TRectD geom(0, 0, ras->getLx(), ras->getLy()); geom = TScale(ri->getSubsampling()) * TTranslation(convert(ri->getOffset()) - ras->getCenterD()) * geom; return TTexturesStorage::instance()->loadTexture(texId, ras, geom); }
P_ITEM findmulti(Coord_cl pos) //Sortta like getboat() only more general... use this for other multi stuff! { int lastdist = 30; P_ITEM multi = NULL; int ret; cRegion::RegionIterator4Items ri(pos); for (ri.Begin(); !ri.atEnd(); ri++) { P_ITEM mapitem = ri.GetData(); if (mapitem != NULL) { if (mapitem->isMulti()) { ret = pos.distance(mapitem->pos); if (ret <= lastdist) { lastdist = ret; if (inmulti(pos, mapitem)) multi = mapitem; } } } } return multi; }
void FullColorBrushTool::onEnter() { TImageP img = getImage(false); TRasterImageP ri(img); if (ri) { m_minThick = m_thickness.getValue().first; m_maxThick = m_thickness.getValue().second; } else { m_minThick = 0; m_maxThick = 0; } Application *app = getApplication(); if (app->getCurrentObject()->isSpline()) { m_currentColor = TPixel32::Red; return; } TPalette *plt = app->getCurrentPalette()->getPalette(); if (!plt) return; int style = app->getCurrentLevelStyleIndex(); TColorStyle *colorStyle = plt->getStyle(style); m_currentColor = colorStyle->getMainColor(); }
void ReadEV3LineTracerSetting::process(InputContext &input) { //Intervalの読み取り ReadInterval ri(ev3LineTracer); ri.process(input); //CostMaxの読み取り ReadCostMax rcm(ev3LineTracer); rcm.process(input); //State数の読み取り ReadStateCount rsc(ev3LineTracer); rsc.process(input); //Stateの読み取り ReadState rs(ev3LineTracer); rs.process(input); //Controlの読み取り ReadControl rc(ev3LineTracer); rc.process(input); //RegularPolicyの読み取り ReadRegularPolicy<EV3LineTracer> rrp(ev3LineTracer); rrp.process(input); //CurrentPolicyをRegularPolicyとして設定する ev3LineTracer.setCurrentPolicyLocal(ev3LineTracer.getRegularPolicy()); }
int main (int argc, char **argv) { /* argv[1] is the file name */ char raw_sk[2*CCA_STRENGTH]; if (argc != 2) { usage (argv[0]); } else { setprogname (argv[0]); /* first, let's create a new symmetric key */ ri (); /* Note that since we'll need to do both AES-CBC-MAC and HMAC-SHA1, there are actuall *two* symmetric keys, which could, e.g., be stored contiguosly in a buffer */ prng_getbytes(raw_sk, 2*CCA_STRENGTH); /* now let's armor and dump to disk the symmetric key buffer */ write_skfile(argv[1], raw_sk, 2*CCA_STRENGTH); /* finally, let's scrub the buffer that held the random bits by overwriting with a bunch of 0's */ bzero(raw_sk, 2*CCA_STRENGTH); } return 0; }
void QSegmentWidget::DrawCylinder(const Cylinder &cyl, const SegmentList &s, const bool erase) { if (!m_pixmap) InitPixmap(); qreal border = 0; QPainter painter(m_pixmap); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setWindow( -(BM_OSIZE / 2), -(BM_OSIZE / 2), BM_OSIZE, BM_OSIZE); QRectF rco(-cyl.outerRadius, -cyl.outerRadius, (cyl.outerRadius * 2.0)+border, (cyl.outerRadius * 2.0)+border); QRectF rci(-cyl.innerRadius, -cyl.innerRadius, (cyl.innerRadius * 2.0)+border, (cyl.innerRadius * 2.0)+border); QRegion ro(rco.toRect(), QRegion::Rectangle); QRegion ri(rci.toRect(), QRegion::Ellipse); QRegion region = ro.subtracted(ri); painter.setClipRegion(region); if (erase) { painter.setBrush(Qt::NoBrush); painter.setPen(Qt::NoPen); } else { QBrush b(cyl.color); painter.setBrush(b); painter.setPen(QPen(cyl.color.darker(200),border)); } DrawSegments(&painter, s, cyl.outerRadius); }
void Polynomial::push(float r, float c) { int n = ci.rows(); ri.conservativeResize(n + 1); ci.conservativeResize(n + 1); ri(n) = r; ci(n) = c; }
void ColaTopologyAddon::handleResizes(const cola::Resizes& resizeList, unsigned n, std::valarray<double>& X, std::valarray<double>& Y, cola::CompoundConstraints& ccs, vpsc::Rectangles& boundingBoxes, cola::RootCluster* clusterHierarchy) { FILE_LOG(cola::logDEBUG) << "ColaTopologyAddon::handleResizes()..."; if(topologyNodes.empty()) { COLA_ASSERT(topologyRoutes.empty()); return; } // all shapes to be resized are wrapped in a ResizeInfo and // placed in a lookup table, resizes, indexed by id ResizeMap resizes; for(cola::Resizes::const_iterator r=resizeList.begin();r!=resizeList.end();++r) { topology::ResizeInfo ri(topologyNodes[r->getID()],r->getTarget()); resizes.insert(std::make_pair(r->getID(),ri)); } vpsc::Variables xvs, yvs; vpsc::Constraints xcs, ycs; cola::setupVarsAndConstraints(n, ccs, vpsc::HORIZONTAL, boundingBoxes, clusterHierarchy, xvs, xcs, X); cola::setupVarsAndConstraints(n, ccs, vpsc::VERTICAL, boundingBoxes, clusterHierarchy, yvs, ycs, Y); topology::applyResizes(topologyNodes, topologyRoutes, clusterHierarchy, resizes, xvs, xcs, yvs, ycs); for_each(xvs.begin(), xvs.end(), delete_object()); for_each(yvs.begin(), yvs.end(), delete_object()); for_each(xcs.begin(), xcs.end(), delete_object()); for_each(ycs.begin(), ycs.end(), delete_object()); FILE_LOG(cola::logDEBUG) << "ColaTopologyAddon::handleResizes()... done."; }
void wxQtDCImpl::QtPreparePainter( ) { //Do here all QPainter initialization (called after each begin()) if ( m_qtPainter == NULL ) { wxLogDebug(wxT("wxQtDCImpl::QtPreparePainter is NULL!!!")); } else if ( m_qtPainter->isActive() ) { m_qtPainter->setPen( wxPen().GetHandle() ); m_qtPainter->setBrush( wxBrush().GetHandle() ); m_qtPainter->setFont( wxFont().GetHandle() ); if (m_clipping) { wxRegionIterator ri(*m_clippingRegion); bool append = false; while (ri.HaveRects()) { wxRect r = ri.GetRect(); m_qtPainter->setClipRect( r.x, r.y, r.width, r.height, append ? Qt::IntersectClip : Qt::ReplaceClip ); append = true; ri++; } } } else { wxLogDebug(wxT("wxQtDCImpl::QtPreparePainter not active!")); } }
bool newpathfinder(actor_t *m) { int oy, ox, dx, dy, dist, newdist, newdx, newdy; if(!m->goalx || !m->goaly || m->x == m->goalx || m->y == m->goaly) { m->goalx = ri(1, world->curlevel->xsize - 1); m->goaly = ri(1, world->curlevel->ysize - 1); while(!monster_passable(world->curlevel, m->goaly, m->goalx)) { m->goalx = ri(1, world->curlevel->xsize - 1); m->goaly = ri(1, world->curlevel->ysize - 1); } } oy = m->y; ox = m->x; makedistancemap(m->goaly, m->goalx); dx = 0; dy = 0; dist = 99999; for(newdy = -1; newdy <= 1; newdy++) { for(newdx = -1; newdx <= 1; newdx++) { newdist = distancemap[m->y + newdy][m->x + newdx]; if(newdist < dist) { dist = newdist; dx = newdx; dy = newdy; } } } m->y += dy; m->x += dx; /* if(!monster_passable(world->curlevel, m->y, m->x)) { m->y = oy; m->x = ox; return false; } */ world->cmap[oy][ox].monster = NULL; world->cmap[m->y][m->x].monster = m; return true; }
int update_binary_main(int argc, char *argv[]) { // Make stdout unbuffered setvbuf(stdout, nullptr, _IONBF, 0); int opt; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; int long_index = 0; while ((opt = getopt_long(argc, argv, "h", long_options, &long_index)) != -1) { switch (opt) { case 'h': update_binary_usage(0); return EXIT_SUCCESS; default: update_binary_usage(1); return EXIT_FAILURE; } } if (argc - optind != 3) { update_binary_usage(1); return EXIT_FAILURE; } int interface; int output_fd; const char *zip_file; char *ptr; interface = strtol(argv[1], &ptr, 10); if (*ptr != '\0' || interface < 0) { fprintf(stderr, "Invalid interface"); return EXIT_FAILURE; } output_fd = strtol(argv[2], &ptr, 10); if (*ptr != '\0' || output_fd < 0) { fprintf(stderr, "Invalid output fd"); return EXIT_FAILURE; } zip_file = argv[3]; // stdout is messed up when it's appended to /tmp/recovery.log util::log_set_logger(std::make_shared<util::StdioLogger>(stderr, false)); mbp::setLogCallback(mbp_log_cb); RecoveryInstaller ri(zip_file, interface, output_fd); return ri.start_installation() ? EXIT_SUCCESS : EXIT_FAILURE; }
int main (int argc, char **argv) { int arg_idx = 0; char *privcert_file = NULL; char *pubcert_file = NULL; char *priv_file = NULL; char *pub_file = NULL; char *priv_id = NULL; char *pub_id = NULL; char *label = DEFAULT_LABEL; dckey *priv = NULL; dckey *pub = NULL; cert *priv_cert = NULL; cert *pub_cert = NULL; printf("argc count is: %d\n", argc); if((argc < 7) || (argc > 8)) { printf("Invalid number of arguments!!!\n"); usage (argv[0], argc); } printf("argc value is: %d\n", argc); ri (); priv_file = argv[++arg_idx]; privcert_file = argv[++arg_idx]; priv_id = argv[++arg_idx]; pub_file = argv[++arg_idx]; pubcert_file = argv[++arg_idx]; pub_id = argv[++arg_idx]; if (argc - 2 == arg_idx) { /* there was a label */ label = argv[++arg_idx]; } pub_cert = pki_check(pubcert_file, pub_file, pub_id); /* check above won't return if something was wrong */ pub = pub_cert->public_key; if (!cert_verify (priv_cert = cert_read (privcert_file))) { printf ("%s: trouble reading certificate from %s, " "or certificate expired\n", getprogname (), privcert_file); perror (getprogname ()); exit (-1); } else if (!dcareequiv(pub_cert->issuer,priv_cert->issuer)) { printf ("%s: certificates issued by different CAs.\n", getprogname ()); printf ("\tOwn (%s's) certificate in %s\n", priv_id, privcert_file); printf ("\tOther (%s's) certificate in %s\n", pub_id, pubcert_file); } else { priv = priv_from_file (priv_file); nidh (priv, pub, priv_id, pub_id, label); } return 0; }
/** * \brief Creates a dialog for editing the recording schedule */ void ScheduleCommon::EditScheduled(ProgramInfo *pginfo) { if (!pginfo) return; RecordingInfo ri(*pginfo); EditScheduled(&ri); }
/** * @brief Very stupid, random "pathfinder". It makes an actor move to a random (and legal/possible) cell. * * @param m Pointer to the actor/monster which is to do this movement. * * @return True if actor successfully moved, false if not. */ int simpleoutdoorpathfinder(actor_t *m) { int choice; int oy, ox; //co c; oy = m->y; ox = m->x; if(m->y <= 2) return true; if(m->x <= 2) return true; if(!m->goalx || !m->goaly || m->x == m->goalx || m->y == m->goaly) { // basically, if we have no goal, or have reached the goal, set a new goal. m->goalx = ri(1, world->curlevel->xsize - 1); m->goaly = ri(1, world->curlevel->ysize - 1); while(!monster_passable(world->curlevel, m->goaly, m->goalx)) { m->goalx = ri(1, world->curlevel->xsize - 1); m->goaly = ri(1, world->curlevel->ysize - 1); } } choice = ri(1,100); if(choice <= 45) { if(m->x > m->goalx) m->x--; if(m->x < m->goalx) m->x++; } else if(choice > 45 && choice <= 90) { if(m->y > m->goaly) m->y--; if(m->y < m->goaly) m->y++; } else if(choice > 90) { // maybe not extremely useful, but adds randomness to the movements, // as if the creature's attention was briefly caught by something else.. m->y += ri(-1, 1); m->x += ri(-1, 1); } //makedistancemap(m->goaly, m->goalx); //c = get_next_step(m->y, m->x); //m->y += c.y; //m->x += c.x; if(monster_passable(world->curlevel, m->y, m->x)) { world->cmap[oy][ox].monster = NULL; world->cmap[m->y][m->x].monster = m; return true; } else { m->y = oy; m->x = ox; return false; } }
float Polynomial::eval(float x) { int n = ci.rows(); if (n == 0) { return 0; } float y = ci(0); for (int i = 1; i < n; i++) { y = y * (x - ri(i)) + ci(i); } return y; }
//----------------------------------------------------------------------------- // Close task //FIXME void daisy::closeTask(WId id) { KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMState ); if ( taskInfo.valid() ) { NETRootInfo ri( QX11Info::display(), NET::CloseWindow ); ri.closeWindowRequest( id ); } }