//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropAPC::Event_Killed( const CTakeDamageInfo &info ) { m_OnDeath.FireOutput( info.GetAttacker(), this ); Vector vecAbsMins, vecAbsMaxs; CollisionProp()->WorldSpaceAABB( &vecAbsMins, &vecAbsMaxs ); Vector vecNormalizedMins, vecNormalizedMaxs; CollisionProp()->WorldToNormalizedSpace( vecAbsMins, &vecNormalizedMins ); CollisionProp()->WorldToNormalizedSpace( vecAbsMaxs, &vecNormalizedMaxs ); Vector vecAbsPoint; CPASFilter filter( GetAbsOrigin() ); for (int i = 0; i < 5; i++) { CollisionProp()->RandomPointInBounds( vecNormalizedMins, vecNormalizedMaxs, &vecAbsPoint ); te->Explosion( filter, random->RandomFloat( 0.0, 1.0 ), &vecAbsPoint, g_sModelIndexFireball, random->RandomInt( 4, 10 ), random->RandomInt( 8, 15 ), ( i < 2 ) ? TE_EXPLFLAG_NODLIGHTS : TE_EXPLFLAG_NOPARTICLES | TE_EXPLFLAG_NOFIREBALLSMOKE | TE_EXPLFLAG_NODLIGHTS, 100, 0 ); } // TODO: make the gibs spawn in sync with the delayed explosions int nGibs = random->RandomInt( 1, 4 ); for ( int i = 0; i < nGibs; i++) { // Throw a flaming, smoking chunk. CGib *pChunk = CREATE_ENTITY( CGib, "gib" ); pChunk->Spawn( "models/gibs/hgibs.mdl" ); pChunk->SetBloodColor( DONT_BLEED ); QAngle vecSpawnAngles; vecSpawnAngles.Random( -90, 90 ); pChunk->SetAbsOrigin( vecAbsPoint ); pChunk->SetAbsAngles( vecSpawnAngles ); int nGib = random->RandomInt( 0, APC_MAX_CHUNKS - 1 ); pChunk->Spawn( s_pChunkModelName[nGib] ); pChunk->SetOwnerEntity( this ); pChunk->m_lifeTime = random->RandomFloat( 6.0f, 8.0f ); pChunk->SetCollisionGroup( COLLISION_GROUP_DEBRIS ); IPhysicsObject *pPhysicsObject = pChunk->VPhysicsInitNormal( SOLID_VPHYSICS, pChunk->GetSolidFlags(), false ); // Set the velocity if ( pPhysicsObject ) { pPhysicsObject->EnableMotion( true ); Vector vecVelocity; QAngle angles; angles.x = random->RandomFloat( -20, 20 ); angles.y = random->RandomFloat( 0, 360 ); angles.z = 0.0f; AngleVectors( angles, &vecVelocity ); vecVelocity *= random->RandomFloat( 300, 900 ); vecVelocity += GetAbsVelocity(); AngularImpulse angImpulse; angImpulse = RandomAngularImpulse( -180, 180 ); pChunk->SetAbsVelocity( vecVelocity ); pPhysicsObject->SetVelocity(&vecVelocity, &angImpulse ); } CEntityFlame *pFlame = CEntityFlame::Create( pChunk, false ); if ( pFlame != NULL ) { pFlame->SetLifetime( pChunk->m_lifeTime ); } } UTIL_ScreenShake( vecAbsPoint, 25.0, 150.0, 1.0, 750.0f, SHAKE_START ); if( hl2_episodic.GetBool() ) { // EP1 perf hit Ignite( 6, false ); } else { Ignite( 60, false ); } m_lifeState = LIFE_DYING; // Spawn a lesser amount if the player is close m_iRocketSalvoLeft = DEATH_VOLLEY_ROCKET_COUNT; m_flRocketTime = gpGlobals->curtime; }
Ignite Ignition::Start(const IgniteConfiguration& cfg, const char* name, IgniteError* err) { bool failed = false; SharedPointer<IgniteEnvironment> env; SharedPointer<IgniteEnvironment>* envTarget = NULL; jobject javaRef = NULL; factoryLock.Enter(); // 1. Load JVM library if needed. if (!JVM_LIB_LOADED) { bool jvmLibFound; std::string jvmLib; if (cfg.jvmLibPath) { std::string jvmLibPath = std::string(cfg.jvmLibPath); jvmLib = FindJvmLibrary(&jvmLibPath, &jvmLibFound); } else jvmLib = FindJvmLibrary(NULL, &jvmLibFound); if (!jvmLibFound) { *err = IgniteError(IgniteError::IGNITE_ERR_JVM_LIB_NOT_FOUND, "JVM library is not found (did you set JAVA_HOME environment variable?)"); failed = true; } if (!failed) { if (!LoadJvmLibrary(jvmLib)) { *err = IgniteError(IgniteError::IGNITE_ERR_JVM_LIB_LOAD_FAILED, "Failed to load JVM library."); failed = true; } } JVM_LIB_LOADED = true; } if (!failed) { // 2. Resolve IGNITE_HOME. bool homeFound; std::string home; if (cfg.igniteHome) { std::string homePath = std::string(cfg.igniteHome); home = ResolveIgniteHome(&homePath, &homeFound); } else home = ResolveIgniteHome(NULL, &homeFound); // 3. Create classpath. std::string cp; if (cfg.jvmClassPath) { std::string usrCp = cfg.jvmClassPath; cp = CreateIgniteClasspath(&usrCp, homeFound ? &home : NULL); } else cp = CreateIgniteClasspath(NULL, homeFound ? &home : NULL); if (!cp.empty()) { // 4. Start JVM if needed. JniErrorInfo jniErr; env = SharedPointer<IgniteEnvironment>(new IgniteEnvironment()); int optsLen; char** opts = CreateJvmOptions(cfg, homeFound ? &home : NULL, cp, &optsLen); envTarget = new SharedPointer<IgniteEnvironment>(env); SharedPointer<JniContext> ctx( JniContext::Create(opts, optsLen, env.Get()->GetJniHandlers(envTarget), &jniErr)); for (int i = 0; i < optsLen; i++) ReleaseChars(*(opts + i)); delete[] opts; if (!ctx.Get()) { IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); failed = true; } // 5. Start Ignite. if (!failed) { char* springCfgPath0 = CopyChars(cfg.springCfgPath); if (!springCfgPath0) springCfgPath0 = CopyChars(DFLT_CFG); char* name0 = CopyChars(name); interop::InteropUnpooledMemory mem(16); interop::InteropOutputStream stream(&mem); stream.WriteBool(false); stream.Synchronize(); javaRef = ctx.Get()->IgnitionStart(springCfgPath0, name0, 2, mem.PointerLong(), &jniErr); ReleaseChars(springCfgPath0); ReleaseChars(name0); if (!javaRef) { IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); failed = true; } else { // 6. Ignite is started at this point. env.Get()->Initialize(ctx); started = true; } } } else { *err = IgniteError(IgniteError::IGNITE_ERR_JVM_NO_CLASSPATH, "Java classpath is empty (did you set IGNITE_HOME environment variable?)"); failed = true; } } factoryLock.Leave(); if (failed) { if (envTarget) delete envTarget; return Ignite(); } else { IgniteImpl* impl = new IgniteImpl(env, javaRef); return Ignite(impl); } }
Ignite Ignition::Get(const char* name, IgniteError* err) { Ignite res; factoryLock.Enter(); if (started) { char* name0 = CopyChars(name); // 1. Create context for this operation. JniErrorInfo jniErr; SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr)); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { // 2. Get environment pointer. long long ptr = ctx.Get()->IgnitionEnvironmentPointer(name0, &jniErr); IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { if (ptr != 0) { // 3. Obtain real environment for this instance. JniHandlers* hnds = reinterpret_cast<JniHandlers*>(ptr); SharedPointer<IgniteEnvironment>* env = static_cast<SharedPointer<IgniteEnvironment>*>(hnds->target); // 4. Get fresh node reference. jobject ref = ctx.Get()->IgnitionInstance(name0, &jniErr); if (err->GetCode() == IgniteError::IGNITE_SUCCESS) { if (ref) { IgniteImpl* impl = new IgniteImpl(*env, ref); res = Ignite(impl); } else // Error: concurrent node stop. *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Failed to get Ignite instance because it was stopped concurrently."); } } else // Error: no node with the given name. *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Failed to get Ignite instance because it is either not started yet or already stopped."); } } ReleaseChars(name0); } else // Error: no node with the given name. *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Failed to get Ignite instance because it is either not started yet or already stopped."); factoryLock.Leave(); return res; }
void DoCmdFile( char *fname ) /**********************************/ /* start parsing the command */ { exe_format possible; f_handle file; size_t namelen; file_defext extension; char *namelnk; ResetCmdFile(); if( fname == NULL || *fname == '\0' ) { _ChkAlloc( fname, (10*1024) ); // arbitrarily large buffer that won't GetCmdLine( fname ); // be overflowed NewCommandSource( NULL, fname, COMMANDLINE ); } else { NewCommandSource( NULL, fname, ENVIRONMENT ); } if( IsStdOutConsole() ) { CmdFlags |= CF_TO_STDOUT; } while( *fname == ' ' ) { fname++; } if( QSysHelp( &Token.next ) ) { Help(); } if( *fname == '?' ) { Token.next = fname + 1; // skip question mark. Help(); #if defined( __UNIX__ ) } else if( *fname == '-' ) { #else } else if( *fname == '-' || *fname == '/' ) { #endif if( *(fname + 1) == '?' ) { Token.next = fname + 2; // skip /? Help(); } } if( *fname == '\0' ) { // go into interactive mode. Token.how = INTERACTIVE; Token.where = ENDOFLINE; LnkMsg( INF+MSG_PRESS_CTRL_Z, NULL ); } namelnk = GetEnvString( INIT_FILE_ENV ); file = ( namelnk != NULL ) ? FindPath( namelnk ) : NIL_FHANDLE; if( file == NIL_FHANDLE ) { namelnk = INIT_FILE_NAME; file = FindPath( namelnk ); } if( file != NIL_FHANDLE ) { fname = ChkStrDup( namelnk ); SetCommandFile( file, fname ); } if( Spawn( DoCmdParse ) ) { Ignite(); Suicide(); } GetExtraCommands(); if( !(LinkState & FMT_DECIDED) ) { /* restrict set to automatically decided ones */ #if defined( __QNX__ ) #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_LE | MK_OS2_NE | MK_QNX ) #elif defined( __LINUX__ ) #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_LE | MK_OS2_NE | MK_ELF ) #elif defined( __NT__ ) #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_NE | MK_WINDOWS | MK_PE | MK_DOS_EXE | MK_WIN_VXD ) #else #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_LE | MK_OS2_NE | MK_DOS_EXE | MK_PHAR_SIMPLE ) #endif HintFormat( LAST_CHANCE ); } else { /* restrict to a unique type */ for( possible = 1; possible != 0; possible *= 2 ) { if( FmtData.type & possible ) { FmtData.type = possible; break; } } } if( (FmtData.type & (MK_NOVELL | MK_DOS)) && (LinkFlags & INC_LINK_FLAG) ) { LnkMsg( FTL+MSG_FORMAT_BAD_OPTION, "s", "incremental" ); } #ifdef _NOVELL if( FmtData.type & MK_NOVELL ) { CmdNovFini(); } else #endif if( FmtData.type & MK_OVERLAYS ) { CmdOvlFini(); AddObjLib( "wovl.lib", LIB_PRIORITY_MIN ); // add a reference to wovl.lib } if( Name == NULL || !(CmdFlags & CF_HAVE_FILES) ) { Ignite(); LnkMsg( FTL+MSG_NO_FILES_FOUND, NULL ); } namelen = strlen( Name ); if( MapFlags & MAP_FLAG ) { if( MapFName == NULL ) { MapFName = FileName( Name, namelen, E_MAP, TRUE ); } } else { MapFlags = 0; // if main isn't set, don't set anything. } if( SymFileName == NULL && ( (CmdFlags & CF_SEPARATE_SYM) || (LinkFlags & OLD_DBI_FLAG) && (FmtData.type & MK_COM) ) ) { SymFileName = FileName( Name, namelen, E_SYM, TRUE ); } if( FmtData.make_implib && FmtData.implibname == NULL ) { if( FmtData.make_impfile ) { extension = E_LBC; } else { extension = E_LIBRARY; } FmtData.implibname = FileName( Name, namelen, extension, TRUE ); } CheckTraces(); BurnUtils(); PruneSystemList(); NumberSections(); DBIInit(); }