On Mon, Feb 12, 2007 at 09:17:41PM +0100, Jörg Hinrichs wrote:
> Hi all,

Hi

<cut>
> How to fix it:
> This is the reason i am writing this mail. I can see several ways to deal
> with the problem but i don't like most of them. And i am not so familiar
> with the ai code so i would like someone else to jump in here. The problem
> is located in ai_interface::move_unit_partial, ai_interface::move_unit,
> ai::move_group and ai::move_to_targets. They return the location where the
> unit moved to but no reliable information if it was ambushed.

Note I'm also not familiar with this part of the code. I had a quick
look and more places test the whether the returned location is equal to the 
requested location. 
 
> 1.
> We could add another bool parameter to these methods. I don't like that much
> because we then have two return values, a "real" one and an output
> parameter. Not really intuitive.

This could be made a pointer with a default of 0 so the parameter is
optional. I don't think this is too ugly.
 
> 2.
> We could add the ambush information to the return value by making a
> structure or something out of it, that contains the location and the bool.
> Doesn't look very elegant to me either.

Looks ugly to me.
 
> 3.
> We could use a global variable for this. Urgh. Don't like that.

Globals are the root of all evil 
 
> 4.
> If (and only if) the return location is just used for detecting ambush, we
> could change it to a bool and everything is fine. This is very promising but
> i don't feel comfortable in judging it since i know little to nothing about
> that part of the code.

I would vote for trying this, change the retour to a bool and then see
where the location is realy used as location and where it's used to
detect ambushing and then decide further.

> There might be more solutions i didn't even think of. Feel free to elaborate
> on this. As i said, i can implement a solution but i would appreciate
> someone else to take care of this.

5.
Throwing an exception is another solution, but I don't think it's really
a nice solution in this case.

6.
Another option is to return location(-1, -1) upon ambusing but that can
break as much as option 4 but in a more subtile way probably.

> 
> Greetings

Greets,

Mark de Wever aka Mordante/SkeletonCrew

_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev

Reply via email to