Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] Re: (PR#9310) startunits
Home

[Freeciv-Dev] Re: (PR#9310) startunits

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ggracian@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#9310) startunits
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sat, 25 Sep 2004 04:18:07 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9310 >

Marko Lindqvist wrote:

> Genevieve Gracian wrote:
> 
>>The string for startunits is limited to 15 characters, makes 15 units
>>max but on stable version it's possible to have 20 units (10 settlers
>>and 10 explos). Is the new max number of units wanted?
> 
>   Attached patch takes care of the most critical part of this ticket; 
> savegame loading was not checking array bounds when loading old saves, 
> so loading such an old game with > 15 startunits got out of bounds.

  This version also increases limit to 20 units. Turned out that not 
even network compatibility nor old clients break.


  - Caz


diff -Nurd -X.diff_ignore freeciv/common/game.h freeciv/common/game.h
--- freeciv/common/game.h       2004-09-24 18:17:00.890625000 +0300
+++ freeciv/common/game.h       2004-09-25 14:00:53.750000000 +0300
@@ -31,7 +31,7 @@
 #define MAX_LEN_ALLOW_TAKE 16
 #define MAX_ID_LEN 33
 #define MAX_GRANARY_INIS 24
-#define MAX_LEN_STARTUNIT 16
+#define MAX_LEN_STARTUNIT (20+1)
 
 enum server_states { 
   PRE_GAME_STATE, 
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2004-09-24 18:18:15.453125000 +0300
+++ freeciv/server/savegame.c   2004-09-25 13:59:02.921875000 +0300
@@ -3108,10 +3108,10 @@
          int settlers = secfile_lookup_int(file, "game.settlers");
          int explorer = secfile_lookup_int(file, "game.explorer");
          int i;
-         for (i = 0; settlers>0; i++, settlers--) {
+         for (i = 0; settlers > 0 && i < MAX_LEN_STARTUNIT ; i++, settlers--) {
            game.start_units[i] = 'c';
          }
-         for (; explorer>0; i++, explorer--) {
+         for (; explorer > 0 && i < MAX_LEN_STARTUNIT ; i++, explorer--) {
            game.start_units[i] = 'x';
          }
          game.start_units[i] = '\0';

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