Author: cazfi
Date: Mon Nov 21 14:08:55 2016
New Revision: 34604

URL: http://svn.gna.org/viewcvs/freeciv?rev=34604&view=rev
Log:
Replace 'seen' vararray with buffer allocated with fc_calloc() in handling of
"Land Ahoy" achievement.

See patch #8007

Modified:
    trunk/common/achievements.c

Modified: trunk/common/achievements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/achievements.c?rev=34604&r1=34603&r2=34604&view=diff
==============================================================================
--- trunk/common/achievements.c (original)
+++ trunk/common/achievements.c Mon Nov 21 14:08:55 2016
@@ -288,13 +288,8 @@
     return pplayer->score.literacy >= ach->value;
   case ACHIEVEMENT_LAND_AHOY:
     {
-      bool seen[wld.map.num_continents];
-      int i;
+      bool *seen = fc_calloc(wld.map.num_continents, sizeof(bool));
       int count = 0;
-
-      for (i = 0; i < wld.map.num_continents; i++) {
-        seen[i] = FALSE;
-      }
 
       whole_map_iterate(ptile) {
         bool this_is_known = FALSE;
@@ -315,6 +310,7 @@
            *        to their current continent when they were last seen. */
           if (ptile->continent > 0 && !seen[ptile->continent]) {
             if (++count >= ach->value) {
+              free(seen);
               return TRUE;
             }
             seen[ptile->continent] = TRUE;
@@ -322,6 +318,7 @@
         }
       } whole_map_iterate_end;
 
+      free(seen);
       return FALSE;
     }
   case ACHIEVEMENT_COUNT:


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

Reply via email to