ParticleSourceWrapper ParticleManager::createSource(ParticleEffectIndex index) { ParticleEffectPtr eff = this->getEffect(index); ParticleSourceWrapper wrapper; if (eff->getType() == EffectType::Composite) { SCP_vector<ParticleSource*> sources; auto composite = static_cast<effects::CompositeEffect*>(eff); auto& childEffects = composite->getEffects(); // UGH, HACK! To implement the source wrapper we need constant pointers to all sources. // To ensure this we reserve the number of sources we will need (current sources + sources being created) m_sources.reserve(m_sources.size() + childEffects.size()); for (auto& effect : childEffects) { ParticleSource* source = createSource(); source->setEffect(effect); effect->initializeSource(*source); sources.push_back(source); } wrapper = ParticleSourceWrapper(std::move(sources)); } else { ParticleSource* source = createSource(); source->setEffect(eff); eff->initializeSource(*source); wrapper = ParticleSourceWrapper(source); } wrapper.setCreationTimestamp(timestamp()); return wrapper; }
// Compute lifetime intervals and use positions of all intervals by walking // the code bottom-up once. Loops aren't handled yet. void Vxls::buildIntervals() { livein.resize(unit.blocks.size()); intervals.resize(unit.next_vr); for (auto blockIt = blocks.end(); blockIt != blocks.begin();) { auto vlabel = *--blockIt; auto& block = unit.blocks[vlabel]; LiveSet live(unit.next_vr); for (auto s : succs(block)) { if (!livein[s].empty()) live |= livein[s]; } auto& block_range = block_ranges[vlabel]; forEach(live, [&](Vreg vr) { intervals[vr]->add(block_range); }); auto pos = block_range.end; for (auto i = block.code.end(); i != block.code.begin();) { auto& inst = *--i; pos -= 2; DefVisitor dv(live, *this, pos); visit(inst, dv); RegSet implicit_uses, implicit_defs; getEffects(abi, inst, implicit_uses, implicit_defs); implicit_defs.forEach([&](Vreg r) { dv.def(r); }); UseVisitor uv(live, *this, {block_range.start, pos}); visit(inst, uv); implicit_uses.forEach([&](Vreg r) { uv.use(r); }); } livein[vlabel] = live; } for (auto& c : unit.cpool) { auto ivl = intervals[c.second]; if (ivl) { ivl->ranges.back().start = 0; ivl->cns = true; ivl->val = c.first; } } // Each interval's range and use list is backwards; reverse them now. for (auto ivl : intervals) { if (!ivl) continue; assert(!ivl->ranges.empty()); // no empty intervals std::reverse(ivl->uses.begin(), ivl->uses.end()); std::reverse(ivl->ranges.begin(), ivl->ranges.end()); } if (dumpIREnabled(kRegAllocLevel)) { print("after building intervals"); } // todo: t4764262 this should check each root, not just position 0. for (DEBUG_ONLY auto ivl : intervals) { // only constants and physical registers can be live at entry. assert(!ivl || ivl->cns || ivl->vreg.isPhys() || ivl->start() > 0); } assert(check(unit)); }
int TURD::load(GFFFile &gff, GFFFile::Struct &top) { std::string tlabels[] = {"ModMapNumAreas", "TURD_CalendarDay", "TURD_TimeOfDay", "TURD_PlayerID", "TURD_AreaId", "TURD_PositionX", "TURD_PositionY", "TURD_PositionZ", "TURD_OrientatX", "TURD_OrientatY", "TURD_OrientatZ", "TURD_CommntyName", "TURD_FirstName", "TURD_LastName", "Mod_MapAreasData", "EffectList", "TURD_PersonalRep", "TURD_RepList", "Mod_MapDataList", "VarTable"}; std::vector<uint32> n; if(gff.getIdxByLabel(tlabels, sizeof(tlabels)/sizeof(std::string), top, n, aderrstr)) return ERR(gff); if(n[0] != NOTFOUND) mapnumareas = top.values[n[0]]; if(n[1] != NOTFOUND) calendarday = top.values[n[1]]; if(n[2] != NOTFOUND) timeofday = top.values[n[2]]; if(n[3] != NOTFOUND) playerid = top.values[n[3]]; if(n[4] != NOTFOUND) areaid = top.values[n[4]]; if(n[5] != NOTFOUND) x = *((float32*) &top.values[n[5]]); if(n[6] != NOTFOUND) y = *((float32*) &top.values[n[6]]); if(n[7] != NOTFOUND) z = *((float32*) &top.values[n[7]]); if(n[8] != NOTFOUND) dirx = *((float32*) &top.values[n[8]]); if(n[9] != NOTFOUND) diry = *((float32*) &top.values[n[9]]); if(n[10] != NOTFOUND) dirz = *((float32*) &top.values[n[10]]); if(n[11] != NOTFOUND) if(gff.getExoString(n[11], top, commntyname)) return ERR(gff); if(n[12] != NOTFOUND) if(gff.getExoLocString(n[12], top, firstname)) return ERR(gff); if(n[13] != NOTFOUND) if(gff.getExoLocString(n[13], top, lastname)) return ERR(gff); if(n[14] != NOTFOUND) if(gff.getRaw(n[14], top, mapareasdata)) return ERR(gff); if(n[15] != NOTFOUND) if(getEffects(gff, n[15], top)) return errcode; if(n[16] != NOTFOUND) if(getPreputations(gff, n[16], top)) return errcode; if(n[17] != NOTFOUND) if(getReputations(gff, n[17], top)) return errcode; if(n[18] != NOTFOUND) if(getMapDatas(gff, n[18], top)) return errcode; if(n[19] != NOTFOUND) if(variables.load(gff, n[19], top)) return ERR(variables); return errcode = 0; }
IAudioSource* cAudioManager::createAudioSource(IAudioDecoder* decoder, const cAudioString& audioName, const cAudioString& dataSource) { if(decoder && decoder->isValid()) { #if CAUDIO_EFX_ENABLED == 1 IAudioSource* audio = CAUDIO_NEW cAudioSource(decoder, AudioContext, ((cAudioEffects*)getEffects())->getEFXInterface()); #else IAudioSource* audio = CAUDIO_NEW cAudioSource(decoder, AudioContext); #endif decoder->drop(); if(audio && audio->isValid()) { if(!audioName.empty()) audioIndex[audioName] = audio; audioSources.push_back(audio); getLogger()->logInfo("AudioManager", "Audio Source (%s) created from Data Source %s.", audioName.c_str(), dataSource.c_str()); return audio; } getLogger()->logError("AudioManager", "Failed to create Audio Source (%s): Error creating audio source.", audioName.c_str()); audio->drop(); return NULL; } getLogger()->logError("AudioManager", "Failed to create Audio Source (%s): Audio data could not be decoded by (.%s) decoder.", audioName.c_str(), decoder->getType().c_str()); decoder->drop(); return NULL; }