STATIC BOOLEAN freeSuffix( void *node, void *ptr ) /************************************************/ { SUFFIX *suf = node; CREATOR *ccur; CREATOR *cwalk; (void)ptr; // Unused FreeSafe( suf->node.name ); freePathRing( suf->first ); cwalk = suf->creator; while( cwalk != NULL ) { ccur = cwalk; cwalk = cwalk->next; KillTarget( ccur->cretarg->node.name ); FreeSafe( ccur ); } FreeSafe( suf ); return( FALSE ); }
STATIC RET_T imply( TARGET *targ, const char *drive, const char *dir, const char *fname, const char *ext, bool must ) /******************************************************************** * targ is the target to be implied * drive is the drive of the target * dir is the path of the target * fname is the portion of targ's name without the extension * ext is the extension of targ's name * must must we make this target? * * RET_SUCCESS - performed cmds, * RET_WARN unable to imply, * RET_ERROR - perform failed */ { SUFFIX *srcsuf; CREATOR *cur; SUFFIX *cursuf; TARGET *imptarg = NULL; RET_T ret; bool newtarg; UINT32 startcount; char *buf; SLIST *curslist; SLIST *slist; // Slist chosen for sufsuf SLIST *slistDef; // Slist that has dependent path = "" SLIST *slistEmptyTargDepPath; bool UseDefaultSList; int slistCount; srcsuf = FindSuffix( ext ); if( srcsuf == NULL || srcsuf->creator == NULL ) { PrtMsg( DBG | INF | IMP_ENV_M, targ->node.name, M_HAS_NO_IMPLICIT ); return( RET_WARN ); } PrtMsg( DBG | INF | IMP_ENV_M, targ->node.name, M_CHECKING_IMPLICIT ); startcount = cListCount; for( cur = srcsuf->creator; cur != NULL; cur = cur->next ) { cursuf = cur->suffix; /* allocate a buffer */ buf = MallocSafe( _MAX_PATH ); slist = NULL; slistDef = NULL; slistEmptyTargDepPath = NULL; ret = RET_ERROR; UseDefaultSList = true; /* find path in SLIST */ slistCount = 0; for( curslist = cur->slist; curslist != NULL && ret != RET_SUCCESS; curslist = curslist->next ) { _makepath( buf, drive, dir, NULL, NULL ); FixName( buf ); /* * note the path of the current target must match the * path as specified in the slist */ if( stricmp( buf, curslist->targ_path ) == 0 ) { /* build filename for implied target */ _makepath( buf, NULL, curslist->dep_path, fname, cursuf->node.name ); /* try to find this file on path or in targets */ ret = TrySufPath( buf, buf, &imptarg, false ); if( ret == RET_SUCCESS ) { slist = curslist; /* later on we need to check if implied target does not */ /* exist we need to create it on the first directory we */ /* see on the SLIST since */ /* the first on the list is the one that was defined */ /* last in the makefile */ } else if( slistDef == NULL ) { slistDef = curslist; } } if( *curslist->targ_path == NULLCHAR && *curslist->dep_path == NULLCHAR ) { slistEmptyTargDepPath = curslist; } if( slistCount > 0 && slistEmptyTargDepPath != NULL ) { UseDefaultSList = false; } ++slistCount; } if( UseDefaultSList && slist == NULL && !Glob.compat_nmake ) { _makepath( buf, NULL, NULL, fname, cursuf->node.name ); /* try to find this file on path or in targets */ ret = TrySufPath( buf, buf, &imptarg, false ); switch( ret ) { case RET_WARN: break; case RET_ERROR: if( !Glob.compat_nmake ) { slistDef = slistEmptyTargDepPath; } break; case RET_SUCCESS: slist = slistEmptyTargDepPath; break; } } if( ret == RET_ERROR && slistDef == NULL ) { /* * No Default Slist found so must continue and find * another slist */ FreeSafe( buf ); continue; } if( (ret == RET_SUCCESS && imptarg == NULL) || ret == RET_ERROR ) { /* Either file doesn't exist, or it exists and we don't already * have a target for it. Either way, we create a new target. */ if( ret == RET_ERROR ) { slist = slistDef; /* file doesn't exist, assume in directory */ /* pointed to by the slistDef */ _makepath( buf, NULL, slist->dep_path, fname, cursuf->node.name ); } newtarg = true; imptarg = NewTarget( buf ); FreeSafe( buf ); /* don't need any more */ getStats( imptarg ); imptarg->busy = true; /* protect against recursion */ if( imply( imptarg, NULL, slist->dep_path, fname, cursuf->node.name, false ) == RET_ERROR ) { imptarg->error = true; } if( startcount != cListCount && (Glob.noexec || Glob.query) ) { imptarg->touched = true; imptarg->executed = true; } imptarg->updated = true; imptarg->busy = false; } else { /* We already know about imptarg, so just update it */ assert( imptarg != NULL ); FreeSafe( buf ); /* don't need any more */ newtarg = false; /* this isn't a new target */ Update( imptarg ); } /* We've tried our best to make the imptarg, check if it exists * after our efforts. */ if( targExists( imptarg ) ) { /* it exists - now we perform the implicit cmd list, and return */ ret = implyMaybePerform( targ, imptarg, slist->cretarg, must ); if( newtarg && !Glob.noexec ) { /* destroy the implied target, because the info in the target * structure is nicely stored on disk (unless Glob.noexec) */ KillTarget( imptarg->node.name ); } implyDebugInfo( targ, startcount ); return( ret ); } else if( newtarg ) { /* we created an unsuccessful target - so destroy it */ KillTarget( imptarg->node.name ); } /* We couldn't imply with this suffix... try next one */ } implyDebugInfo( targ, startcount ); return( RET_WARN ); }
void Object::Killed(Event *ev) { Entity * ent; Entity * attacker; Vector dir; Event * event; const char * name; takedamage = DamageNo; setSolidType( SOLID_NOT ); hideModel(); attacker = ev->GetEntity( 1 ); if (flags & FlagDieExplode) { CreateExplosion( origin, 50.0f, this, this, this ); } if (flags & FlagDieGibs) { setSolidType( SOLID_NOT ); hideModel(); CreateGibs( this, -150.0f, edict->s.scale, 3 ); } // // kill the killtargets // name = KillTarget(); if ( name && strcmp( name, "" ) ) { ent = NULL; do { ent = G_FindTarget( ent, name ); if ( !ent ) { break; } ent->PostEvent( EV_Remove, 0.0f ); } while ( 1 ); } // // fire targets // name = Target(); if ( name && strcmp( name, "" ) ) { ent = NULL; do { ent = G_FindTarget( ent, name ); if ( !ent ) { break; } event = new Event( EV_Activate ); event->AddEntity( attacker ); ent->ProcessEvent( event ); } while ( 1 ); } PostEvent( EV_Remove, 0.0f ); }