diff -ru freeciv/ai/aicity.c freeciv+pasky/ai/aicity.c
--- freeciv/ai/aicity.c	Sat Nov 24 20:26:37 2001
+++ freeciv+pasky/ai/aicity.c	Sat Nov 24 20:36:45 2001
@@ -315,7 +315,10 @@
   
   for (id = 0; id < game.num_impr_types; id++) {
     /* selling walls to buy defenders is counterproductive -- Syela */
-    if (can_sell_building(pcity, id) && id != B_CITY) {
+    /* Selling palace too. Virtually selling of every building with
+     * original upkeep 0. We can't exempt all buildings with real
+     * upkeep 0 because e.g. B_ASMITHS. --pasky */
+    if (can_sell_building(pcity, id) && improvement_types[id].upkeep) {
       really_handle_city_sell(pplayer, pcity, id);
       break;
     }
@@ -796,9 +799,13 @@
   struct player *pplayer = city_owner(pcity);
   
   for (i = 0; i < game.num_impr_types; i++) {
+    /* selling city walls is really, really dumb -- Syela */
+    /* Selling palace too. Virtually selling of every building with
+     * original upkeep 0. We can't exempt all buildings with real
+     * upkeep 0 because e.g. B_ASMITHS. --pasky */
     if (city_got_building(pcity, i) 
        && !is_wonder(i) 
-       && i != B_CITY /* selling city walls is really, really dumb -- Syela */
+       && improvement_types[i].upkeep
        && (wonder_replacement(pcity, i) || building_unwanted(city_owner(pcity), i))) {
       do_sell_building(pplayer, pcity, i);
       notify_player_ex(pplayer, pcity->x, pcity->y, E_IMP_SOLD,
