[Freeciv-Dev] Re: (PR#9898) civserver crashes on multiple games with dif
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#9898) civserver crashes on multiple games with different sizes |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Wed, 1 Sep 2004 12:29:21 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9898 >
Jason Short wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=9898 >
>
> Run the server with a map of size 1.
>
> Then don't exit the server, but run it again on a map of size 29.
>
> Boom!
>
> One culprit is local_vector in gotohand.c:find_the_shortest_path().
> This patch fixes that. But I think there are other problems also.
Mateusz pointed out a second culprit in init_warmap.
jason
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.182
diff -u -r1.182 gotohand.c
--- server/gotohand.c 1 Sep 2004 19:24:36 -0000 1.182
+++ server/gotohand.c 1 Sep 2004 19:28:38 -0000
@@ -194,12 +194,14 @@
**************************************************************************/
static void init_warmap(int orig_x, int orig_y, enum unit_move_type move_type)
{
- if (!warmap.cost) {
- warmap.cost = fc_malloc(map.xsize * map.ysize * sizeof(*warmap.cost));
- warmap.seacost = fc_malloc(map.xsize * map.ysize
- * sizeof(*warmap.seacost));
- warmap.vector = fc_malloc(map.xsize * map.ysize
- * sizeof(*warmap.vector));
+ if (warmap.size != MAX_MAP_INDEX) {
+ warmap.cost = fc_realloc(warmap.cost,
+ MAX_MAP_INDEX * sizeof(*warmap.cost));
+ warmap.seacost = fc_realloc(warmap.seacost,
+ MAX_MAP_INDEX * sizeof(*warmap.seacost));
+ warmap.vector = fc_realloc(warmap.vector,
+ MAX_MAP_INDEX * sizeof(*warmap.vector));
+ warmap.size = MAX_MAP_INDEX;
}
init_queue();
Index: server/gotohand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.h,v
retrieving revision 1.29
diff -u -r1.29 gotohand.h
--- server/gotohand.h 10 Oct 2003 19:29:06 -0000 1.29
+++ server/gotohand.h 1 Sep 2004 19:28:38 -0000
@@ -51,6 +51,8 @@
unsigned char *cost;
unsigned char *seacost;
unsigned char *vector;
+ int size;
+
struct city *warcity; /* so we know what we're dealing with here */
struct unit *warunit; /* so we know what we're dealing with here */
int orig_x, orig_y;
- [Freeciv-Dev] Re: (PR#9898) civserver crashes on multiple games with different sizes,
Jason Short <=
|
|