Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: init_techs integrated patch (PR#999)
Home

[Freeciv-Dev] Re: init_techs integrated patch (PR#999)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Arien Malec <arien_malec@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: init_techs integrated patch (PR#999)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 9 Oct 2001 12:16:43 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Oct 08, 2001 at 10:22:25PM -0700, Arien Malec wrote:
> Attached is a merged patch incorporating global and nation-specific init 
> techs.
> This includes my work (global) and the work of the FreecivAC team (nation
> specific). Some work was done to harmonize naming (e.g., the FreecivAC patch
> had a ruleset variable named free_tech; this patch calls it init_techs) and 
> use
> similar coding and data coventions (e.g., using A_LAST terminated tech 
> arrays).
> 
> Initial techs are useful for creating scenarios (e.g., modern warfare) and for
> testing. Nation-specific initial techs, combined with a multiply rooted tech
> tree, can be used to create special capabilities for specific nations.
> 
> Arien

>    struct {
>      char techs[MAX_LEN_NAME];
>      char units[MAX_LEN_NAME];
> @@ -182,6 +182,8 @@
>      int nuke_contamination;
>      int granary_food_ini;
>      int granary_food_inc;
> +    int *init_techs; /* Advances to assign to all players at game
> +                     start. A_LAST terminated.*/

Why is this dynamic and not init_techs[MAX_NUM_INIT_TECHS + 1]? Or
should MAX_NUM_INIT_TECHS be named MAX_NUM_NATION_INIT_TECHS?

> +
> +  /* Init techs */
> +  int     init_techs[MAX_NUM_INIT_TECHS + 1]; /* A_LAST terminated */

For easy grepping and easy distinction it would be nice if you rename
one of init_techs. May one init_techs and one global_init_techs?

> +    techs = secfile_lookup_str_vec(file, &dim, "%s.init_techs", sec[i]);
> +    if( dim > MAX_NUM_INIT_TECHS ) {
> +      freelog(LOG_VERBOSE,
> +              "Only %d initial techs can be given from %d"
> +           "defined for nation %s",
> +              MAX_NUM_INIT_TECHS, dim, pl->name_plural);
> +    }
> +    for(j = k = 0; j < dim; j++) {

Overrun. Either you limit dim to MAX_NUM_INIT_TECHS or bail out above.

>  /**************************************************************************
> +Lookup init techs from section file
> +**************************************************************************/
> +static int *secfile_lookup_init_techs (struct section_file *file)

This method contains the same? code as above. Please unify them.

        Raimar
-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "brand memory are for windows users that think their stability
   problems come from the memory"
    -- bomek in #freeciv



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