[Freeciv-Dev] [bug #19272] The revolt_cost of a city can become negative.

2012-01-17 Thread Jacob Nevins

Update of bug #19272 (project freeciv):

  Status:  Ready For Test => Fixed  
 Open/Closed:Open => Closed 


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19272] The revolt_cost of a city can become negative.

2012-01-15 Thread Jacob Nevins

Follow-up Comment #4, bug #19272 (project freeciv):

Portability: "long long" isn't in C90, but "double" is.
(Yes, Freeciv already uses some C99 features, but this would be the first
explicit use of "long long" -- not something I want to introduce on a stable
branch at least.)

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19272] The revolt_cost of a city can become negative.

2012-01-15 Thread Michal Mazurek

Follow-up Comment #3, bug #19272 (project freeciv):

Why use double? 'long long int' can be used instead, it's 64-bit long.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19272] The revolt_cost of a city can become negative.

2012-01-15 Thread Jacob Nevins

Follow-up Comment #2, bug #19272 (project freeciv):

(Note that I haven't tried to address the wider issue of using "int" rather
than "unsigned int" for gold calculations in general, and the resulting
potential for overflow/underflow -- that would be a much bigger job.)

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19272] The revolt_cost of a city can become negative.

2012-01-15 Thread Jacob Nevins

Update of bug #19272 (project freeciv):

Severity:  3 - Normal => 4 - Important  
  Status:None => Ready For Test 
 Assigned to:None => jtn
 Release: => 2.2.7, 2.3.1   
 Planned Release: => 2.2.8, 2.3.2, 2.4.0,
2.5.0

___

Follow-up Comment #1:

Oh dear, that's embarrassing. Reproduced (see attached incite_test4 savefile
with the multiplayer ruleset -- try to incite Bordeaux).

So... I have a fix for this, but it's possible that you may not like the
effects.

The fix is simply to use double arithmetic rather than int in
city_incite_cost(). This calculates intermediate results much larger than the
final cost, and it's certainly plausible that these overflow with the
coefficients in the multiplayer ruleset.
For good measure, if the *final* cost ends up greater than
INCITE_IMPOSSIBLE_COST (_one BEELLEEON dollars_), then we just return
IMPOSSIBLE (not that this is likely to happen in practice).

I've verified the fix continues to give the same results in non-wrapping
cases (e.g., incite_test3 savefile).

What I've found is that, with the multiplayer ruleset at least (haven't
checked Longturn), it's rather easy to run into the "wrapping" range with
plausible scenarios -- I've run into trouble when the "correct" incite cost
exceeds about two million (the test file here is just over the edge). So, it
seems likely that some previously-positive-but-incorrect incite costs in real
games will become much bigger.

It would thus probably be a good idea to plausibility check the incite costs
if applying this fix to a running Longturn server.


(If we take a "baseline" incite cost (before other factors) to be
base_incite_cost * incite_total_factor / 100, then for the default ruleset we
start at 1000*100/100 = 1000 and it goes up and down (mostly up) from there,
but for the multiplayer ruleset we start at a cool million (1*1/100).
That doesn't leave much headroom for the other multiplicative factors before
running into trouble.)


(file #14791, file #14792, file #14793)
___

Additional Item Attachment:

File name: trunk-S2_4-S2_3-S2_2-city-incite-cost-negative.diff Size:1 KB
File name: incite_test4.sav.bz2   Size:12 KB
File name: incite_test3.sav.bz2   Size:12 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19272] The revolt_cost of a city can become negative.

2012-01-11 Thread anonymous

URL:
  

 Summary: The revolt_cost of a city can become negative.
 Project: Freeciv
Submitted by: None
Submitted on: Wed Jan 11 14:12:18 2012
Category: general
Severity: 3 - Normal
Priority: 5 - Normal
  Status: None
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Release: 
 Discussion Lock: Any
Operating System: Any
 Planned Release: 

___

Details:

In the multiplayer ruleset Book tweaked the incite cost of cities to increase
the cost by 1000. In the current longturn game using this multiplayer ruleset
the incite cost has now become negative.
I just received 360,000 gold for inciting someone else's city.

The problem presumably is a signed integer revolt_cost in diplomats.c I
suggest this becomes a double.




___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev