Am Sonntag, 4. September 2011, 13:10:56 schrieb Jordi Negrevernis i Font:
> En/na Matthias Pfafferodt ha escrit:
> > The check is implemented like this since 2004 ...Considering patch #2943
> > (https://gna.org/patch/?2943), the index values should be compared:
> > 
> > bool same_pos(const struct tile *tile1, const struct tile *tile2)
> > {
> > 
> >    fc_assert_ret_val(tile1 != NULL&&  tile2 != NULL, FALSE);
> >    return (tile1->index == tile2->index);
> > 
> > }

This code would be a patch - it changes the comparison of pointers to a 
comparison of the index value.

> 
>      But this is not the code on S2_3 and trunk!! It's that:
> 
> bool same_pos(const struct tile *tile1, const struct tile *tile2)
> {
>    fc_assert_ret_val(tile1 != NULL && tile2 != NULL, FALSE);
>    return (tile1 == tile2);
> }
> 
>      This is comparing only the pointers!!! Is this correct?

It is correct as long as no virtual tile is used. In this case there is only 
_one_ map with pointers to each tile. So to check if two positions (tiles) are 
identical, the pointers must be compared. With virtual tiles, one of the tiles 
could be such a special tile and the check would fail if if it is the same 
position. Thus, something else, like the index, is needed. The code above 
should be applied on top of the patch mentioned in my first mail. Else, the 
index value for the virtual tile is not set.

> 
> > Am Sonntag, 4. September 2011, 02:48:24 schrieb Jordi Negrevernis i Font:
> >>       I was trying to debug some issues with the AI, and i realized that
> >> 
> >> some checks I put in the code didn't succeed because the 'same_pos'
> >> function does not check the value of x and y in the structure, instead
> >> it just compares the points!!!????!!!
> >> 
> >>       How is that supposed to work??!! Which is the way to check two
> >> 
> >> locations?
> >> 
> >>       Thanks
> >> 
> >> _______________________________________________
> >> Freeciv-dev mailing list
> >> Freeciv-dev@gna.org
> >> https://mail.gna.org/listinfo/freeciv-dev
> > 
> > _______________________________________________
> > Freeciv-dev mailing list
> > Freeciv-dev@gna.org
> > https://mail.gna.org/listinfo/freeciv-dev
> 
> _______________________________________________
> Freeciv-dev mailing list
> Freeciv-dev@gna.org
> https://mail.gna.org/listinfo/freeciv-dev


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

Reply via email to