void HostileReference::setAccessibleState(bool isAccessible) { if (iAccessible != isAccessible) { iAccessible = isAccessible; ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ASSECCIBLE_STATUS, this); fireStatusChanged(event); } }
void HostileReference::setOnlineOfflineState(bool pIsOnline) { if (iOnline != pIsOnline) { iOnline = pIsOnline; if (!iOnline) setAccessibleState(false); // if not online that not accessable as well ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ONLINE_STATUS, this); fireStatusChanged(event); } }
void HostilReference::addThreat(float pMod) { iThreat += pMod; // the threat is changed. Source and target unit have to be availabe // if the link was cut before relink it again if(!isOnline()) updateOnlineStatus(); if(pMod != 0.0f) fireStatusChanged(ThreatRefStatusChangeEvent(UEV_THREAT_REF_THREAT_CHANGE, this, pMod)); if(isValid() && pMod >= 0) { Unit* victim_owner = getTarget()->GetCharmerOrOwner(); if(victim_owner && victim_owner->isAlive()) getSource()->addThreat(victim_owner, 0.0f); // create a threat to the owner of a pet, if the pet attacks } }
void HostileReference::addThreat(float modThreat) { iThreat += modThreat; if(!isOnline()) updateOnlineStatus(); if(modThreat != 0.0f) { ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, modThreat); fireStatusChanged(event); } if(isValid() && modThreat >= 0.0f) { Unit* victimOwner = getTarget()->GetCharmerOrOwner(); if(victimOwner && victimOwner->isAlive()) getSource()->addThreat(victimOwner, 0.0f); // create a threat to the owner of a pet, if the pet attacks } }
void HostileReference::addThreat(float modThreat) { iThreat += modThreat; // the threat is changed. Source and target unit have to be available // if the link was cut before relink it again if (!isOnline()) updateOnlineStatus(); if (modThreat != 0.0f) { ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, modThreat); fireStatusChanged(event); } if (isValid() && modThreat >= 0.0f) { Unit* victimOwner = getTarget()->GetCharmerOrOwner(); if (victimOwner && victimOwner->IsAlive()) GetSource()->addThreat(victimOwner, 0.0f); // create a threat to the owner of a pet, if the pet attacks } }
QString InstalledPackages::setPackageVersionPath(const QString& package, const Version& version, const QString& directory) { this->mutex.lock(); QString err; InstalledPackageVersion* ipv = this->findNoCopy(package, version); if (!ipv) { ipv = new InstalledPackageVersion(package, version, directory); this->data.insert(package + "/" + version.getVersionString(), ipv); err = saveToRegistry(ipv); } else { ipv->setPath(directory); err = saveToRegistry(ipv); } this->mutex.unlock(); fireStatusChanged(package, version); return err; }
QString InstalledPackages::readRegistryDatabase() { // qDebug() << "start reading registry database"; // "data" is only used at the bottom of this method QString err; WindowsRegistry packagesWR; LONG e; err = packagesWR.open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Npackd\\Npackd\\Packages", false, KEY_READ, &e); QList<InstalledPackageVersion*> ipvs; if (e == ERROR_FILE_NOT_FOUND || e == ERROR_PATH_NOT_FOUND) { err = ""; } else if (err.isEmpty()) { QStringList entries = packagesWR.list(&err); for (int i = 0; i < entries.count(); ++i) { QString name = entries.at(i); int pos = name.lastIndexOf("-"); if (pos <= 0) continue; QString packageName = name.left(pos); if (!Package::isValidName(packageName)) continue; QString versionName = name.right(name.length() - pos - 1); Version version; if (!version.setVersion(versionName)) continue; WindowsRegistry entryWR; err = entryWR.open(packagesWR, name, KEY_READ); if (!err.isEmpty()) continue; QString p = entryWR.get("Path", &err).trimmed(); if (!err.isEmpty()) continue; QString dir; if (p.isEmpty()) dir = ""; else { QDir d(p); if (d.exists()) { dir = p; } else { dir = ""; } } if (dir.isEmpty()) { packagesWR.remove(name); } else { dir = WPMUtils::normalizePath(dir, false); InstalledPackageVersion* ipv = new InstalledPackageVersion( packageName, version, dir); ipv->detectionInfo = entryWR.get("DetectionInfo", &err); if (!err.isEmpty()) { // ignore ipv->detectionInfo = ""; err = ""; } if (!ipv->directory.isEmpty()) { /* qDebug() << "adding " << ipv->package << ipv->version.getVersionString() << "in" << ipv->directory;*/ ipvs.append(ipv); } else { delete ipv; } } } } this->mutex.lock(); qDeleteAll(this->data); this->data.clear(); for (int i = 0; i < ipvs.count(); i++) { InstalledPackageVersion* ipv = ipvs.at(i); this->data.insert(PackageVersion::getStringId(ipv->package, ipv->version), ipv->clone()); } this->mutex.unlock(); for (int i = 0; i < ipvs.count(); i++) { InstalledPackageVersion* ipv = ipvs.at(i); fireStatusChanged(ipv->package, ipv->version); } qDeleteAll(ipvs); // qDebug() << "stop reading"; return err; }
void HostilReference::removeReference() { invalidate(); fireStatusChanged(ThreatRefStatusChangeEvent(UEV_THREAT_REF_REMOVE_FROM_LIST, this)); }