Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Logical operator inversion in citytools.c (PR#913)
Home

[Freeciv-Dev] Logical operator inversion in citytools.c (PR#913)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Logical operator inversion in citytools.c (PR#913)
From: rwetmore@xxxxxxxxxxxx
Date: Sat, 25 Aug 2001 22:06:59 -0700 (PDT)

Full_Name: Ross Wetmore
Version: cvs-Aug-25
Distribution: Don't know
Client: Both (or N/A)
OS: RedHat Linux 7.0
Submission from: (NULL) (65.92.47.30)


Logical operator inversion causes cartesian rather than centre square to
be checked for food. Problem if city is polar, or near non-wrap border.

Cheers,
RossW
=====
Suggested fix:

--- ../.freeciv-Aug-25/server/citytools.c   Sat Aug 25 07:56:32 2001
+++ server/citytools.c  Sun Aug 26 00:54:51 2001
@@ -217,7 +217,7 @@
 {
   int best = 0, tmp;
   city_map_iterate(x, y) {
-    if ((x == 2 || y == 2) ||
+    if ((x == 2 && y == 2) ||
    (get_worker_city(pcity, x, y) == C_TILE_WORKER) ||
    can_place_worker_here(pcity, x, y)) {
       tmp = city_tile_value(pcity, x, y, 0, 0);

Game saved as civgame-750.sav.gz
> civserver: map.c:1352: map_get_special: Assertion `is_real_tile(x,y)' failed.

real    0m14.137s
user    0m14.070s
sys 0m0.040s

(gdb) where
#0  0x2ab23131 in __kill () from /lib/libc.so.6
#1  0x2ab22ead in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x2ab24534 in abort () at ../sysdeps/generic/abort.c:88
#3  0x2ab1c8e1 in __assert_fail (assertion=0x80cbb92 "is_real_tile(x,y)",
    file=0x80cb999 "map.c", line=1352, function=0x80cbbf1 "map_get_special")
    at assert.c:60
#4  0x80936be in map_get_special (x=10, y=50) at map.c:1352
#5  0x808b295 in city_get_food_tile (x=2, y=4, pcity=0x827e508) at city.c:679
#6  0x805e1b9 in city_tile_value (pcity=0x827e508, x=2, y=4, foodneed=0,
    prodneed=0) at citytools.c:181
#7  0x805e394 in best_worker_tile_value (pcity=0x827e508) at citytools.c:223
#8  0x8088b21 in initialize_infrastructure_cache (pcity=0x827e508)
    at settlers.c:1390
#9  0x805f407 in create_city (pplayer=0x8128d4c, x=10, y=48,
    name=0x7ffff7e0 "Bielany") at citytools.c:902
#10 0x8053ef9 in city_build (pplayer=0x8128d4c, punit=0x824c098,
    name=0x7ffff7e0 "Bielany") at unithand.c:522
#11 0x8053f48 in handle_unit_build_city (pplayer=0x8128d4c, req=0x7ffff7d0)
    at unithand.c:542
#12 0x8085a7d in ai_do_build_city (pplayer=0x8128d4c, punit=0x824c098)
    at settlers.c:63
#13 0x8088ae3 in auto_settler_findwork (pplayer=0x8128d4c, punit=0x824c098)
    at settlers.c:1374
#14 0x8088d7c in auto_settlers_player (pplayer=0x8128d4c) at settlers.c:1433
#15 0x80891fe in auto_settlers () at settlers.c:1543
#16 0x804e8e4 in main_loop () at srv_main.c:1717
#17 0x804eef4 in srv_main () at srv_main.c:1968
#18 0x8049b65 in main (argc=3, argv=0x7ffff9a4) at civserver.c:147
#19 0x2ab12790 in __libc_start_main (main=0x804964c <main>, argc=3,
    ubp_av=0x7ffff9a4, init=0x8049060 <_init>, fini=0x80b260c <_fini>,
    rtld_fini=0x2aab835c <_dl_fini>, stack_end=0x7ffff99c)
    at ../sysdeps/generic/libc-start.c:111
(gdb) up 3
#3  0x2ab1c8e1 in __assert_fail (assertion=0x80cbb92 "is_real_tile(x,y)",
    file=0x80cb999 "map.c", line=1352, function=0x80cbbf1 "map_get_special")
    at assert.c:60
60  assert.c: No such file or directory.
(gdb) up 2
#5  0x808b295 in city_get_food_tile (x=2, y=4, pcity=0x827e508) at city.c:679
679   enum tile_special_type spec_t=map_get_special(pcity->x+x-2,
pcity->y+y-2);(gdb) print *pcity
$2 = {id = 323, owner = 2, x = 10, y = 48,
  name = "Bielany\000en_US/LC_MESSAGES/freeci", size = 1, ppl_happy = {0, 0,
    0, 0, 0}, ppl_content = {1, 1, 1, 1, 1}, ppl_unhappy = {0, 0, 0, 0, 0},
  ppl_elvis = 0, ppl_scientist = 0, ppl_taxman = 0, trade = {0, 0, 0, 0},
  trade_value = {0, 0, 0, 0}, food_prod = 3, food_surplus = 1,
  shield_prod = 1, shield_surplus = 1, trade_prod = 2, corruption = 0,
  tile_trade = 2, shield_bonus = 100, tax_bonus = 100, science_bonus = 100,
  luxury_total = 0, tax_total = 1, science_total = 1, food_stock = 0,
  shield_stock = 0, pollution = 0, incite_revolt_cost = 65,
  is_building_unit = 1, currently_building = 3,
  improvements = '\000' <repeats 68 times>,
"\020\000\000\000Hæ'\b(æ'\bð\n\000\000\020\000\000\000Xæ'\b8æ'\b\000\013\000\000\020\000\000\000hæ'\bHæ'\b\020\013\000\000\020\000\000\000xæ'\bXæ'\b
\013\000\000\020\000\000\000\210æ'\bhæ'\b0\013\000\000\020\000\000\000\230æ'\bxæ'\b@\013\000\000\020\000\000\000¨æ'\b\210æ'\bP\013\000\000\020\000\000\000¸æ'\b\230æ'\b`\013\000\000\020\000\000",
  worklist = 0x827ecb0, city_map = {{C_TILE_UNAVAILABLE, C_TILE_UNAVAILABLE,
      C_TILE_EMPTY, C_TILE_EMPTY, C_TILE_UNAVAILABLE}, {C_TILE_EMPTY,
      C_TILE_EMPTY, C_TILE_EMPTY, C_TILE_EMPTY, C_TILE_UNAVAILABLE}, {
      C_TILE_EMPTY, C_TILE_WORKER, C_TILE_WORKER, C_TILE_EMPTY,
      C_TILE_UNAVAILABLE}, {C_TILE_UNAVAILABLE, C_TILE_EMPTY, C_TILE_EMPTY,
      C_TILE_EMPTY, C_TILE_UNAVAILABLE}, {C_TILE_UNAVAILABLE,
      C_TILE_UNAVAILABLE, C_TILE_UNAVAILABLE, C_TILE_UNAVAILABLE,
      C_TILE_UNAVAILABLE}}, units_supported = {list = {nelements = 0,
      null_link = {next = 0x827e724, prev = 0x827e724, dataptr = 0x0},
      head_link = 0x827e724, tail_link = 0x827e724}}, steal = 0, did_buy = -1,
  did_sell = 3056, is_updated = 16, turn_last_built = -625,
  turn_changed_target = -625, changed_from_id = 0, changed_from_is_unit = 0,
  disbanded_shields = 0, caravan_shields = 0, before_change_shields = 0,
  anarchy = 0, rapture = 0, was_happy = 0, airlift = 0, original = 2,
  city_options = 15, synced = 0, info_units_supported = {list = {
      nelements = 3120, null_link = {next = 0x10, prev = 0x827e798,
        dataptr = 0x827e778}, head_link = 0xc40, tail_link = 0x10}},
  info_units_present = {list = {nelements = 136832936, null_link = {
        next = 0x827e788, prev = 0xc50, dataptr = 0x10},
      head_link = 0x827e7b8, tail_link = 0x827e798}}, ai = {workremain = 1,
    ai_role = 0, building_want = {0 <repeats 200 times>}, danger = -1,
    diplomat_threat = 136833736, urgency = 3984, grave_danger = 16,
    wallvalue = 136833784, trade_want = 10, choice = {choice = 4000,
      want = 16, type = 136833800}, downtown = 136833768,
    distance_to_wonder_city = 4016, detox = {{16, 0, -5352, 2087, -5384}, {
        2087, 4032, 0, 16, 0}, {-5336, 2087, -5368, 2087, 4048}, {0, 16, 0,
        -5320, 2087}, {-5352, 2087, 4064, 0, 16}}, derad = {{0, -5304, 2087,
        -5336, 2087}, {4080, 0, 16, 0, -5288}, {2087, -5320, 2087, 4096, 0}, {
        16, 0, -5272, 2087, -5304}, {2087, 4112, 0, 16, 0}}, mine = {{-5256,
        2087, -5288, 2087, 4128}, {0, 16, 0, -5240, 2087}, {-5272, 2087, 4144,
        0, 16}, {0, -5224, 2087, -5256, 2087}, {4160, 0, 16, 0, -5208}},
    irrigate = {{2087, -5240, 2087, 4176, 0}, {16, 0, -5192, 2087, -5224}, {
        2087, 4192, 0, 16, 0}, {-5176, 2087, -5208, 2087, 4208}, {0, 16, 0,
        -5160, 2087}}, road = {{-5192, 2087, 4224, 0, 16}, {0, -5144, 2087,
        -5000, 2087, 4416, 0}}, settler_want = 16, founder_want = 136834216,
    a = 136834184, f = 4432, invasion = 16}}
(gdb)  






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