Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] (PR#12706) Events framework
Home

[Freeciv-Dev] (PR#12706) Events framework

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#12706) Events framework
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Apr 2005 10:19:44 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12706 >

> [per - Sat Apr 02 13:23:14 2005]:

> Make events just a case of general effects. (For easy identification,
> global effects and events effects should be put in effects.ruleset, 
while
> other effects should be put in the other rulesets.)

I'm not certain but I don't think this is the right way to do it.  All 
effects we have now operate continuously.  They are not checked when 
the action occurrs but when the effect takes place.  So there is 
no "trigger" to generate an effect, it just has a start and (in some 
cases) a stop time and any effects checks in between will know about 
the effect.

By comparison events require certain triggers; they are discrete.  For 
instance the hut event requires a function to be called when a hut is 
entered.  To do this with the current effects framework would require 
something like:

  enable_requirement(pplayer, REQ_HUT);
  rerun_all_effects();
  disable_requirement(pplayer, REQ_HUT);

which is not only very slow (unless there's yet another cache, you 
have to go over all effects to see what should be done for them...code 
that hasn't even been written yet, and there are a lot of effects) but 
also must be added for every type of trigger we want.  As well, we'll 
have to add a new requirement for every type of trigger.  Finally, 
while triggers may need to take more than one parameter (or a string 
parameter, in the case of a notification event) the effects system 
currently takes only a single integer parameter (and it must be a 
numerical since it is summed for all effects).

In summary, I think there is not actually a lot of overlap between 
effects and events.  You wouldn't have an "increase tile output" event 
action, nor would you have a "give player 50 gold" effect.  The 
difference between a continuous effect and a discrete event is 
fundamental.

Also I think (but I'm not quite as sure) that requirements and 
triggers don't overlap, and for the same reason.  A trigger must be 
checked at the instant that something happens, while a requirement is 
just set in the sources cache somewhere and then is checked by various 
bits of code later.

-jason




[Prev in Thread] Current Thread [Next in Thread]