Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#8791) crash with civ1 ruleset
Home

[Freeciv-Dev] Re: (PR#8791) crash with civ1 ruleset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8791) crash with civ1 ruleset
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Fri, 21 May 2004 23:24:14 -0700
Reply-to: rt@xxxxxxxxxxx

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

On Fri, May 21, 2004 at 06:12:33PM -0700, Jason Short wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8791 >
> 
> Gregory Berkolaiko wrote:
> 
> > I am not too sure what shall we do about it.  multiplication by 10 is for
> > veteran bonuses not to get lost.  Later division by 30 is to keep numbers
> > sane for larger units in default/civ2 rulesets.
> 
> What about either:
> 
> - Making it use floating point values?
> 
> or
> 
> - Calculating the POWER_DIVIDER when we load the ruleset?

What about this patch? It works for both RCc you posted.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Premature optimization is the root of all evil."
    -- D. E. Knuth in "Structured Programming with go to Statements"

Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.165
diff -u -u -r1.165 advmilitary.c
--- ai/advmilitary.c    2 May 2004 12:31:05 -0000       1.165
+++ ai/advmilitary.c    22 May 2004 06:15:58 -0000
@@ -798,6 +798,10 @@
       
       /* Take into account reinforcements strength */
       if (acity) attack += acity->ai.attack;
+
+      if (attack == 0) {
+       continue;
+      }
       
       attack *= attack;
 
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.315
diff -u -u -r1.315 aiunit.c
--- ai/aiunit.c 19 May 2004 14:40:15 -0000      1.315
+++ ai/aiunit.c 22 May 2004 06:16:01 -0000
@@ -818,6 +818,8 @@
 {
   int desire;
 
+  assert(attack > 0);
+
   /*         attractiveness     danger */ 
   desire = ((benefit * attack - loss * vuln) * victim_count * SHIELD_WEIGHTING
             / (attack + vuln * victim_count));

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