diff -urd -X freeciv.clean/diff_ignore part_app/server/sanitycheck.c work/server/sanitycheck.c --- part_app/server/sanitycheck.c Fri Feb 22 14:07:32 2002 +++ work/server/sanitycheck.c Sat Feb 23 15:51:38 2002 @@ -40,7 +40,7 @@ if (contains_special(special, S_FARMLAND)) assert(special & S_IRRIGATION); if (contains_special(special, S_SPECIAL_1)) - assert(!(special & S_SPECIAL_2)); + assert(!contains_special(special, S_SPECIAL_2)); if (contains_special(special, S_MINE)) assert(get_tile_type(terrain)->mining_result == terrain); @@ -186,7 +186,8 @@ struct tile *ptile = map_get_tile(x, y); if (ptile->worked) { struct city *pcity = ptile->worked; - int city_x, city_y, is_valid; + int city_x, city_y; + bool is_valid; is_valid = map_to_city_map(&city_x, &city_y, pcity, x, y); assert(is_valid); @@ -215,7 +216,7 @@ assert(unit_owner(punit) == pplayer); assert(is_real_tile(x, y)); - if (punit->homecity) { + if (punit->homecity != 0) { pcity = player_find_city_by_id(pplayer, punit->homecity); assert(pcity != NULL); assert(city_owner(pcity) == pplayer); diff -urd -X freeciv.clean/diff_ignore part_app/server/savegame.c work/server/savegame.c --- part_app/server/savegame.c Sat Feb 23 10:10:32 2002 +++ work/server/savegame.c Sat Feb 23 16:01:28 2002 @@ -282,7 +282,7 @@ { int i=0, pos; - map.fixed_start_positions = secfile_lookup_int_default(file, 0, "map.fixed_start_positions"); + map.fixed_start_positions = secfile_lookup_bool_default(file, FALSE, "map.fixed_start_positions"); while( (pos = secfile_lookup_int_default(file, -1, "map.r%dsx", i)) != -1) { map.start_positions[i].x = pos; @@ -339,7 +339,7 @@ LOAD_MAP_DATA(secfile_lookup_str_default(file, NULL, "map.n%03d", y), map_get_tile(x, y)->special |= (ascii_hex2bin(ch, 2) & S_RIVER)); - map.have_rivers_overlay = 1; + map.have_rivers_overlay = TRUE; } /*************************************************************** @@ -360,7 +360,7 @@ map_startpos_load(file); } else { map.num_start_positions = 0; - map.fixed_start_positions = 0; + map.fixed_start_positions = FALSE; } /* get 4-bit segments of 16-bit "special" field. */ @@ -400,7 +400,7 @@ } - map.have_specials = 1; + map.have_specials = TRUE; /* Should be handled as part of send_all_know_tiles, but do it here too for safety */ @@ -423,7 +423,7 @@ secfile_insert_bool(file, game.save_options.save_starts, "game.save_starts"); if (game.save_options.save_starts) { - secfile_insert_int(file, map.fixed_start_positions, "map.fixed_start_positions"); + secfile_insert_bool(file, map.fixed_start_positions, "map.fixed_start_positions"); for (i=0; iwlefs[i] == WEF_IMPR) && !improvement_exists(pwl->wlids[i]))) { pwl->wlefs[i] = WEF_END; pwl->wlids[i] = 0; - end = 1; + end = TRUE; } } } @@ -534,7 +535,8 @@ char *path, int plrno, int wlinx, struct worklist *pwl) { - int i, id, end = 0; + int i, id; + bool end = FALSE; for (i = 0; i < MAX_LEN_WORKLIST; i++) { if (end) { @@ -547,7 +549,7 @@ if ((id < 0) || (id >= 284)) { /* 284 was flag value for end of list */ pwl->wlefs[i] = WEF_END; pwl->wlids[i] = 0; - end = 1; + end = TRUE; } else if (id >= 68) { /* 68 was offset to unit ids */ pwl->wlefs[i] = WEF_UNIT; pwl->wlids[i] = id - 68; @@ -713,7 +715,7 @@ ship->life_support = secfile_lookup_int(file, "%s.life_support", prefix); ship->solar_panels = secfile_lookup_int(file, "%s.solar_panels", prefix); st = secfile_lookup_str(file, "%s.structure", prefix); - for(i=0; istructure[i] = ((*st) == '1'); } if (ship->state >= SSHIP_LAUNCHED) { @@ -813,7 +815,7 @@ pcity->airlift=secfile_lookup_bool(file, "player%d.c%d.airlift", plrno,i); else - pcity->airlift=0; + pcity->airlift = FALSE; pcity->city_options = secfile_lookup_int_default(file, CITYOPT_DEFAULT, @@ -852,7 +854,8 @@ city_map_to_map(&map_x, &map_y, pcity, x, y) ? C_TILE_EMPTY : C_TILE_UNAVAILABLE); } else if (*p=='1') { - int map_x, map_y, is_real; + int map_x, map_y; + bool is_real; is_real = city_map_to_map(&map_x, &map_y, pcity, x, y); assert(is_real); @@ -887,7 +890,7 @@ ceff_vector_init(&pcity->effects); for(x=0; xpos[j].x)) + if (sscanf(goto_buf_ptr, "%d", &pgr->pos[j].x) == 0) abort(); while (*goto_buf_ptr != ',') { goto_buf_ptr++; @@ -1015,7 +1018,7 @@ goto_buf = secfile_lookup_str(file, "player%d.u%d.goto_route_y", plrno, i); goto_buf_ptr = goto_buf; for (j = 0; j < len; j++) { - if (!sscanf(goto_buf_ptr, "%d", &pgr->pos[j].y)) + if (sscanf(goto_buf_ptr, "%d", &pgr->pos[j].y) == 0) abort(); while (*goto_buf_ptr != ',') { goto_buf_ptr++; @@ -1123,7 +1126,7 @@ 3) is not from a "unit only" fog of war save file */ if (secfile_lookup_int_default(file, -1, "game.fogofwar") != -1 - && game.fogofwar == 1 + && game.fogofwar == TRUE && secfile_lookup_int_default(file, -1,"player%d.total_ncities", plrno) != -1 && secfile_lookup_bool_default(file, TRUE, "game.save_private_map") && game.load_options.load_private_map) { @@ -1172,7 +1175,7 @@ y = secfile_lookup_int(file, "player%d.dc%d.y", plrno, j); sz_strlcpy(pdcity->name, secfile_lookup_str(file, "player%d.dc%d.name", plrno, j)); pdcity->size = secfile_lookup_int(file, "player%d.dc%d.size", plrno, j); - pdcity->has_walls = secfile_lookup_int(file, "player%d.dc%d.has_walls", plrno, j); + pdcity->has_walls = secfile_lookup_bool(file, "player%d.dc%d.has_walls", plrno, j); pdcity->owner = secfile_lookup_int(file, "player%d.dc%d.owner", plrno, j); map_get_player_tile(x, y, plr)->city = pdcity; alloc_id(pdcity->id); @@ -1298,7 +1301,7 @@ char vision[MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS+1]; for (i=0; i < MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS; i++) - vision[i] = plr->gives_shared_vision & (1 << i) ? '1' : '0'; + vision[i] = TEST_BIT(plr->gives_shared_vision, i) ? '1' : '0'; vision[i] = '\0'; secfile_insert_str(file, vision, "player%d.gives_shared_vision", plrno); } @@ -1488,7 +1491,7 @@ "player%d.c%d.currently_building", plrno, i); for(j=0; jimprovements[j]) ? '1' : '0'; + buf[j]=(pcity->improvements[j] != I_NONE) ? '1' : '0'; buf[j]='\0'; secfile_insert_str(file, buf, "player%d.c%d.improvements", plrno, i); @@ -1553,7 +1556,7 @@ plrno, i); secfile_insert_int(file, pdcity->size, "player%d.dc%d.size", plrno, i); - secfile_insert_int(file, pdcity->has_walls, + secfile_insert_bool(file, pdcity->has_walls, "player%d.dc%d.has_walls", plrno, i); secfile_insert_int(file, pdcity->owner, "player%d.dc%d.owner", plrno, i); @@ -1654,7 +1657,7 @@ static void check_city(struct city *pcity) { city_map_iterate(x, y) { - int res = city_can_work_tile(pcity, x, y); + bool res = city_can_work_tile(pcity, x, y); switch (pcity->city_map[x][y]) { case C_TILE_EMPTY: if (!res) { @@ -1664,7 +1667,8 @@ break; case C_TILE_WORKER: if (!res) { - int map_x, map_y, is_real; + int map_x, map_y; + bool is_real; pcity->ppl_elvis++; set_worker_city(pcity, x, y, C_TILE_UNAVAILABLE); @@ -1916,7 +1920,7 @@ /* aka a "scenario" */ if (has_capability("specials",savefile_options)) { map_load(file); - map.fixed_start_positions = 1; + map.fixed_start_positions = TRUE; return; } map_tiles_load(file); @@ -1925,7 +1929,7 @@ } if (has_capability("startpos",savefile_options)) { map_startpos_load(file); - map.fixed_start_positions = 1; + map.fixed_start_positions = TRUE; return; } return; @@ -1954,11 +1958,11 @@ &rstate.v[7*i+1], &rstate.v[7*i+2], &rstate.v[7*i+3], &rstate.v[7*i+4], &rstate.v[7*i+5], &rstate.v[7*i+6]); } - rstate.is_init = 1; + rstate.is_init = TRUE; set_myrand_state(rstate); } else { /* mark it */ - secfile_lookup_int_default(file, 1, "game.save_random"); + secfile_lookup_bool_default(file, TRUE, "game.save_random"); } @@ -1980,7 +1984,7 @@ if (!game.is_new_game && game.load_options.load_players) { /* destroyed wonders: */ string = secfile_lookup_str_default(file, "", "game.destroyed_wonders"); - for(i=0; iused && pconn->send_buffer->ndata) { + if(pconn->used && pconn->send_buffer->ndata > 0) { FD_SET(pconn->sock, &writefs); FD_SET(pconn->sock, &exceptfs); max_desc=MAX(pconn->sock, max_desc); @@ -276,11 +276,11 @@ conn_description(pconn)); close_socket_callback(pconn); } else { - if(pconn->send_buffer && pconn->send_buffer->ndata) { + if(pconn->send_buffer && pconn->send_buffer->ndata > 0) { if(FD_ISSET(pconn->sock, &writefs)) { flush_connection_send_buffer_all(pconn); } else { - if(game.tcptimeout && pconn->last_write + if(game.tcptimeout != 0 && pconn->last_write != 0 && (time(NULL)>pconn->last_write + game.tcptimeout)) { freelog(LOG_NORMAL, "cut connection %s due to lagging player", conn_description(pconn)); @@ -347,7 +347,7 @@ if(year!=game.year) { if (server_state == RUN_GAME_STATE) year=game.year; } - if (!game.timeout) + if (game.timeout == 0) game.turn_start = time(NULL); while(TRUE) { @@ -361,10 +361,10 @@ /* quit server if no players for 'srvarg.quitidle' seconds */ - if (srvarg.quitidle && server_state != PRE_GAME_STATE) { + if (srvarg.quitidle != 0 && server_state != PRE_GAME_STATE) { static time_t last_noplayers; if(conn_list_size(&game.est_connections) == 0) { - if (last_noplayers) { + if (last_noplayers != 0) { if (time(NULL)>last_noplayers + srvarg.quitidle) { sz_strlcpy(srvarg.metaserver_info_line, "restarting for lack of players"); @@ -443,7 +443,7 @@ for(i=0; indata) { + if(connections[i].send_buffer->ndata > 0) { FD_SET(connections[i].sock, &writefs); } FD_SET(connections[i].sock, &exceptfs); @@ -454,7 +454,7 @@ if(select(max_desc+1, &readfs, &writefs, &exceptfs, &tv)==0) { /* timeout */ send_server_info_to_metaserver(FALSE, FALSE); - if((game.timeout) + if(game.timeout != 0 && (time(NULL)>game.turn_start + game.timeout) && (server_state == RUN_GAME_STATE)){ con_prompt_off(); @@ -481,7 +481,7 @@ #endif /* !__VMS */ } } - if (!game.timeout) + if (game.timeout == 0) game.turn_start = time(NULL); if(FD_ISSET(sock, &exceptfs)) { /* handle Ctrl-Z suspend/resume */ @@ -599,11 +599,11 @@ for(i=0; iused && pconn->send_buffer && pconn->send_buffer->ndata) { + if(pconn->used && pconn->send_buffer && pconn->send_buffer->ndata > 0) { if(FD_ISSET(pconn->sock, &writefs)) { flush_connection_send_buffer_all(pconn); } else { - if(game.tcptimeout && pconn->last_write + if(game.tcptimeout != 0 && pconn->last_write != 0 && (time(NULL)>pconn->last_write + game.tcptimeout)) { freelog(LOG_NORMAL, "cut connection %s due to lagging player", conn_description(pconn)); @@ -617,7 +617,7 @@ } con_prompt_off(); - if((game.timeout) + if(game.timeout != 0 && (time(NULL)>game.turn_start + game.timeout)) return 0; return 1; @@ -789,7 +789,7 @@ int request_id) { assert(request_id); - assert(!pconn->server.currently_processed_request_id); + assert(pconn->server.currently_processed_request_id == 0); freelog(LOG_DEBUG, "start processing packet %d from connection %d", request_id, pconn->id); if (strlen(pconn->capability) == 0 diff -urd -X freeciv.clean/diff_ignore part_app/server/settlers.c work/server/settlers.c --- part_app/server/settlers.c Fri Feb 22 14:07:32 2002 +++ work/server/settlers.c Sat Feb 23 16:24:26 2002 @@ -91,14 +91,14 @@ int s = 1; assert(delay >= 0); if (benefit < 0) { s = -1; benefit *= s; } - while (delay && benefit) { + while (delay > 0 && benefit != 0) { denom = 1; - while (delay >= 12 && !(benefit>>28) && !(denom>>27)) { + while (delay >= 12 && (benefit >> 28) == 0 && (denom >> 27) == 0) { benefit *= 3; /* this is a kluge but it is 99.9% accurate and saves time */ denom *= 5; /* as long as MORT remains 24! -- Syela */ delay -= 12; } - while (!(benefit>>25) && delay && !(denom>>25)) { + while ((benefit >> 25) == 0 && delay > 0 && (denom >> 25) == 0) { benefit *= num; denom *= MORT; delay--; @@ -235,7 +235,7 @@ /* all of these kluges are hardcoded amortize calls to save much CPU use -- Syela */ } else if (ptile->terrain == T_OCEAN && har) food[i][j] += MORT; /* harbor */ shield[i][j] = get_tile_shield_base(ptile) * sh; - if (is_city_center(i, j) && !shield[i][j]) { + if (is_city_center(i, j) && shield[i][j] == 0) { shield[i][j] = sh; } if (ptile->terrain == T_OCEAN && har) shield[i][j] += sh; @@ -256,8 +256,8 @@ else if (con2 == con) road[i][j] = t * ptype->road_trade_incr - 70; /* KLUGE */ /* actualy exactly 70 1/2 */ } - if (trade[i][j]) trade[i][j] += t; - else if (road[i][j]) road[i][j] += t; + if (trade[i][j] != 0) trade[i][j] += t; + else if (road[i][j] != 0) road[i][j] += t; } } city_map_checked_iterate_end; @@ -275,7 +275,7 @@ jj = j; } } city_map_iterate_end; - if (!best) return(0); + if (best == 0) return(0); val = (shield[ii][jj] + mine[ii][jj]) + (food[ii][jj] + irrig[ii][jj]) * FOOD_WEIGHTING + /* seems to be needed */ (trade[ii][jj] + road[ii][jj]); @@ -288,7 +288,7 @@ } f = food[2][2] + irrig[2][2]; - if (!f) return(0); /* no starving cities, thank you! -- Syela */ + if (f == 0) return(0); /* no starving cities, thank you! -- Syela */ val = f * FOOD_WEIGHTING + /* this needs to be here, strange as it seems */ (shield[2][2] + mine[2][2]) + (trade[2][2] + road[2][2]); @@ -307,13 +307,13 @@ x, y, val, har, f); for (n = 1; n <= 20 && f > 0; n++) { - for (a = 1; a; a--) { + for (a = 1; a > 0; a--) { best = 0; worst = -1; b2 = 0; i0 = 0; j0 = 0; ii = 0; jj = 0; city_map_iterate(i, j) { cur = (food[i][j]) * food_weighting(n) + /* ignoring irrig on purpose */ (shield[i][j] + mine[i][j]) + (trade[i][j] + road[i][j]); - if (!taken[i][j]) { + if (taken[i][j] == 0) { if (cur > best) { b2 = best; best = cur; @@ -328,7 +328,7 @@ j0 = j; } } city_map_iterate_end; - if (!best) break; + if (best == 0) break; cur = amortize((shield[ii][jj] + mine[ii][jj]) + (food[ii][jj] + irrig[ii][jj]) * FOOD_WEIGHTING + /* seems to be needed */ (trade[ii][jj] + road[ii][jj]), d); @@ -366,7 +366,7 @@ } } } - if (!best) break; + if (best == 0) break; if (f > 0) d += (game.foodbox * MORT * n + (f*g) - 1) / (f*g); if (n == 4) { val -= amortize(40 * SHIELD_WEIGHTING + (50 - 20 * g) * FOOD_WEIGHTING, d); /* lers */ @@ -393,7 +393,7 @@ **************************************************************************/ void ai_manage_settler(struct player *pplayer, struct unit *punit) { - punit->ai.control = 1; + punit->ai.control = TRUE; if (punit->ai.ai_role == AIUNIT_NONE) /* if BUILD_CITY must remain BUILD_CITY */ punit->ai.ai_role = AIUNIT_AUTO_SETTLER; /* gonna handle city-building in the auto-settler routine -- Syela */ @@ -418,7 +418,7 @@ unit_list_iterate_end; return FALSE; } - return(map_get_tile(x, y)->assigned & (1<player_no)); + return TEST_BIT(map_get_tile(x, y)->assigned, pplayer->player_no); } /*************************************************************************/ @@ -642,7 +642,7 @@ static int road_bonus(int x, int y, int spc) { int m = 0, k; - int rd[12], te[12]; + bool rd[12], te[12]; int ii[12] = { -1, 0, 1, -1, 1, -1, 0, 1, 0, -2, 2, 0 }; int jj[12] = { -1, -1, -1, 0, 0, 1, 1, 1, -2, 0, 0, 2 }; struct tile *ptile; @@ -652,15 +652,15 @@ for (k = 0; k < 12; k++) { int x1 = x + ii[k], y1 = y + jj[k]; if (!normalize_map_pos(&x1, &y1)) { - rd[k] = 0; + rd[k] = FALSE; } else { ptile = map_get_tile(x1, y1); - rd[k] = ptile->special&spc; + rd[k] = tile_has_special(ptile, spc); te[k] = (ptile->terrain == T_MOUNTAINS || ptile->terrain == T_OCEAN); if (!rd[k]) { unit_list_iterate(ptile->units, punit) if (punit->activity == ACTIVITY_ROAD || punit->activity == ACTIVITY_RAILROAD) - rd[k] = spc; + rd[k] = TRUE; unit_list_iterate_end; } } @@ -816,7 +816,7 @@ } } unit_list_iterate_end; - if (id) return(id); + if (id != 0) return(id); #ifdef ALLOW_VIRTUAL_BOATS city_list_iterate(pplayer->cities, pcity) if (pcity->is_building_unit && @@ -850,15 +850,15 @@ ... **************************************************************************/ static void consider_settler_action(struct player *pplayer, enum unit_activity act, - int extra, int newv, int oldv, int in_use, + int extra, int newv, int oldv, bool in_use, int d, int *best_newv, int *best_oldv, int *best_act, int *gx, int *gy, int x, int y) { int a, b=0; - int consider; + bool consider; if (extra >= 0) { - consider = 1; + consider = TRUE; } else { consider = (newv > oldv); } @@ -893,7 +893,7 @@ { int cost; - if (punit->id) { + if (punit->id != 0) { cost = 30; } else { /* It is a virtuel unit, so must start in a city... */ @@ -914,7 +914,7 @@ struct player *pplayer = unit_owner(punit); int upkeep = utype_food_cost(unit_type(punit), get_gov_pplayer(pplayer)); - if (punit->id && !punit->homecity) + if (punit->id != 0 && punit->homecity == 0) upkeep = 0; /* thanks, Peter */ return upkeep; @@ -940,7 +940,7 @@ struct city *mycity = map_get_city(punit->x, punit->y); int newv, b, d; struct player *pplayer = unit_owner(punit); - int nav_known = (get_invention(pplayer, game.rtech.nav) == TECH_KNOWN); + bool nav_known = (get_invention(pplayer, game.rtech.nav) == TECH_KNOWN); int ucont = map_get_continent(punit->x, punit->y); int mv_rate = unit_type(punit)->move_rate; int food_upkeep = unit_food_upkeep(punit); @@ -966,15 +966,15 @@ /* hope 11 is far enough -- Syela */ square_iterate(punit->x, punit->y, 11, x, y) { int near = real_map_distance(punit->x, punit->y, x, y); - int w_virtual = 0; /* I'm no entirely sure what this is --dwp */ + bool w_virtual = FALSE; /* I'm no entirely sure what this is --dwp */ int mv_cost; if (!is_already_assigned(punit, pplayer, x, y) && map_get_terrain(x, y) != T_OCEAN - && (territory[x][y]&(1<player_no)) + && TEST_BIT(territory[x][y], pplayer->player_no) /* pretty good, hope it's enough! -- Syela */ && (near < 8 || map_get_continent(x, y) != ucont) && city_can_be_built_here(x,y) - && !city_exists_within_city_radius(x, y, 0)) { + && !city_exists_within_city_radius(x, y, FALSE)) { /* potential target, calculate mv_cost: */ if (*ferryboat) { @@ -990,13 +990,13 @@ /* for Rome->Carthage */ if (!is_terrain_near_tile(x, y, T_OCEAN)) { mv_cost = 9999; - } else if (boatid) { - if (!punit->id && mycity->id == boatid) { - w_virtual = 1; + } else if (boatid != 0) { + if (punit->id == 0 && mycity->id == boatid) { + w_virtual = TRUE; } mv_cost = warmap.cost[bx][by] + real_map_distance(bx, by, x, y) + mv_rate; - } else if (punit->id || + } else if (punit->id != 0 || !is_terrain_near_tile(mycity->x, mycity->y, T_OCEAN)) { mv_cost = 9999; } else { @@ -1004,7 +1004,7 @@ /* this should be fresh; the only thing that could have munged the seacost is the ferryboat code in k_s_w/f_s_t_k, but only if find_boat succeeded */ - w_virtual = 1; + w_virtual = TRUE; } } else { mv_cost = warmap.cost[x][y]; @@ -1014,7 +1014,7 @@ build a city at Y */ d *= 2; /* and then build its NEXT city halfway between X and Y. -- Syela */ - b = city_desirability(pplayer, x, y) * ai_fuzzy(pplayer, TRUE); + b = city_desirability(pplayer, x, y) * (ai_fuzzy(pplayer, TRUE) ? 1 : 0); newv = amortize(b, d); b = (food_upkeep * FOOD_WEIGHTING) * MORT; @@ -1024,7 +1024,7 @@ /* newv is now the value over mort turns */ newv = (newv * 100) / MORT / ((w_virtual ? 80 : 40) + food_cost); - if (best_newv && map_get_city(x, y)) newv = 0; + if (best_newv != 0 && map_get_city(x, y)) newv = 0; /* I added a line to discourage settling in existing cities, but it was inadequate. It may be true that in the short-term building infrastructure @@ -1046,7 +1046,7 @@ if (map_get_continent(x, y) != ucont && !nav_known && near >= 8) { freelog(LOG_DEBUG, "%s @(%d, %d) city_des (%d, %d) = %d, newv = %d, d = %d", - (punit->id ? unit_type(punit)->name : mycity->name), + (punit->id != 0 ? unit_type(punit)->name : mycity->name), punit->x, punit->y, x, y, b, newv, d); } else if (newv > best_newv) { best_newv = newv; @@ -1072,7 +1072,7 @@ { struct city *mycity = map_get_city(punit->x, punit->y); struct player *pplayer = unit_owner(punit); - int in_use; /* true if the target square is being used + bool in_use; /* true if the target square is being used by one of our cities */ int ucont = map_get_continent(punit->x, punit->y); int mv_rate = unit_type(punit)->move_rate; @@ -1083,7 +1083,7 @@ so that newv=0 activities are not chosen */ int food_upkeep = unit_food_upkeep(punit); int food_cost = unit_food_cost(punit); - int can_rr = player_knows_techs_with_flag(pplayer, TF_RAILROAD); + bool can_rr = player_knows_techs_with_flag(pplayer, TF_RAILROAD); int best_newv = 0; @@ -1098,7 +1098,7 @@ in_use = (get_worker_city(pcity, i, j) == C_TILE_WORKER); if (map_get_continent(x, y) == ucont && warmap.cost[x][y] <= THRESHOLD * mv_rate - && (territory[x][y]&(1<player_no)) + && TEST_BIT(territory[x][y], pplayer->player_no) /* pretty good, hope it's enough! -- Syela */ && !is_already_assigned(punit, pplayer, x, y)) { /* calling is_already_assigned once instead of four times @@ -1220,8 +1220,8 @@ || (ferryboat && goto_is_sane(ferryboat, gx, gy, TRUE) && (!is_tiles_adjacent(punit->x, punit->y, gx, gy) - || !could_unit_move_to_tile(punit, punit->x, punit->y, - gx, gy)))) { + || could_unit_move_to_tile(punit, punit->x, punit->y, + gx, gy) == 0))) { int x, y; punit->ai.ferryboat = find_boat(pplayer, &x, &y, 1); /* might need 2 */ freelog(LOG_DEBUG, "%d@(%d, %d): Looking for BOAT.", @@ -1234,7 +1234,7 @@ punit->ai.ferryboat); punit->goto_dest_x = gx; punit->goto_dest_y = gy; - if (ferryboat && (!ferryboat->ai.passenger + if (ferryboat && (ferryboat->ai.passenger == 0 || ferryboat->ai.passenger == punit->id)) { freelog(LOG_DEBUG, "We have FOUND BOAT, %d ABOARD %d@(%d,%d)->(%d,%d).", @@ -1251,7 +1251,7 @@ && (!ferryboat || (is_tiles_adjacent(punit->x, punit->y, gx, gy) && could_unit_move_to_tile(punit, punit->x, punit->y, - gx, gy)))) { + gx, gy) != 0))) { auto_settler_do_goto(pplayer, punit, gx, gy); if (!player_find_unit_by_id(pplayer, save_id)) return FALSE; /* died */ punit->ai.ferryboat = 0; @@ -1343,7 +1343,7 @@ /* This line makes non-AI autosettlers go off auto when they run out of squares to improve. I would like keep them on, prepared for future pollution and warming, but there wasn't consensus to do so. */ - punit->ai.control=0; + punit->ai.control = FALSE; } /* If we are at the destination then do the activity. */ @@ -1459,7 +1459,7 @@ static void assign_region(int x, int y, int player_no, int distance, int s) { square_iterate(x, y, distance, x1, y1) { - if (!s || is_terrain_near_tile(x1, y1, T_OCEAN)) + if (s == 0 || is_terrain_near_tile(x1, y1, T_OCEAN)) territory[x1][y1] &= (1<player_no; unit_list_iterate(pplayer->units, punit) - if (unit_type(punit)->attack_strength) { + if (unit_type(punit)->attack_strength != 0) { /* I could argue that phalanxes aren't really a threat, but ... */ if (is_sailing_unit(punit)) { assign_region(punit->x, punit->y, n, 1 + unit_type(punit)->move_rate / SINGLE_MOVE, 1);