Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: PATCH: AI cleanup Version 2
Home

[Freeciv-Dev] Re: PATCH: AI cleanup Version 2

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Raahul Kumar <raahul_da_man@xxxxxxxxx>, Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: PATCH: AI cleanup Version 2
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Fri, 23 Nov 2001 22:11:46 +0100

> This is a formatting change. See past threads about such changes.
They are meant to improve readibility. But ok.. I only stick on
unit_move_turns() indentation correct, that fault was introduced
by the previous patch anyway, so it wouldn't introduce any diffs
into the code itself.

> I will definitely not accept changes which remove {}. 
Ok.

> > +  
> >    if (pcity->ai.building_want[B_SAM] > 0 && danger4) {
> >      i = assess_defense_igwall(pcity);
> > +    
> >      if (!i) pcity->ai.building_want[B_SAM] = 100 + urgency;
> >      else if (danger4 > i * 2) pcity->ai.building_want[B_SAM] = 200 + 
> > urgency;
> >      else pcity->ai.building_want[B_SAM] = danger4 * 100 / i;
> >    }
> > +  
> >    if (pcity->ai.building_want[B_SDI] > 0 && danger5) {
> >      i = assess_defense_igwall(pcity);
> > +    
> >      if (!i) pcity->ai.building_want[B_SDI] = 100 + urgency;
> >      else if (danger5 > i * 2) pcity->ai.building_want[B_SDI] = 200 + 
> > urgency;
> >      else pcity->ai.building_want[B_SDI] = danger5 * 100 / i;
> >    }
> > +  
> >    pcity->ai.urgency = urgency; /* need to cache this for bodyguards now -- 
> > Syela */
> >    return(urgency);
> >  }
> 
> Such changes are only noise.
You can read the code reasonably then. Most of applications are written
with sane indentation, so one doesn't have to spend time uselessly decrypting
messy code.

>                              Also note that i can be declared local
> (which I prefer).
It can't, as above you use it in top-level for. I would have to add special
block for it there, and indent the half of function for that. Too many
useless indendation levels for one variable, it will make it rather worse.
Otherwise, I prefer local declared variables too.

> Overall I have to look at the other changes in detail. It may also be
> nice if you add some docu to the variables. Like in
> 
> /* 
>  * Desire to get the unit denotes by "punit". Value range is [0,100)
>  * where 0 means no interest. 
>  */
> int udesire;
That would, I will add some for variables which looks uncertain in my
opinion. Also, there come more ideas to my mind, what should be cleaned
up there, as I look at the code after some while... I will send you
modified patch w/o some format changes and with several other things
cleaned up this night or tommorow.

-- 

                                Petr "Pasky" Baudis

UN*X programmer, UN*X administrator, hobbies = IPv6, IRC
Real Users hate Real Programmers.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/


[Prev in Thread] Current Thread [Next in Thread]