adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] Event system update


From: Kai Sterker
Subject: [Adonthell-devel] Event system update
Date: Sun, 26 Feb 2012 18:00:19 +0100

Made quite a few changes, so hopefully no major new bugs :-)

[*] Move events are implemented. You can see one in action by running
world test with the included test data. While the NPC is moving,
you'll see a dot printed to stdout for each move event. Note that
you'll see more move events after the "Arrived" message. It's because
the character is jumping on the spot, which also counts as movement.

[*] Replaced a number of std::vectors with std::list, as lists are
better suited for inserting or removing items at arbitrary positions.
Probably not a big deal, but it also shouldn't break anything.

[*] Changed the way how listeners are unregistered. Basically the
issue was in the gui::conversation widget, where it kept adding new
listeners without cleaning up the old ones. If by chance one of the
new option buttons was created at the same address in memory as prior
button, the old listener would suddenly fire and all hell break lose.
Clearing the listeners ran into the old issue again the we were
currently inside a callback attached to the listener we wanted to
delete. That's like sawing off the branch you're sitting on.
As a solution, the factory will not delete the listeners, but instead
set their repeat count to 0, thus marking them as deleted. Each event
handler in turn was changed to check the repeat count first and
finally delete the listener. That means deletion of listeners is
deferred until the next event is raised (which might open another can
of worms), but the various tests I ran seemed to indicate that things
were fine.

Maybe it would not hurt to analyse the relationship between factory,
listeners, events and event_handlers and come up with a better way to
handle cleanup and deletion of listeners. It's a part of the code that
is quite old and could probably use a bit of love. Or maybe it has
just too many ways to use. Streamlining the API might already help
closing loopholes where stuff is deleted while still used elsewhere or
not deleted at all.

Kai



reply via email to

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