[Freeciv-Dev] Re: (PR#6790) Expel enemy units
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Fri, Nov 07, 2003 at 05:34:13AM -0800, Per I. Mathisen wrote:
> On Fri, 7 Nov 2003, Raimar Falke wrote:
> > I break up an alliance and the units of the now enemy are still in my
> > cities. They should all be expelled. This could be done with either
> > of:
> > - they just move ouf of my cities with their normal movepoints
> > - they are placed one tile outside the city
> > - they are teleported back to a city of their nation.
>
> They should be teleported by bounce_unit(). I don't know why this does not
> happen properly.
To reproduce: load the game, watch Walbrzych, cancel the treaty with
Roman. The caravel shouldn't be there afterwards.
Findings: this is an update problem. If you disconnect and reconnect
the unit isn't there anymore.
I have tracked this down to
pplayers_allied(unit_owner(punit), pplayer)
in can_player_see_unit_at(). IMHO it has to be changed to
pplayers_allied(city_owner(pcity), pplayer)
since we want to test if the player can look inside the given city.
The attacked patch changes this.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Many of my assistants were fans of Tolkien, who wrote 'Lord of the Rings'
and a number of other children's stories for adults. The first character
alphabet that was programmed for my plotter was Elvish rather than Latin."
-- from SAIs "life as a computer for a quarter of a century"
ally.gz
Description: application/gunzip
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.128
diff -u -u -r1.128 player.c
--- common/player.c 2003/10/21 21:49:55 1.128
+++ common/player.c 2003/11/07 16:18:08
@@ -263,18 +263,20 @@
A player can see a unit if he:
(a) can see the tile AND
(b) can see the unit at the tile (i.e. unit not invisible at this tile) AND
- (c) the unit is not in an unallied city
+ (c) the unit is outside a city OR in an allied city
TODO: the name is confusingly similar to player_can_see_unit_at_location
But we need to rename p_c_s_u_a_t because it is really
is_unit_visible_to_player_at or player_ignores_unit_invisibility_at.
**************************************************************************/
bool can_player_see_unit_at(struct player *pplayer, struct unit *punit,
- int x, int y)
+ int x, int y)
{
+ struct city *pcity = map_get_city(x, y);
+
return ((map_get_known(x, y, pplayer) == TILE_KNOWN)
- && !(map_get_city(x, y) && !pplayers_allied(unit_owner(punit),
pplayer))
- && player_can_see_unit_at_location(pplayer, punit, x, y));
+ && player_can_see_unit_at_location(pplayer, punit, x, y)
+ && (!pcity || pplayers_allied(city_owner(pcity), pplayer)));
}
/***************************************************************
|
|