std::shared_ptr<Ego::Particle> ParticleHandler::spawnParticle(const Vector3f& spawnPos, const Facing& spawnFacing, const PRO_REF spawnProfile, const PIP_REF particleProfile, const ObjectRef spawnAttach, Uint16 vrt_offset, const TEAM_REF spawnTeam, const ObjectRef spawnOrigin, const ParticleRef spawnParticleOrigin, const int multispawn, const ObjectRef spawnTarget, const bool onlyOverWater) { const std::shared_ptr<ParticleProfile> &ppip = ProfileSystem::get().ParticleProfileSystem.get_ptr(particleProfile); if (!ppip) { const std::string spawnOriginName = _currentModule->getObjectHandler().exists(spawnOrigin) ? _currentModule->getObjectHandler()[spawnOrigin]->getName() : "INVALID"; const std::string spawnProfileName = ProfileSystem::get().isValidProfileID(spawnProfile) ? ProfileSystem::get().getProfile(spawnProfile)->getPathname() : "INVALID"; Log::get().debug("spawn_one_particle() - cannot spawn particle with invalid particle profile == %d, spawn origin == %" PRIuZ " (\"%s\"), spawn profile == %d (\"%s\"))\n", REF_TO_INT(particleProfile), spawnOrigin.get(), spawnOriginName.c_str(), REF_TO_INT(spawnProfile), spawnProfileName.c_str()); return Ego::Particle::INVALID_PARTICLE; } // count all the requests for this particle type ppip->_spawnRequestCount++; //Try to get a free particle std::shared_ptr<Ego::Particle> particle = getFreeParticle(ppip->force); if(particle) { //Initialize particle and add it into the game if(particle->initialize(ParticleRef(_totalParticlesSpawned++), spawnPos, spawnFacing, spawnProfile, particleProfile, spawnAttach, vrt_offset, spawnTeam, spawnOrigin, ParticleRef(spawnParticleOrigin), multispawn, spawnTarget, onlyOverWater)) { _pendingParticles.push_back(particle); _particleMap[particle->getParticleID()] = particle; } else { //If we failed to spawn somehow, put it back to the unused pool _unusedPool.push_back(particle); } } if(!particle) { const std::string spawnOriginName = _currentModule->getObjectHandler().exists(spawnOrigin) ? _currentModule->getObjectHandler().get(spawnOrigin)->getName() : "INVALID"; const std::string particleProfileName = LOADED_PIP(particleProfile) ? ProfileSystem::get().ParticleProfileSystem.get_ptr(particleProfile)->_name : "INVALID"; const std::string spawnProfileName = ProfileSystem::get().isValidProfileID(spawnProfile) ? ProfileSystem::get().getProfile(spawnProfile)->getPathname().c_str() : "INVALID"; Log::get().debug("spawn_one_particle() - cannot allocate a particle! owner == %" PRIuZ "(\"%s\"), spawn profile == %d(\"%s\"), particle profile == %d(\"%s\")\n", spawnOrigin.get(), spawnOriginName.c_str(), REF_TO_INT(spawnProfile), spawnProfileName.c_str(), REF_TO_INT(particleProfile), particleProfileName.c_str()); } return particle; }
//-------------------------------------------------------------------------------------------- bool link_push_module() { return false; //TODO: not ported #if 0 bool retval; link_stack_entry_t * pentry; PLA_REF ipla; if ( link_stack_count >= MAX_PLAYER || pickedmodule_index < 0 ) return false; // grab an entry pentry = link_stack + link_stack_count; BLANK_STRUCT_PTR( pentry ) // store the load name of the module strncpy( pentry->modname, mnu_ModList_get_vfs_path( pickedmodule_index ), SDL_arraysize( pentry->modname ) ); // find all of the exportable characters pentry->hero_count = 0; for ( ipla = 0; ipla < MAX_PLAYER; ipla++ ) { ObjectRef ichr; Object * pchr; hero_spawn_data_t * phero; if ( !PlaStack.lst[ipla].valid ) continue; // Is it alive? ichr = PlaStack.lst[ipla].index; if ( !_currentModule->getObjectHandler().exists( ichr ) ) continue; pchr = _currentModule->getObjectHandler().get( ichr ); if ( pentry->hero_count < LINK_HEROES_MAX ) { phero = pentry->hero + pentry->hero_count; pentry->hero_count++; // copy some important info phero->object_index = REF_TO_INT( pchr->getProfileID() ); phero->pos_stt.x = pchr->pos_stt.x; phero->pos_stt.y = pchr->pos_stt.y; phero->pos_stt.z = pchr->pos_stt.z; chr_get_pos( pchr, phero->pos.v ); } } // the function only succeeds if at least one hero's info was cached retval = false; if ( pentry->hero_count > 0 ) { link_stack_count++; retval = true; } return retval; #endif }