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

 This is idea I got when looking through aiferry code. This might be
overkill for current freeciv codebase, but something to consider.

 aiferry code keeps statistics about passengers and free boats. For
that to work perfectly, it would require notifications about new units
and removed units. Scripting interface requires notifications about
these events too. Maybe other AI subsystems require same notifications
as well.

 Each subsystem registers set of callbacks to system. When something
important happens, we iterate through callbacksets and call all the
relevant callbacks.

 This is close to subject/observer design pattern.


 callbackset_iterate(pset) {
    if (pset->new_unit != NULL) {
        pset->new_unit(punit);
    }
 } callbackset_iterate_end;



 - ML



_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to