<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40407 >

> [book - Mo 11. Aug 2008, 20:29:57]:
> 
> 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). :?

I used to test it with the editor as well and noticed that it seems not
to be using the send_unit_info_to_onlookers when placing units in
cities, so I could see whole stacks of units with the latest one placed
on top. To circumvent this I used to fog and unfog the given city and
then I could only see just one unit, which was the "strongest" as
determined by the value of get_defense_power (whatever calculations this
function does).

> 
> 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.

Oh sorry about that, I really got this problem of dropping the bad
habbits I picked up with Java. ;)

> 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.

Well that was just a quick shot as I noticed that it was the
can_player_see_unit function that prevented the client to actually get
the info about any units in a city I worked this extra check out to send
at least the one unit strongest in a city.

> 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).

Yeah, I agree that this would be the better way to realise this feature
way more runtime friendly. I'd imagine this won't be easy and could
bring some potential dangers for the source. Especially as fiddling with
structures like info packages (or even the city struct itself) inherits
a great potential for introducing new unforseeable bugs to the code
base, as I noticed it with other bugs I worked on here. I would be
willing to spend my efforts on that, if they are worth for anything
good. But before I start messing up your neat code base here I believe
that you and other senior programmers here should agree upon whether or
not such a feature is even wanted here.
 
> 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. :|

This get_best_defender function comes up with quite a lot of odd results
that are puzzling me as a former payciv gamer, no matter if this feature
here is implemented or not. For example it lets me kill non military
units before any strong unit in a city if I attack with something
rediculus strong like an howitzer. Once the non military units are gone
and you continue attacking with the strong units it lets the howitzer
sink an aircraft carrier before a marines unit which is... well just
imagine if you'd read this in an history book about the battle of Iwo
Jima...

Maybe there should be another option letting the get_best_defender
function return the strongest units of the same type (ground/naval/air)
first just like the payciv city attacks were handled?

Greetings,
Nico

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

Reply via email to