bool OnlineUnlockStatus::applyKeyFile (String keyFileContent) { KeyFileUtils::KeyFileData data; data = KeyFileUtils::getDataFromKeyFile (KeyFileUtils::getXmlFromKeyFile (keyFileContent, getPublicKey())); if (data.licensee.isNotEmpty() && data.email.isNotEmpty() && doesProductIDMatch (data.appID)) { setUserEmail (data.email); status.setProperty (keyfileDataProp, keyFileContent, nullptr); status.removeProperty (data.keyFileExpires ? expiryTimeProp : unlockedProp, nullptr); var actualResult (0), dummyResult (1.0); var v (machineNumberAllowed (data.machineNumbers, getLocalMachineIDs())); actualResult.swapWith (v); v = machineNumberAllowed (StringArray ("01"), getLocalMachineIDs()); dummyResult.swapWith (v); jassert (! dummyResult); if (data.keyFileExpires) { if ((! dummyResult) && actualResult) status.setProperty (expiryTimeProp, data.expiryTime.toMilliseconds(), nullptr); return getExpiryTime().toMilliseconds() > 0; } if ((! dummyResult) && actualResult) status.setProperty (unlockedProp, actualResult, nullptr); return isUnlocked(); } return false; }
skillReturnType Skill::canCast(Creature &caster) { if (checkCost(caster) == false) { return SKILL_FAIL_COST; } else if (isUnlocked() == false) { return SKILL_NOT_UNLOCKED; } else { return SKILL_SUCCESS; } }
bool EntryData::isWritable() const { Notebook *b = book(); if (!b || b->isReadOnly()) return false; if (isUnlocked()) return true; if (isEmpty()) return true; return isRecent() && App::instance()->cui()->match(cui_); }
/* load ******************************************************************************************* - loads a file into the device ************************************************************************************************ */ void LoadableDevice_impl::load (CF::FileSystem_ptr fs, const char *fileName, CF::LoadableDevice::LoadType loadKind) throw (CORBA::SystemException, CF::Device::InvalidState, CF::LoadableDevice::InvalidLoadKind, CF::InvalidFileName, CF::LoadableDevice::LoadFail) { //CF::File_ptr fileToLoad; // file pointer bool readOnly = true; // read only flag // verify that the device is in a valid state for loading if (!isUnlocked () || isDisabled ()) { throw (CF::Device:: InvalidState ("Cannot load. System is either LOCKED, SHUTTING DOWN or DISABLED.")); } // verify that the loadKind is supported (only executable is supported by this version) if (loadKind != CF::LoadableDevice::EXECUTABLE) { throw CF::LoadableDevice::InvalidLoadKind (); } // verify the file name exists in the file system and get a pointer to it // NOTE: in this context, this step is redundant; the 'installApplication' method // already performs this existence check /* if (!fs->exists ((char *) fileName)) throw (CF::InvalidFileName (CF::CFENOENT, "Cannot load. File name is invalid.")); */ // pass fileToLoad to API (device specific, not currently implemented) // check if file loaded correctly //if (API unsuccessful) //{ // throw(CF::LoadableDevice::LoadFail("Cannot load. Attempt to load to device unsuccessful.")); // return; //} // add filename to loadedfiles. If it's been already loaded, then increment its counter incrementFile (fileName); //CORBA::release (fileToLoad); }
/* execute ***************************************************************** - executes a process on the device ************************************************************************* */ CF::ExecutableDevice::ProcessID_Type ExecutableDevice_impl::execute ( const char* name, const CF::Properties& options, const CF::Properties& parameters) throw (CORBA::SystemException, CF::Device::InvalidState, CF::ExecutableDevice::InvalidFunction, CF::ExecutableDevice::InvalidParameters, CF::ExecutableDevice::InvalidOptions, CF::InvalidFileName, CF::ExecutableDevice::ExecuteFail) { CORBA::TypeCode_var tc; // CORBA type code const char* tempStr; // temporary character string CF::ExecutableDevice::ProcessID_Type PID; // process ID int size = 2 * parameters.length () + 2; // length of the POSIX argv arguments char** argv = new char *[size]; // POSIX arguments CORBA::ULong stackSize, priority; // CORBA unsigned longs for options storage // verify device is in the correct state if (!isUnlocked () || isDisabled ()) { DEBUG(5, ExecutableDevice_impl, "Cannot execute. System is either LOCKED, SHUTTING DOWN or DISABLED.") throw (CF::Device::InvalidState("Cannot execute. System is either LOCKED, SHUTTING DOWN or DISABLED.")); } priority = 0; // this is the default value for the priority (it's actually meaningless in this version) stackSize = 4096; // this is the default value for the stacksize (it's actually meaningless in this version) { // verify valid options, both STACK_SIZE_ID and PRIORITY_ID must have unsigned-long types CF::Properties invalidOptions; invalidOptions.length(0); for (unsigned i = 0; i < options.length (); i++) { tc = options[i].value.type (); // extract priority and stack size from the options list if (strcmp (options[i].id, CF::ExecutableDevice::PRIORITY_ID)) { if (tc->kind () == CORBA::tk_ulong) { options[i].value >>= priority; } else { LOG_ERROR(ExecutableDevice_impl, "Incorrect type provided for option PRIORITY"); invalidOptions.length(invalidOptions.length() + 1); invalidOptions[invalidOptions.length() - 1] = options[i]; } } else if (strcmp (options[i].id, CF::ExecutableDevice::STACK_SIZE_ID)) {
bool Campaign::reset (bool unlockFirstMap) { const bool alreadyUnlocked = isUnlocked(); if (!alreadyUnlocked) { Log::error(LOG_CAMPAIGN, "could not reset campaign '%s' - not yet unlocked", getId().c_str()); return false; } if (!_persister->resetCampaign(this)) { Log::error(LOG_CAMPAIGN, "failed to reset the campaign"); return false; } resetMaps(); if (unlockFirstMap) unlock(); return true; }
bool Campaign::unlock () { // if we already played this campaign, we will not unlock any other map if (isUnlocked()) { Log::info(LOG_CAMPAIGN, "no unlocking needed for campaign '%s'", getId().c_str()); return false; } CampaignMapPtr map = getMap(1); if (!map) { Log::info(LOG_CAMPAIGN, "no map in campaign '%s'", getId().c_str()); return false; } Log::info(LOG_CAMPAIGN, "unlocked campaign '%s'", getId().c_str()); map->unlock(); _currentMap = 1; return true; }
// Processes a single CLatentEffect* and finds the expression to evaluate for // activation/deactivation and attempts to apply bool CLatentEffectContainer::ProcessLatentEffect(CLatentEffect& latentEffect) { // Our default case un-finds our latent prevent us from toggling a latent we don't have programmed auto expression = false; auto latentFound = true; // find the latent type from the enum and find the expression to tests againts switch (latentEffect.GetConditionsID()) { case LATENT_HP_UNDER_PERCENT: expression = ((float)m_POwner->health.hp / m_POwner->health.maxhp) * 100 <= latentEffect.GetConditionsValue(); break; case LATENT_HP_OVER_PERCENT: expression = ((float)m_POwner->health.hp / m_POwner->health.maxhp) * 100 >= latentEffect.GetConditionsValue(); break; case LATENT_HP_UNDER_TP_UNDER_100: expression = ((float)m_POwner->health.hp / m_POwner->health.maxhp) * 100 <= latentEffect.GetConditionsValue() && m_POwner->health.tp < 1000; break; case LATENT_HP_OVER_TP_UNDER_100: expression = ((float)m_POwner->health.hp / m_POwner->health.maxhp) * 100 >= latentEffect.GetConditionsValue() && m_POwner->health.tp < 1000; break; case LATENT_MP_UNDER_PERCENT: expression = m_POwner->health.maxmp && (float)(m_POwner->health.mp / m_POwner->health.maxmp) * 100 <= latentEffect.GetConditionsValue(); break; case LATENT_MP_UNDER: expression = m_POwner->health.mp <= latentEffect.GetConditionsValue(); break; case LATENT_TP_UNDER: expression = m_POwner->health.tp < latentEffect.GetConditionsValue(); break; case LATENT_TP_OVER: expression = m_POwner->health.tp > latentEffect.GetConditionsValue(); break; case LATENT_SUBJOB: expression = m_POwner->GetSJob() == latentEffect.GetConditionsValue(); break; case LATENT_PET_ID: expression = m_POwner->PPet != nullptr && m_POwner->PPet->objtype == TYPE_PET && ((CPetEntity*)m_POwner->PPet)->m_PetID == latentEffect.GetConditionsValue(); break; case LATENT_WEAPON_DRAWN: expression = m_POwner->animation == ANIMATION_ATTACK; break; case LATENT_WEAPON_SHEATHED: expression = m_POwner->animation != ANIMATION_ATTACK; break; case LATENT_STATUS_EFFECT_ACTIVE: expression = m_POwner->StatusEffectContainer->HasStatusEffect((EFFECT)latentEffect.GetConditionsValue()); break; case LATENT_NO_FOOD_ACTIVE: expression = !m_POwner->StatusEffectContainer->HasStatusEffect(EFFECT_FOOD); break; case LATENT_PARTY_MEMBERS: expression = m_POwner->PParty != nullptr && latentEffect.GetConditionsValue() <= m_POwner->PParty->members.size(); break; case LATENT_PARTY_MEMBERS_IN_ZONE: { auto inZone = 0; if (m_POwner->PParty != nullptr) { for (auto member : m_POwner->PParty->members) { if (member->getZone() == m_POwner->getZone()) { ++inZone; } } } expression = latentEffect.GetConditionsValue() <= inZone; break; } case LATENT_AVATAR_IN_PARTY: if (m_POwner->PParty != nullptr) { for (auto member : m_POwner->PParty->members) { if (member->PPet != nullptr) { auto PPet = (CPetEntity*)member->PPet; if (PPet->m_PetID == latentEffect.GetConditionsValue() && PPet->PAI->IsSpawned()) { expression = true; break; } } } } else if (m_POwner->PParty == nullptr && m_POwner->PPet != nullptr) { auto PPet = (CPetEntity*)m_POwner->PPet; if (PPet->m_PetID == latentEffect.GetConditionsValue() && !PPet->isDead()) { expression = true; } } break; case LATENT_JOB_IN_PARTY: if (m_POwner->PParty != nullptr) { for (auto member : m_POwner->PParty->members) { if (member->id != m_POwner->id) { if (member->GetMJob() == latentEffect.GetConditionsValue()) { expression = true; break; } } } } break; case LATENT_ZONE: expression = latentEffect.GetConditionsValue() == m_POwner->getZone(); break; case LATENT_SYNTH_TRAINEE: // todo: figure this out break; case LATENT_SONG_ROLL_ACTIVE: expression = m_POwner->StatusEffectContainer->HasStatusEffectByFlag(EFFECTFLAG_ROLL | EFFECTFLAG_SONG); break; case LATENT_TIME_OF_DAY: { uint32 VanadielHour = CVanaTime::getInstance()->getHour(); switch (latentEffect.GetConditionsValue()) { case 0: //daytime: 06:00 to 18:00 expression = VanadielHour >= 6 && VanadielHour < 18; break; case 1: //nighttime: 18:00 to 06:00 expression = VanadielHour >= 18 || VanadielHour < 6; break; case 2: //dusk - dawn: 17:00 to 7:00 expression = VanadielHour >= 17 || VanadielHour < 7; break; } break; } case LATENT_HOUR_OF_DAY: { uint32 VanadielHour = CVanaTime::getInstance()->getHour(); switch (latentEffect.GetConditionsValue()) { case 1: //new day expression = VanadielHour == 4; break; case 2: //dawn expression = VanadielHour >= 6 && VanadielHour < 7; break; case 3: //day expression = VanadielHour >= 7 && VanadielHour < 17; break; case 4: //dusk expression = VanadielHour >= 16 && VanadielHour < 18; break; case 5: //evening expression = VanadielHour >= 18 && VanadielHour < 20; break; case 6: //dead of night expression = VanadielHour >= 20 || VanadielHour < 4; break; } break; } case LATENT_FIRESDAY: expression = CVanaTime::getInstance()->getWeekday() == FIRESDAY; break; case LATENT_EARTHSDAY: expression = CVanaTime::getInstance()->getWeekday() == EARTHSDAY; break; case LATENT_WATERSDAY: expression = CVanaTime::getInstance()->getWeekday() == WATERSDAY; break; case LATENT_WINDSDAY: expression = CVanaTime::getInstance()->getWeekday() == WINDSDAY; break; case LATENT_DARKSDAY: expression = CVanaTime::getInstance()->getWeekday() == DARKSDAY; break; case LATENT_ICEDAY: expression = CVanaTime::getInstance()->getWeekday() == ICEDAY; break; case LATENT_LIGHTNINGSDAY: expression = CVanaTime::getInstance()->getWeekday() == LIGHTNINGDAY; break; case LATENT_LIGHTSDAY: expression = CVanaTime::getInstance()->getWeekday() == LIGHTSDAY; break; case LATENT_MOON_PHASE: { uint32 MoonPhase = CVanaTime::getInstance()->getMoonPhase(); uint32 MoonDirection = CVanaTime::getInstance()->getMoonDirection(); //directions: 1 = waning, 2 = waxing, 0 = neither switch (latentEffect.GetConditionsValue()) { case 0: //New Moon - 10% waning -> 5% waxing expression = MoonPhase <= 5 || (MoonPhase <= 10 && MoonDirection == 1); break; case 1: //Waxing Crescent - 7% -> 38% waxing expression = MoonPhase >= 7 && MoonPhase <= 38 && MoonDirection == 2; break; case 2: //First Quarter - 40%% -> 55% waxing expression = MoonPhase >= 40 && MoonPhase <= 55 && MoonDirection == 2; break; case 3: //Waxing Gibbous - 57% -> 88% expression = MoonPhase >= 57 && MoonPhase <= 88 && MoonDirection == 2; break; case 4: //Full Moon - waxing 90% -> waning 95% expression = MoonPhase >= 95 || (MoonPhase >= 90 && MoonDirection == 2); break; case 5: //Waning Gibbous - 93% -> 62% expression = MoonPhase >= 62 && MoonPhase <= 93 && MoonDirection == 1; break; case 6: //Last Quarter - 60% -> 45% expression = MoonPhase >= 45 && MoonPhase <= 60 && MoonDirection == 1; break; case 7: //Waning Crescent - 43% -> 12% expression = MoonPhase >= 12 && MoonPhase <= 43 && MoonDirection == 1; break; } break; } case LATENT_JOB_MULTIPLE_5: expression = m_POwner->GetMLevel() % 5 == 0; break; case LATENT_JOB_MULTIPLE_10: expression = m_POwner->GetMLevel() % 10 == 0; break; case LATENT_JOB_MULTIPLE_13_NIGHT: expression = m_POwner->GetMLevel() % 13 == 0 && CVanaTime::getInstance()->SyncTime() == TIME_NIGHT; break; case LATENT_JOB_LEVEL_ODD: expression = m_POwner->GetMLevel() % 2 == 1; break; case LATENT_JOB_LEVEL_EVEN: expression = m_POwner->GetMLevel() % 2 == 0; break; case LATENT_WEAPON_DRAWN_HP_UNDER: expression = m_POwner->health.hp < latentEffect.GetConditionsValue() && m_POwner->animation == ANIMATION_ATTACK; break; case LATENT_MP_UNDER_VISIBLE_GEAR: //TODO: figure out if this is actually right //CItemArmor* head = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_HEAD])); //CItemArmor* body = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_BODY])); //CItemArmor* hands = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_HANDS])); //CItemArmor* legs = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_LEGS])); //CItemArmor* feet = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_FEET])); //int32 visibleMp = 0; //visibleMp += (head ? head->getModifier(Mod::MP) : 0); //visibleMp += (body ? body->getModifier(Mod::MP) : 0); //visibleMp += (hands ? hands->getModifier(Mod::MP) : 0); //visibleMp += (legs ? legs->getModifier(Mod::MP) : 0); //visibleMp += (feet ? feet->getModifier(Mod::MP) : 0); //TODO: add mp percent too //if ((float)( mp / ((m_POwner->health.mp - m_POwner->health.modmp) + (m_POwner->PMeritPoints->GetMerit(MERIT_MAX_MP)->count * 10 ) + // visibleMp) ) <= m_LatentEffectList.at(i)->GetConditionsValue()) //{ // m_LatentEffectList.at(i)->Activate(); //} //else //{ // m_LatentEffectList.at(i)->Deactivate(); //} break; case LATENT_HP_OVER_VISIBLE_GEAR: //TODO: figure out if this is actually right //CItemArmor* head = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_HEAD])); //CItemArmor* body = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_BODY])); //CItemArmor* hands = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_HANDS])); //CItemArmor* legs = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_LEGS])); //CItemArmor* feet = (CItemArmor*)(m_POwner->getStorage(LOC_INVENTORY)->GetItem(m_POwner->equip[SLOT_FEET])); //int32 visibleHp = 0; //visibleHp += (head ? head->getModifier(Mod::HP) : 0); //visibleHp += (body ? body->getModifier(Mod::HP) : 0); //visibleHp += (hands ? hands->getModifier(Mod::HP) : 0); //visibleHp += (legs ? legs->getModifier(Mod::HP) : 0); //visibleHp += (feet ? feet->getModifier(Mod::HP) : 0); //TODO: add mp percent too //if ((float)( hp / ((m_POwner->health.hp - m_POwner->health.modhp) + (m_POwner->PMeritPoints->GetMerit(MERIT_MAX_HP)->count * 10 ) + // visibleHp) ) <= m_LatentEffectList.at(i)->GetConditionsValue()) //{ // m_LatentEffectList.at(i)->Activate(); //} //else //{ // m_LatentEffectList.at(i)->Deactivate(); //} break; case LATENT_WEAPON_BROKEN: { auto slot = latentEffect.GetSlot(); auto item = (CItemWeapon*)m_POwner->getEquip((SLOTTYPE)slot); switch (slot) { case SLOT_MAIN: case SLOT_SUB: case SLOT_RANGED: expression = item != nullptr && item->isUnlocked(); break; } break; } case LATENT_IN_DYNAMIS: expression = m_POwner->isInDynamis(); break; case LATENT_IN_ASSAULT: expression = m_POwner->isInAssault(); break; case LATENT_FOOD_ACTIVE: expression = m_POwner->StatusEffectContainer->HasStatusEffect(EFFECT_FOOD) && m_POwner->StatusEffectContainer->GetStatusEffect(EFFECT_FOOD)->GetSubID() == latentEffect.GetConditionsValue(); break; case LATENT_JOB_LEVEL_BELOW: expression = m_POwner->GetMLevel() < latentEffect.GetConditionsValue(); break; case LATENT_JOB_LEVEL_ABOVE: expression = m_POwner->GetMLevel() >= latentEffect.GetConditionsValue(); break; case LATENT_WEATHER_ELEMENT: expression = latentEffect.GetConditionsValue() == zoneutils::GetWeatherElement(battleutils::GetWeather((CBattleEntity*)m_POwner, false)); break; case LATENT_NATION_CONTROL: { //player is logging in/zoning if (m_POwner->loc.zone == nullptr) { break; } auto region = m_POwner->loc.zone->GetRegionID(); auto hasSignet = m_POwner->StatusEffectContainer->HasStatusEffect(EFFECT_SIGNET); auto hasSanction = m_POwner->StatusEffectContainer->HasStatusEffect(EFFECT_SANCTION); auto hasSigil = m_POwner->StatusEffectContainer->HasStatusEffect(EFFECT_SIGIL); switch (latentEffect.GetConditionsValue()) { case 0: //under own nation's control expression = region < 28 && conquest::GetRegionOwner(region) == m_POwner->profile.nation && (hasSignet || hasSanction || hasSigil); break; case 1: //outside of own nation's control expression = region < 28 && m_POwner->profile.nation != conquest::GetRegionOwner(region) && (hasSignet || hasSanction || hasSigil); break; } break; } case LATENT_ZONE_HOME_NATION: { //player is logging in/zoning if (m_POwner->loc.zone == nullptr) { break; } auto PZone = m_POwner->loc.zone; auto region = (REGIONTYPE)latentEffect.GetConditionsValue(); switch (region) { case REGION_SANDORIA: expression = m_POwner->profile.nation == 0 && PZone->GetRegionID() == region; break; case REGION_BASTOK: expression = m_POwner->profile.nation == 1 && PZone->GetRegionID() == region; break; case REGION_WINDURST: expression = m_POwner->profile.nation == 2 && PZone->GetRegionID() == region; break; default: break; } break; } case LATENT_MP_OVER: expression = m_POwner->health.mp >= latentEffect.GetConditionsValue(); break; case LATENT_WEAPON_DRAWN_MP_OVER: expression = m_POwner->health.mp > latentEffect.GetConditionsValue() && m_POwner->animation == ANIMATION_ATTACK; break; case LATENT_ELEVEN_ROLL_ACTIVE: expression = m_POwner->StatusEffectContainer->CheckForElevenRoll(); break; default: latentFound = false; ShowWarning("Latent ID %d unhandled in ProcessLatentEffect\n", latentEffect.GetConditionsID()); break; } // if we did not hit the default case, attempt to apply the latent effect based on the expression if (latentFound) { return ApplyLatentEffect(latentEffect, expression); } return false; }
std::string ClientAchievement::getDecentName() const { return getName() + (isUnlocked() ? "" : std::string(" (") + std::to_string(getCurrentProgress()) + "/" + std::to_string(getRequiredProgress()) + ")"); }
std::string ClientAchievement::getPrettyName() const { return (isUnlocked() ? std::string("✔ ") : std::string("✘ ")) + getDecentName(); }