Beispiel #1
0
void DoReplace(char **replace,char *name,struct XMLDBbuffer *buf,
               struct XMLDBbuffer *mod,char *sep,int type) {
  struct XMLDBbuffer *tbuf;
  char *txt;
  if (buf==NULL) return;
  if (buf->sze==0) return;

  if (mod==NULL) tbuf=XMLDBCopyBuffer(buf); 
  else tbuf=ApplyModifier(mod,name,buf);
	  
  if (type==2) txt=XMLToRaw(tbuf);
  else if (type==1) txt=XMLToURL(tbuf);
  else txt=XMLToHTML(tbuf);

  if (*replace==NULL) *replace=txt;
  else {
    char *tmp;
    if (sep !=NULL) {
      tmp=realloc(*replace,strlen(*replace)+strlen(sep)+strlen(txt)+1);
      strcat(tmp,sep);
    } else tmp=realloc(*replace,strlen(*replace)+strlen(txt)+1);
    strcat(tmp,txt);
    free(txt);
    *replace=tmp;
  }
  XMLDBFreeBuffer(tbuf);
}
void FGAGameEffectContainer::ApplyEffect(const FGAGameEffect& EffectIn
	, const FGAGameEffectHandle& HandleIn)
{
	//instant effect goes trough simplest application path
	//just make effect and run it trough modifiers.

	//FGAGameEffect Effect = EfNoConst.Calculation->ModiifyEffect(EffectIn);
	switch (EffectIn.GameEffect->EffectType)
	{
	case EGAEffectType::Instant:
	{
		//dont do anything fancy now simply execute effect and forget about it.
		HandleIn.GetContext().TargetComp->ExecuteEffect(HandleIn);
		break;
	}
	case EGAEffectType::Periodic:
	{

		UE_LOG(GameAttributesEffects, Log, TEXT("UGAAttributeComponent:: Apply periodic effect"));
		/*FTimerDelegate del = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExecuteEffect, HandleIn);
		FTimerManager& timer = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();

		timer.SetTimer(HandleIn.GetEffectRef().PeriodTimerHandle, del,
			EffectIn.GameEffect->Period, true, 0);

		FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
		FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();

		timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
			EffectIn.GameEffect->Duration, false);*/

		InternalCheckEffectStacking(HandleIn);
		InternalApplyModifiers(HandleIn);
		break;
	}
	case EGAEffectType::Duration:
	{

		UE_LOG(GameAttributesEffects, Log, TEXT("UGAAttributeComponent:: Apply effect for duration"));
		HandleIn.GetContextRef().TargetComp->ApplyEffectForDuration(HandleIn);

		FTimerDelegate delDuration = FTimerDelegate::CreateUObject(HandleIn.GetContext().TargetComp.Get(), &UGAAttributeComponent::ExpireEffect, HandleIn);
		FTimerManager& timerDuration = HandleIn.GetEffectRef().Context.TargetComp->GetWorld()->GetTimerManager();

		timerDuration.SetTimer(HandleIn.GetEffectRef().DurationTimerHandle, delDuration,
			EffectIn.GameEffect->Duration, false);

		InternalCheckEffectStacking(HandleIn);
		InternalApplyModifiers(HandleIn);
		break;
	}
	default:
		break;
	}
	//apply additonal effect applied with this effect.
	for (TSubclassOf<UGAGameEffectSpec> Spec : EffectIn.GameEffect->OnAppliedEffects)
	{
		FGAGameEffectHandle Handle = EffectIn.Context.TargetComp->MakeGameEffect(Spec, EffectIn.Context);

		EffectIn.Context.TargetComp->ApplyEffectToSelf(Handle.GetEffect(), Handle);
	}
	//regardless of what happen try to apply effect modifiers
	for (FGAGameEffectModifier& mod : EffectIn.GameEffect->Modifiers)
	{
		ApplyModifier(mod, EffectIn);
	}

}
Beispiel #3
0
int main (int argc, char **argv)
{
    setlocale (LC_ALL, "");

    if (!ParseParameters(argc, argv))
        return -1;

    // load database
    lfDatabase *ldb = new lfDatabase ();

    if (ldb->Load () != LF_NO_ERROR) {
        ldb->Destroy();
        g_print ("\rERROR: Database could not be loaded\n");
        return -1;
    }

    // try to find camera in the database
    const lfCamera *cam = NULL;
    if (opts.Camera) {
        const lfCamera ** cameras = ldb->FindCamerasExt(NULL, opts.Camera);
        if (cameras)
            cam = cameras[0];
        else
            g_print ("Cannot find a camera matching `%s' in database\n", opts.Camera);
        lf_free (cameras);
     }

    // try to find a matching lens in the database
    const lfLens *lens = NULL;
    if (opts.Lens) {
        const lfLens **lenses = ldb->FindLenses (cam, NULL, opts.Lens);
        if (lenses)
            lens = lenses [0];
        else
            g_print ("Cannot find a lens matching `%s' in database\n", opts.Lens);
        lf_free (lenses);
    }

    // print camera and lens information if in verbose mode or if no input file is specified
    if (opts.Verbose || !opts.Input) {
        if (cam && lens) {
            g_print("Matching lens and camera combination found in the database:\n");
            PrintCamera(cam, ldb);
            PrintLens(lens, ldb);
        } else if (!cam && lens) {
            g_print("Matching lens found in the database:\n");
            PrintLens(lens, ldb);
        } else if (!lens && cam) {
            g_print("Matching camera found in the database:\n");
            PrintCamera(cam, ldb);
        }
    } else {
        if (cam && lens) {
            g_print("= Selecting %s / %s\n", cam->Model, lens->Model);
        } else if (!cam && lens) {
            g_print("= Selecting %s\n", lens->Model);
        }
    }

    // nothing to process, so lets quit here
    if (!opts.Input) {
        ldb->Destroy();
        return 0;
    }

    // assume standard values if parameters are not specified
    if (cam)
        opts.Crop = cam->CropFactor;
    else if (!opts.Crop)
        opts.Crop = lens->CropFactor;    
    if (!opts.Focal)
        opts.Focal = lens->MinFocal;
    if (!opts.Aperture)
        opts.Aperture = lens->MinAperture;

    if (opts.Verbose) {
        g_print("\nProcessing parameters:\n"
                "    |- Image crop factor: %g\n"
                "    |- Focal length: %gmm\n"
                "    |- Aperture: f/%g\n"
                "    |- Distance: %gm\n\n",
                opts.Crop, opts.Focal, opts.Aperture, opts.Distance);
    } else {
        g_print("= Processing parameters: Crop %g, Focal %gmm, Aperture f/%g, Distance: %gm\n",
                opts.Crop, opts.Focal, opts.Aperture, opts.Distance);
    }

    Image *img = new Image ();
    g_print ("~ Loading `%s' ... ", opts.Input);
    if (!img->Open (opts.Input)) {
        g_print ("\rERROR: failed to open file `%s'\n", opts.Input);
        delete img;
        ldb->Destroy();
        return -1;
    }
    if (!img->LoadPNG ()) {
        g_print ("\rERROR: failed to parse PNG data from file `%s'\n", opts.Input);
        delete img;
        ldb->Destroy();
        return -1;
    }
    g_print ("done.\n~ Image size [%ux%u].\n", img->width, img->height);

    lfModifier *mod = lfModifier::Create (lens, opts.Crop, img->width, img->height);
    if (!mod) {
        g_print ("\rWarning: failed to create modifier\n");
        delete img;
        ldb->Destroy();
        return -1;
    }
    int modflags = mod->Initialize (
        lens, LF_PF_U8, opts.Focal,
        opts.Aperture, opts.Distance, opts.Scale, opts.TargetGeom,
        opts.ModifyFlags, opts.Inverse);

    g_print("~ Selected modifications: ");
    if (modflags & LF_MODIFY_TCA)
        g_print ("[tca]");
    if (modflags & LF_MODIFY_VIGNETTING)
        g_print ("[vign]");
    if (modflags & LF_MODIFY_DISTORTION)
        g_print ("[dist]");
    if (modflags & LF_MODIFY_GEOMETRY)
        g_print ("[geom]");
    if (opts.Scale != 1.0)
        g_print ("[scale]");
    if (modflags==0)
        g_print ("[NOTHING]");
    g_print ("\n");

    g_print("~ Run processing chain... ");

    clock_t st;
    clock_t xt = clock ();
    while (xt == (st = clock ()))
        ;

    img = ApplyModifier (modflags, opts.Inverse, img, mod);

    clock_t et = clock ();
    g_print ("done (%.3g secs)\n", double (et - st) / CLOCKS_PER_SEC);

    mod->Destroy ();

    g_print ("~ Save output as `%s'...", opts.Output);
    bool ok = img->SavePNG (opts.Output);

    delete img;
    ldb->Destroy ();

    if (ok) {
        g_print (" done\n");
        return 0;
    } else {
        g_print (" FAILED\n");
        return -1;
    }

}
	void CGridManager::SlowUpdate() {
		ApplyModifier(UpdateModifier);
	}