void ImageCaptionGrabber::checkIfGrabsMouse(int x, int y, const Camera* const camera) { if (m_pressed) { // mouse button pressed so keep grabbing setGrabsMouse(true); return; } Vec voxelSize = Global::voxelScaling(); Vec pos = position(); if (pos.z > -100000) { pos = VECPRODUCT(pos, voxelSize); pos = camera->projectedCoordinatesOf(pos); } else { pos.x = camera->screenWidth()*pos.x; pos.y = camera->screenHeight()*pos.y; //QPoint scr = mapFromGlobal(pos); } QPoint hp(pos.x, pos.y); if ((hp-QPoint(x,y)).manhattanLength() < 50) setGrabsMouse(true); else setGrabsMouse(false); }
void FilterOnePole::test() { float tau = 10; float updateInterval = 1; float nextupdateTime = millis()*1e-3; float inputValue = 0; FilterOnePole hp( HIGHPASS, tau, inputValue ); FilterOnePole lp( LOWPASS, tau, inputValue ); while( true ) { float now = millis()*1e-3; // switch input values on a 20 second cycle if( round(now/20.0)-(now/20.0) < 0 ) inputValue = 0; else inputValue = 100; hp.input(inputValue); lp.input(inputValue); if( now > nextupdateTime ) { nextupdateTime += updateInterval; Serial.print("inputValue: "); Serial.print( inputValue ); Serial.print("\t high-passed: "); Serial.print( hp.output() ); Serial.print("\t low-passed: "); Serial.print( lp.output() ); Serial.println(); } } }
QList<int>* Controller::search(QString txt,const int& c) const{ QList<int>* indexlist=0; if( !model.empty() && !txt.isEmpty() )//se il db non è vuoto e c'è un valore su cui eseguire la ricerca { switch(c){ case 0://Name indexlist=model.find(name(txt.toStdString()));//funtori break; case 1://Type indexlist=model.find(type(txt.toStdString())); break; case 2://HP indexlist=model.find(hp(txt.toShort())); break; case 3://MP indexlist=model.find(mp(txt.toShort())); break; case 4://LV indexlist=model.find(lv(txt.toShort())); break; case 5://Strength indexlist=model.find(strength(txt.toShort())); break; case 6://Constitution indexlist=model.find(constitution(txt.toShort())); break; case 7://Wisdom indexlist=model.find(wisdom(txt.toShort())); break; } } return indexlist; }
int MinimumHP::calculateMinimumHP(std::vector<std::vector<int> > &dungeon) { if (dungeon.empty() || dungeon[0].empty()) { return 0; } int rowSize = dungeon.size(); int colSize = dungeon[0].size(); std::vector<std::vector<int>> hp(rowSize, std::vector<int>(colSize, 0)); hp[rowSize - 1][colSize - 1] = std::max(0, -dungeon[rowSize-1][colSize-1]); for (int i = rowSize - 2; i >= 0; --i) { hp[i][colSize - 1] = std::max(0, hp[i+1][colSize-1]-dungeon[i][colSize-1]); } for (int j = colSize -2; j >= 0; --j) { hp[rowSize-1][j] = std::max(0, hp[rowSize-1][j+1] - dungeon[rowSize-1][j]); } for (int i = rowSize - 2; i >=0; --i) { for (int j = colSize-2; j >= 0; --j) { hp[i][j] = std::max(0, std::min(hp[i+1][j], hp[i][j+1]) - dungeon[i][j]); } } return hp[0][0] + 1; }
inline bool app_init_config() { #ifdef _WIN32 std::string global_config_file = "gsmartcontrol.conf"; // installation dir s_home_config_file = hz::get_home_dir() + hz::DIR_SEPARATOR_S + "gsmartcontrol.conf"; // $HOME/program_name.conf #else std::string global_config_file = std::string(PACKAGE_SYSCONF_DIR) + hz::DIR_SEPARATOR_S + "gsmartcontrol.conf"; s_home_config_file = hz::get_home_dir() + hz::DIR_SEPARATOR_S + ".gsmartcontrolrc"; #endif hz::FsPath gp(global_config_file); // Default system-wide settings. This file is empty by default. hz::FsPath hp(s_home_config_file); // Per-user settings. if (gp.exists() && gp.is_readable()) rconfig::load_from_file(gp.str()); if (hp.exists() && hp.is_readable()) rconfig::load_from_file(hp.str()); rconfig::dump_tree(); init_default_settings(); // initialize /default #ifdef ENABLE_GLIB rconfig::autosave_set_config_file(s_home_config_file); uint32_t autosave_timeout = rconfig::get_data<uint32_t>("system/config_autosave_timeout"); if (autosave_timeout) rconfig::autosave_start(autosave_timeout); #endif return true; }
void ScreenshotManager::initHistory() { if (mHistoryInitialized) { return; } // Creating the SQLite database. QSqlDatabase history = QSqlDatabase::addDatabase("QSQLITE"); QDir hp(mHistoryPath); if (!hp.exists()) { hp.mkpath(mHistoryPath); } history.setHostName("localhost"); history.setDatabaseName(mHistoryPath + "history.sqlite"); if (history.open()) { history.exec("CREATE TABLE IF NOT EXISTS history (fileName text, URL text, deleteURL text, time integer)"); mHistoryInitialized = true; } else { qCritical() << "Could not open SQLite DB."; } }
int dtrace_xen_hypercall(int call, void *a, void *b, void *c) { #if DO_XEN static char *hypercall_page; static int (*hp)(void *, void *, void *); int ret; if (!dtrace_is_xen()) return 0; /***********************************************/ /* hypercall_page is GPL protected and is */ /* an assembly level parameter coming from */ /* <hypercall.h>, so work around that. We */ /* need to be low level to get to the Xen */ /* API (allow as much dtrace probing as */ /* possible), so we have to do what the */ /* kernel is doing (approximately). */ /***********************************************/ if (hypercall_page == NULL) hypercall_page = get_proc_addr("hypercall_page"); if (hypercall_page == NULL) return 0; hp = (void *) (hypercall_page + call * 32); ret = hp(a, b, c); return ret; #endif /* DO_XEN */ }
InterpretedIC* frame::current_interpretedIC() const { if (is_interpreted_frame()) { methodOop m = method(); int bci = m->bci_from(hp()); u_char* codeptr = m->codes(bci); if (Bytecodes::is_send_code(Bytecodes::Code(*codeptr))) { InterpretedIC* ic = as_InterpretedIC((char*)hp()); assert(ic->send_code_addr() == codeptr, "found wrong ic"); return ic; } else { return NULL; // perform, dll call, etc. } } return NULL; // doesn't have InterpretedIC }
void GLObject::tick(){ behaviors.tick(); for(size_t i = 0; i<bullets.size();/* ++i*/){ if( !bullets[i]->isLife()){ hp( hp() - bullets[i]->damage() ); delete bullets[i]; bullets[i] = bullets.back(); bullets.pop_back(); } else { bullets[i]->tick(); ++i; } } }
void frame::restore_hcode_pointer() { if (!is_interpreted_frame()) return; // Readjust hcode pointer u_char* obj = hp(); int offset = MarkSweep::next_hcode_offset(); // if (WizardMode) lprintf("[0x%lx+%d]\n", obj, offset); set_hp(obj + offset); }
Vec2 Homography::transformPoint( const Vec2 & p ) const { Vec4 hp(p.x,p.y,0,1.0); hp = mul(hp,matrix); hp.x/=hp.w; hp.y/=hp.w; return Vec2(hp.x,hp.y); }
int main() { HasPtr hp("sss"); HasPtr hp2 = hp; return 0; }
void hourserace() { apvector<int> hp(3,1); firstshow(); while(hp[1]!=trackl&& hp[2]!=trackl&&hp[0]!=trackl) { drawscreen(hp); } }
Pokemon* User::GetOpponentPokemonFromServer (yap::IPacket& packet) { yap::ID staticID = packet.ReadID (); yap::Gender gender = static_cast<yap::Gender>(packet.ReadUChar ()); bool shiny = packet.ReadBool (); yap::ID nature = packet.ReadID (); yap::uint experience = packet.ReadUInt (); // Read the Pokemon's IV value yap::UInt16 hpIV = packet.ReadUInt16 (); yap::UInt16 attackIV = packet.ReadUInt16 (); yap::UInt16 defenseIV = packet.ReadUInt16 (); yap::UInt16 specialAttackIV = packet.ReadUInt16 (); yap::UInt16 specialDefenseIV = packet.ReadUInt16 (); yap::UInt16 speedIV = packet.ReadUInt16 (); // Set the stats with EV and IV yap::HitPoint hp (hpIV); yap::Attack attack (attackIV); yap::Defense defense (defenseIV); yap::SpecialAttack specialAttack (specialAttackIV); yap::SpecialDefense specialDefense (specialDefenseIV); yap::Speed speed (speedIV); yap::PokemonStat stats ( hp, attack, defense, specialAttack, specialDefense, speed); // Read the Pokemon's move yap::PokemonMoveSet moveSet; yap::UInt8 moveNumber = packet.ReadUChar (); for (int index = 0; index < moveNumber; index++) { yap::PokemonMove* move = new yap::PokemonMove (packet.ReadID ()); yap::UInt8 moveIndex = packet.ReadUChar (); move->SetPP (packet.ReadUInt16 ()); move->SetMaxPP (packet.ReadUInt16 ()); moveSet.AddMove (move, moveIndex); } return new Pokemon ( staticID, stats, gender, shiny, moveSet, nature, experience); }
void frame::convert_hcode_pointer() { if (!is_interpreted_frame()) return; // Adjust hcode pointer to object start u_char* h = hp(); u_char* obj = (u_char*) as_memOop(Universe::object_start((oop*) h)); set_hp(obj); // Save the offset MarkSweep::add_hcode_offset(h - obj); // if (WizardMode) lprintf("[0x%lx+%d]\n", obj, h - obj); }
methodOop frame::method() const { assert(is_interpreted_frame(), "must be interpreter frame"); // First we will check the interpreter frame is valid by checking the frame size. // The interpreter guarantees hp is valid if the frame is at least 4 in size. // (return address, link, receiver, hcode pointer) if (frame_size() < minimum_size_for_deoptimized_frame) return NULL; u_char* h = hp(); if (!Universe::old_gen.contains(h)) return NULL; memOop obj = as_memOop(Universe::object_start((oop*) h)); return obj->is_method() ? methodOop(obj) : NULL; }
ResourceHandler* Component::getResourceHandlerForOurResource(QString name) { ResourceHandler* h = getResourceHandlerWithOwner(name, this); if (h == nullptr) { // Adding an non-existant resource (in an exception-safe way) std::unique_ptr<ResourceHandler> hp(new ResourceHandler(name, this)); resources()[name][this] = hp.get(); h = hp.release(); } return h; }
static void * serviceThread(void * sockdt) { //printf("init new thread\n"); SockData* sd=(SockData*)sockdt; Provider hp(sd->fd, sd->type, sd->persist); if(sd->persist) { hp.listener(); } else { hp.serviceRequest(); } free(sockdt); pthread_exit(0); }
void frame::print() const { std->print("[%s frame: fp = %#lx, sp = %#lx, pc = %#lx", print_name(), fp(), sp(), pc()); if (is_compiled_frame()) { std->print(", nm = %#x", findNMethod(pc())); } else if (is_interpreted_frame()) { std->print(", hp = %#x, method = %#x", hp(), method()); } std->print_cr("]"); if (PrintLongFrames) { for (oop* p = sp(); p < (oop*)fp(); p++) std->print_cr(" - 0x%lx: 0x%lx", p, *p); } }
void P2PGameClient::connectionEvent(net::NetworkTraffic const& e) { LogO("== Netw Connected "+e.peer_address.str()); if (m_state == LOBBY) { boost::mutex::scoped_lock lock(m_mutex); PeerInfo& pi = m_peers[e.peer_address.str()]; pi.address = e.peer_address; pi.peer_id = e.peer_id; pi.connection = PeerInfo::CONNECTED; pi.ping = e.ping; protocol::HandshakePackage hp(m_playerInfo.password); m_client.send(e.peer_id, net::convert(hp), net::PACKET_RELIABLE); // No connection callback here, because player info is not yet received } }
void object::test<3> () { double scale = 1.0; Coordinate p1(0, 0); Coordinate p2(3, 2); Coordinate p3(1, 1); PrecisionModel pm(scale); LineIntersector li(&pm); HotPixel hp(p3, scale, li); ensure(hp.intersects(p1, p2)); }
void testHp() { int sampleNum = 1200; int snpNum = 2; int chrSetNum = 2; int HapNum = 3; std::vector<boost::shared_ptr<short[]> > haps = createHaplotype(HapNum, snpNum); std::vector<int> hapcount; boost::shared_ptr<SHEsis::SHEsisData> data = GenerateHaploData(sampleNum, snpNum, chrSetNum, haps, hapcount); // data->statCount(data->vLabel); SHEsis::Haplotype hp(data); hp.setSilent(false); hp.startHaplotypeAnalysis(); hp.AssociationTest(); }
void Test() { int a[] = { 10, 11, 13, 12, 16, 18, 15, 17, 14, 19 }; int len = sizeof(a) / sizeof(a[0]); Heap<int,Less<int>> hp(a, len); hp.Print(); hp.Push(22); hp.Print(); hp.Push(0); hp.Print(); hp.Pop(); hp.Print(); }
void dynHostResolve(string& name, int& port) { assert( !name.empty() ); assert( !str::contains(name, ':') ); assert( str::startsWith(name, '#') ); string s = dynHostNames.get(name); if( s.empty() ) { name.clear(); return; } assert( !str::startsWith(s, '#') ); HostAndPort hp(s); if( hp.hasPort() ) { port = hp.port(); log() << "info: dynhost in:" << name << " out:" << hp.toString() << endl; } name = hp.host(); }
inline void fromCoordAToCoordB(const Vec3r&p, Vec3r& q, const real transform[4][4]) { HVec3r hp(p); HVec3r hq(0, 0, 0, 0); for (unsigned i = 0; i < 4; i++) for (unsigned j = 0; j < 4; j++) hq[i] += transform[i][j] * hp[j]; if(hq[3] == 0) { q = p; return; } for (unsigned k = 0; k < 3; k++) q[k] = hq[k] / hq[3]; }
void ControlClient::connectToTcpDispatcher() { m_gate->writeUInt32(ControlProto::REPLY_OK); // Read a hostname. StringStorage connectString; m_gate->readUTF8(&connectString); // Read a dispatcher name. StringStorage dispatcherName; m_gate->readUTF8(&dispatcherName); // Read a keyword. StringStorage keyword; m_gate->readUTF8(&keyword); // Read a connection id. UINT32 connectionId = m_gate->readUInt32(); // Parse host and port from connection string. AnsiStringStorage connectStringAnsi(&connectString); HostPath hp(connectStringAnsi.getString(), 5900); if (!hp.isValid()) { return; } StringStorage host; AnsiStringStorage ansiHost(hp.getVncHost()); ansiHost.toStringStorage(&host); // Converting got TCHAR strings to AnsiStringStorage format AnsiStringStorage ansiDispName(&dispatcherName); AnsiStringStorage ansiKeyword(&keyword); // Make connection in separate thread. ConnectToTcpDispatcherThread *newConnectionThread = new ConnectToTcpDispatcherThread(host.getString(), hp.getVncPort(), &ansiDispName, connectionId, &ansiKeyword, m_rfbClientManager, m_log); ZombieKiller::getInstance()->addZombie(newConnectionThread); }
bool InterpretedPrim_Cache::has_failure_code() const { CodeIterator c(hp()); switch (c.code()) { case Bytecodes::prim_call_failure: case Bytecodes::prim_call_failure_lookup: case Bytecodes::prim_call_self_failure: case Bytecodes::prim_call_self_failure_lookup: return true; case Bytecodes::prim_call: case Bytecodes::prim_call_lookup: case Bytecodes::prim_call_self_lookup: case Bytecodes::prim_call_self: return false; default: fatal("Wrong bytecode"); } return false; }
symbolOop InterpretedPrim_Cache::name() const { CodeIterator c(hp()); switch (c.code()) { case Bytecodes::prim_call: case Bytecodes::prim_call_failure: case Bytecodes::prim_call_self: case Bytecodes::prim_call_self_failure: return primitives::lookup((fntype) c.word_at(1))->selector(); case Bytecodes::prim_call_lookup: case Bytecodes::prim_call_failure_lookup: case Bytecodes::prim_call_self_lookup: case Bytecodes::prim_call_self_failure_lookup: return symbolOop(c.oop_at(1)); default: fatal("Wrong bytecode"); } return NULL; }
void BaseProjectPartBuilder::setIncludePaths(const QStringList &includePaths) { m_templatePart->headerPaths.clear(); foreach (const QString &includeFile, includePaths) { ProjectPartHeaderPath hp(includeFile, ProjectPartHeaderPath::IncludePath); // The simple project managers are utterly ignorant of frameworks on OSX, and won't report // framework paths. The work-around is to check if the include path ends in ".framework", // and if so, add the parent directory as framework path. if (includeFile.endsWith(QLatin1String(".framework"))) { const int slashIdx = includeFile.lastIndexOf(QLatin1Char('/')); if (slashIdx != -1) { hp = ProjectPartHeaderPath(includeFile.left(slashIdx), ProjectPartHeaderPath::FrameworkPath); } } m_templatePart->headerPaths += hp; }
int main() { // Videos Video lotr("Lord of the Rings", Video::REGULAR); Video hp("Harry Potter", Video::CHILDRENS); // Rentals of these movies Rental r1(lotr, 10); Rental r2(hp, 5); // Customer with some rentals Customer customer("Fred"); customer.addRental(r1); customer.addRental(r2); // Output customer statement outputCustomerStatement(customer) return 0; }