void DQmlFileTracker::onDirChange(const QString &path) { qCDebug(DQML_LOG) << "change in directory" << path; QString id = idFromPath(path); if (id.isEmpty()) { untrack(id); qCDebug(DQML_LOG) << " - no entry, cancel tracking..."; return; } Entry &entry = m_set[id]; QDir dir(path); QDirIterator iterator(dir); QHash<QString, quint64> currentContent; while (iterator.hasNext()) { iterator.next(); QFileInfo i = iterator.fileInfo(); if (i.isFile() && m_suffixes.contains(i.suffix().toLower())) { QString name = i.fileName(); quint64 time = i.lastModified().toMSecsSinceEpoch(); currentContent[name] = time; } } QSet<QString> allPaths = QSet<QString>::fromList(currentContent.keys()).unite(QSet<QString>::fromList(entry.content.keys())); foreach (QString p, allPaths) { bool was = entry.content.contains(p); bool is = currentContent.contains(p); if (was && is) { // If file was there before and is still there, check match the last modified // timestamp and emit fileChange if it has been modified.. if (currentContent.value(p) > entry.content.value(p)) { qCDebug(DQML_LOG) << " - changed:" << id << p; emit fileChanged(id, path, p); } } else if (is) { // File is there now, but wasn't before -> added.. qCDebug(DQML_LOG) << " - added:" << id << p; #ifdef Q_OS_LINUX m_watcher.addPath(QFileInfo(path + QStringLiteral("/") + p).canonicalFilePath()); #endif emit fileAdded(id, path, p); } else if (was) { // file was there, but isn't anymore -> removed qCDebug(DQML_LOG) << " - removed:" << id << p; #ifdef Q_OS_LINUX // Need to use absoluteFilePath here as the file is gone and // canonicalFilePath() will return a null string. m_watcher.removePath(QFileInfo(path + QStringLiteral("/") + p).absoluteFilePath()); #endif emit fileRemoved(id, path, p); } }
void Object::destroy() throw() { GC::collect_mutex.lock(); // If another thread just dereferenced a weak pointer to this // object, we might now have references. Now that we have the // lock, check the refcount again. if (SDL_AtomicGet(&refcount) > 0) { GC::collect_mutex.unlock(); return; } SDL_AtomicSet(&refcount, 0); untrack(); weakptrbase* cur = weak; weakptrbase* old; while (cur) { old = cur; cur = cur->next; old->set_ref(NULL); } // Avoid stack overflow. if (trashlevel < max_trashlevel) { ++trashlevel; delete this; if (trashlevel == 1) { while (!trashcan.empty()) { Object* op = static_cast<Object*>(trashcan.next); op->remove(); delete op; } } --trashlevel; } else { moveto(&trashcan); } GC::collect_mutex.unlock(); }
void updateTargetTracking( GameEntity *ent ) { unsigned long targetcat = 0; trace_t tr; vec3_t forward, endpos, dir; float radarrange = 0; bool buildings = false, groundinstallations = false; GameEntity *test; float cone = 0.0f; // Com_Printf( "updateTargetTracking for %s\n", ent->client->pers.netname ); // what can we lock on ? if( ent->client_->ps_.ONOFF & OO_RADAR_AIR ) { targetcat = CAT_PLANE|CAT_HELO; radarrange = availableVehicles[ent->client_->vehicle_].radarRange; cone = availableVehicles[ent->client_->vehicle_].trackCone; } else if( ent->client_->ps_.ONOFF & OO_RADAR_GROUND ) { targetcat = CAT_GROUND|CAT_BOAT; buildings = true; groundinstallations = true; radarrange = availableVehicles[ent->client_->vehicle_].radarRange2; cone = availableVehicles[ent->client_->vehicle_].trackCone2; } if( !targetcat ) { if( ent->client_->ps_.stats[STAT_LOCKINFO] ) untrack(ent); return; } // weapon range and vehicle direction if( (availableVehicles[ent->client_->vehicle_].cat & CAT_GROUND) || (availableVehicles[ent->client_->vehicle_].cat & CAT_BOAT)) { vec3_t right, up, temp; AngleVectors( ent->client_->ps_.vehicleAngles, forward, right, up ); RotatePointAroundVector( temp, up, forward, ent->client_->ps_.turretAngle ); CrossProduct( up, temp, right ); RotatePointAroundVector( dir, right, temp, ent->client_->ps_.gunAngle ); VectorCopy( dir, forward ); } else { VectorCopy( ent->s.angles, dir ); AngleVectors( dir, forward, 0, 0 ); } // no target yet if( !ent->tracktarget_ ) { VectorMA( ent->r.currentOrigin, radarrange, forward, endpos ); SV_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, endpos, ent->s.number, MASK_ALL, false ); // nothing found if( tr.entityNum == ENTITYNUM_NONE ) return; // found something test = theLevel.getEntity(tr.entityNum);// &g_entities[tr.entityNum]; if( test->s.eType == ET_VEHICLE && test->client_ && (availableVehicles[test->client_->vehicle_].cat & targetcat) ) { track(ent, test); } else if( test->s.eType == ET_MISC_VEHICLE ) { if( (test->s.modelindex == 255 && groundinstallations) || // ground installations (availableVehicles[test->s.modelindex].cat & targetcat) ) track(ent, test); } else { if( buildings ) { if( test->s.eType == ET_EXPLOSIVE && test->takedamage_ ) track(ent, test); } else { return; } } } else { // update existing target vec3_t diff; float dot, dist; int actualcat = 0; if( ent->tracktarget_->s.eType == ET_EXPLOSIVE ) { vec3_t mid; actualcat = CAT_GROUND; VectorAdd( ent->tracktarget_->r.absmax, ent->tracktarget_->r.absmin, mid ); VectorScale( mid, 0.5f, mid ); VectorSubtract( mid, ent->r.currentOrigin, diff ); } else { if( ent->tracktarget_->s.eType == ET_MISC_VEHICLE ) { if( ent->tracktarget_->s.modelindex == 255 )// groundinstallation { actualcat = CAT_GROUND; groundinstallations = true; } else actualcat = availableVehicles[ent->tracktarget_->s.modelindex].cat; } else if( ent->tracktarget_->s.eType == ET_VEHICLE && ent->tracktarget_->client_ ) { actualcat = availableVehicles[ent->tracktarget_->client_->vehicle_].cat; } VectorSubtract( ent->tracktarget_->r.currentOrigin, ent->r.currentOrigin, diff ); } if( !actualcat ) { untrack(ent); return; } // check within range dist = VectorNormalize( diff ); if( dist > radarrange ) { untrack(ent); return; } // check within cone dot = DotProduct( forward, diff ); if( dot < cone ) { untrack(ent); return; } else if( dot < availableWeapons[ent->s.weaponIndex].lockcone ) { if( ent->client_->ps_.stats[STAT_LOCKINFO] & LI_LOCKING ) unlock(ent); ent->locktime_ = theLevel.time_; return; } // check LOS VectorMA( ent->r.currentOrigin, dist, diff, endpos ); SV_Trace( &tr, ent->r.currentOrigin, 0, 0, endpos, ent->s.number, MASK_PLAYERSOLID, false ); if( tr.fraction < 1 && tr.entityNum != ent->s.tracktarget ) { untrack(ent); return; } // only weapons that can lock on if( availableWeapons[ent->s.weaponIndex].type != WT_GUIDEDBOMB && availableWeapons[ent->s.weaponIndex].type != WT_ANTIAIRMISSILE && availableWeapons[ent->s.weaponIndex].type != WT_ANTIGROUNDMISSILE && availableWeapons[ent->s.weaponIndex].type != WT_ANTIRADARMISSILE ) { //untrack(ent); if( ent->client_->ps_.stats[STAT_LOCKINFO] & LI_LOCKING ) unlock(ent); return; } // what can we lock on ? targetcat = 0; if( availableWeapons[ent->s.weaponIndex].type == WT_ANTIAIRMISSILE && (ent->client_->ps_.ONOFF & OO_RADAR_AIR) ) { targetcat = CAT_PLANE|CAT_HELO; } else if( availableWeapons[ent->s.weaponIndex].type != WT_ANTIAIRMISSILE && (ent->client_->ps_.ONOFF & OO_RADAR_GROUND) ) { targetcat = CAT_GROUND|CAT_BOAT; buildings = true; } if( !targetcat ) { unlock(ent); //untrack(ent); return; } else if( !(targetcat & actualcat) ) { unlock(ent); return; } // check time if( theLevel.time_ > ent->locktime_ + availableWeapons[ent->s.weaponIndex].lockdelay ) { ent->client_->ps_.stats[STAT_LOCKINFO] |= LI_LOCKING; } // update target if( ent->tracktarget_->client_ && (ent->client_->ps_.stats[STAT_LOCKINFO] & LI_LOCKING) ) { ent->tracktarget_->client_->ps_.stats[STAT_LOCKINFO] |= LI_BEING_LOCKED; } } }