On Tue, 2006-04-04 at 23:05 +0200, Jörg Hinrichs wrote:
> As an example, i take the code in
> actions.cpp, that is using a turn_info object. Like this code that resides
> in ai.cpp::recruit :
>
> ...
> if(recruit_unit(info_.map,info_.team_num,info_.units,new_unit,loc,preference
> s::show_ai_moves() ? &info_.disp : NULL).empty()) {
> ...
> info_.turn_data_.sync_network();
> ...
> return true;
> else if(...
...
> There is another option: you can delay the call until the rest of the code
> within recruit is done, that makes extracting very easy. But that has a
> tradeoff: Immediate feedback is lost. If things turn out bad you might have
> to wait until the end of the turn until you send the results to other
> network players.
Hi Yogi!
"If things turn out bad". What does that mean? I guess I don't
understand this code at all. Why is it doing a network sync? Because
it wants the other side to see the recruitment ASAP? OK, why isn't it
done inside recruit_unit()?
Abstracting this into a generic "fire_sync()" event doesn't seem to
actually help. You've added a layer of indirection, so instead of it
being obvious what the code is doing, you have to grep and find who's
registered. Worse, AFAICT this sync_network() call only exists because
of networking: the programmer has to know that it wants networking to
sync here, so the abstraction is just a distraction.
Confused about this example,
Rusty.
--
ccontrol: http://ozlabs.org/~rusty/ccontrol
_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev