bool CollectionMgr::AddMount(uint32 spellId, MountStatusFlags flags, bool factionMount /*= false*/, bool learned /*= false*/) { Player* player = _owner->GetPlayer(); if (!player) return false; MountEntry const* mount = sDB2Manager.GetMount(spellId); if (!mount) return false; MountDefinitionMap::const_iterator itr = FactionSpecificMounts.find(spellId); if (itr != FactionSpecificMounts.end() && !factionMount) AddMount(itr->second, flags, true, learned); _mounts.insert(MountContainer::value_type(spellId, flags)); // Mount condition only applies to using it, should still learn it. if (mount->PlayerConditionID) { PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mount->PlayerConditionID); if (playerCondition && !ConditionMgr::IsPlayerMeetingCondition(player, playerCondition)) return false; } if (!learned) { if (!factionMount) SendSingleMountUpdate(std::make_pair(spellId, flags)); if (!player->HasSpell(spellId)) player->LearnSpell(spellId, true); } return true; }
struct Mount *AllocAssign (char *alias, char *path) { struct Mount *assign; int alias_len; alias_len = StrLen (alias) + 1; if ((assign = KMalloc (sizeof (struct Mount))) != NULL) { if ((assign->name = KMalloc (alias_len)) != NULL) { StrLCpy (assign->name, alias, alias_len); if (ValidAlias (assign->name) == 0) { if ((assign->pathname = TranslatePathnameAliases (path)) != NULL) { assign->type = MOUNT_ASSIGN; AddMount (assign); return assign; } } KFree (assign->name); } KFree (assign); } return NULL; }
lfLens &lfLens::operator = (const lfLens &other) { lf_free (Maker); Maker = lf_mlstr_dup (other.Maker); lf_free (Model); Model = lf_mlstr_dup (other.Model); MinFocal = other.MinFocal; MaxFocal = other.MaxFocal; MinAperture = other.MinAperture; MaxAperture = other.MaxAperture; lf_free (Mounts); Mounts = NULL; if (other.Mounts) for (int i = 0; other.Mounts [i]; i++) AddMount (other.Mounts [i]); CenterX = other.CenterX; CenterY = other.CenterY; CropFactor = other.CropFactor; AspectRatio = other.AspectRatio; Type = other.Type; lf_free (CalibDistortion); CalibDistortion = NULL; if (other.CalibDistortion) for (int i = 0; other.CalibDistortion [i]; i++) AddCalibDistortion (other.CalibDistortion [i]); lf_free (CalibTCA); CalibTCA = NULL; if (other.CalibTCA) for (int i = 0; other.CalibTCA [i]; i++) AddCalibTCA (other.CalibTCA [i]); lf_free (CalibVignetting); CalibVignetting = NULL; if (other.CalibVignetting) for (int i = 0; other.CalibVignetting [i]; i++) AddCalibVignetting (other.CalibVignetting [i]); lf_free (CalibCrop); CalibCrop = NULL; if (other.CalibCrop) for (int i = 0; other.CalibCrop [i]; i++) AddCalibCrop (other.CalibCrop [i]); lf_free (CalibFov); CalibFov = NULL; if (other.CalibFov) for (int i = 0; other.CalibFov [i]; i++) AddCalibFov (other.CalibFov [i]); return *this; }
lfLens &lfLens::operator = (const lfLens &other) { lf_free (Maker); Maker = lf_mlstr_dup (other.Maker); lf_free (Model); Model = lf_mlstr_dup (other.Model); MinFocal = other.MinFocal; MaxFocal = other.MaxFocal; MinAperture = other.MinAperture; MaxAperture = other.MaxAperture; lf_free (Mounts); Mounts = NULL; if (other.Mounts) for (int i = 0; other.Mounts [i]; i++) AddMount (other.Mounts [i]); CenterX = other.CenterX; CenterY = other.CenterY; RedCCI = other.RedCCI; GreenCCI = other.GreenCCI; BlueCCI = other.BlueCCI; CropFactor = other.CropFactor; Type = other.Type; lf_free (CalibDistortion); CalibDistortion = NULL; if (other.CalibDistortion) for (int i = 0; other.CalibDistortion [i]; i++) AddCalibDistortion (other.CalibDistortion [i]); lf_free (CalibTCA); CalibTCA = NULL; if (other.CalibTCA) for (int i = 0; other.CalibTCA [i]; i++) AddCalibTCA (other.CalibTCA [i]); lf_free (CalibVignetting); CalibVignetting = NULL; if (other.CalibVignetting) for (int i = 0; other.CalibVignetting [i]; i++) AddCalibVignetting (other.CalibVignetting [i]); return *this; }
void CollectionMgr::LoadMounts() { for (auto const& m : _mounts) AddMount(m.first, m.second, false, false); }
int cd_opendevice (int unit, void *ioreq, uint32 flags) { struct FSReq *fsreq = ioreq; struct CDSB *cdsb; struct MountEnviron *me; struct BlkReq blkreq; KPRINTF ("cd_opendevice ()"); if ((cdsb = KMalloc (sizeof (struct CDSB))) != NULL) { me = fsreq->me; if (OpenDevice (me->device_name, me->device_unit, &blkreq, me->device_flags) == 0) { /* FIXME: Shouldn't need it (also in fat handler) */ MemSet (cdsb, 0, sizeof (struct CDSB)); /* Need it as cdsb->validated isn't initialized */ cdsb->device = blkreq.device; cdsb->unitp = blkreq.unitp; cdsb->me = fsreq->me; cdsb->reference_cnt = 0; LIST_INIT (&cdsb->node_list); LIST_INIT (&cdsb->active_filp_list); LIST_INIT (&cdsb->invalid_filp_list); cdsb->root_node.flags = ISO_DIRECTORY; cdsb->root_node.cdsb = cdsb; cdsb->root_node.reference_cnt = 0; if ((cdsb->buf = CreateBuf (cdsb->device, cdsb->unitp, me->buffer_cnt, me->block_size, me->partition_start, me->partition_end, me->writethru_critical, me->writeback_delay, me->max_transfer)) != NULL) { if (KSpawn (CDTask, cdsb, 10, "cd.handler") != -1) { KWait (SIGF_INIT); RWWriteLock (&mountlist_rwlock); cd_device.reference_cnt ++; cdsb->device_mount = MakeMount (cdsb->me, &cd_device, cdsb); AddMount (cdsb->device_mount); RWUnlock (&mountlist_rwlock); fsreq->unitp = cdsb; fsreq->error = 0; fsreq->rc = 0; return 0; } } CloseDevice (&blkreq); } KFree (cdsb); } fsreq->error = IOERR_OPENFAIL; fsreq->rc = -1; KPANIC ("CD OpenDevice FAIL"); return -1; }