<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40407 >
> [nicorwadh - Sun Aug 10 21:28:18 2008]: > > Attached patch is one way of how this feature > could be implemented in current trunk version. I > created two new options in the game for this: > one on the server side called "seecitydefender", > which is disabled by default. Once enabled the > server will send the info about the strongest > unit occupying any city within vision so it can > be displayed. > > For the displaying on the client there is the > second option "draw_units_in_cities" that I > incorporated so far only in the gtk-2.0 GUI. This > is the reason why I enabled it by default, so > players using other GUI's that have no way yet > to change this view option will have no drawback > when playing on a server with seecitydefender > enabled. If this option is disabled on the > server side you should still be able to see full > unit stacks on top of own and allied cities with > the client side option enabled. I tried your patch, but it sometimes did not show the best defender (as in the one with the highest defence power). I used the editor to make a city, put a bunch of different units inside and moved them in and out of the city over a few turns). :? Style-wise, don't use camel case (e.g. defValue, refValue) when all the code around it uses underscores to seperate words in variable/function names. The biggest problem I have is the efficiency of can_player_see_city_defender. It should not be necessary to iterate the entire list of units in the city each time the result of this function is needed. I think a better design would be to have a field in the city struct that designates which unit is to be shown as the "best defender" (perhaps even just a unit type, unless the criteria for "best defender" also takes into account unit hitpoints). This field is set by the server whenever the units in the city change, and sent to the client in a city info packet if the client is allowed to known that information (server setting is set and client can see inside that city). Otherwise the client is sent an "empty" value for that field (e.g. -1 or whatever convention works). The client draws the "best defender" according to the information in the city field and if its own view option is set (it might be good to have a shortcut for this too). Generally, I agree with Per that "best defender" is a relative term so the client could be misled under certain circumstances, so I'm not really convinced of the benefit of having this feature. :| ----------------------------------------------------------------------- 聖戦じゃなくて、殺戮だと思った。 _______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev