Complete.Org: Mailing Lists: Archives: freeciv-dev: February 1999:
[Freeciv-Dev] Patch: handle caravans/freights in a more user-friendly w
Home

[Freeciv-Dev] Patch: handle caravans/freights in a more user-friendly w

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Patch: handle caravans/freights in a more user-friendly way.
From: rizos@xxxxxxxx
Date: Tue, 16 Feb 1999 00:46:35 -0600 (CST)
Reply-to: freeciv-dev@xxxxxxxxxxx

The following patch handles in a more user-friendly way the case 
where a caravan cannot establish a trade route with an enemy city. 
At the moment, if this is not possible, the message appearing is 
the meaningless "You can't attack there". This no longer appears
and a more elaborate message is displayed. Also, the modification
of the server function allows to display an appropriate message in 
cases where the client `gives ok' but a traderoute cannot finally 
be established.

--rizos


Files affected:
        client/mapctrl.c
        server/unithand.c


--- mapctrl-orig.c      Mon Feb 15 18:40:40 1999
+++ mapctrl.c   Tue Feb 16 00:23:47 1999
@@ -180,8 +180,9 @@
 **************************************************************************/
 void request_move_unit_direction(struct unit *punit, int dx, int dy)
 {
-  int dest_x, dest_y;
+  int dest_x, dest_y, i;
   struct unit req_unit;
+  char buf[512];
 
   dest_x=map_adjust_x(punit->x+dx);
   dest_y=punit->y+dy;   /* not adjusting on purpose*/
@@ -195,7 +196,27 @@
         unit_can_help_build_wonder(punit, pcity)) {
        popup_caravan_dialog(punit, phomecity, pcity);
        return;
-      }
+      } else if (game.player_idx != pcity->owner) {  
+                append_output_window("Game: You cannot establish a trade route 
here.");
+                for (i=0;i<4;i++)
+                    if (phomecity->trade[i]==pcity->id) {
+                       sprintf(buf, "      A traderoute already exists between 
%s and %s!",
+                                    phomecity->name, pcity->name);
+                       append_output_window(buf);
+                       return;
+                    }
+                if (city_num_trade_routes(phomecity)==4) {
+                   sprintf(buf, "      The city of %s has already 4 trade 
routes!",phomecity->name);
+                   append_output_window(buf);
+                   return;
+                } 
+                if (city_num_trade_routes(pcity)==4) {
+                   sprintf(buf, "      The city of %s has already 4 trade 
routes!",pcity->name);
+                   append_output_window(buf);
+                   return;
+                }
+                return;
+             }
     }
   }
   else if(unit_flag(punit->type, F_DIPLOMAT) &&




--- unithand-orig.c     Mon Feb 15 19:47:53 1999
+++ unithand.c  Mon Feb 15 22:56:59 1999
@@ -954,24 +954,26 @@
     pcity_dest=find_city_by_id(req->city_id);
     
     if(unit_flag(punit->type, F_CARAVAN) && pcity_homecity && pcity_dest && 
-       is_tiles_adjacent(punit->x, punit->y, pcity_dest->x, pcity_dest->y) &&
-       can_establish_trade_route(pcity_homecity, pcity_dest)) {
-      int revenue;
-
-      revenue=establish_trade_route(pcity_homecity, pcity_dest);
-      connection_do_buffer(pplayer->conn);
-      notify_player_ex(pplayer, pcity_dest->x, pcity_dest->y, E_NOEVENT,
+       is_tiles_adjacent(punit->x, punit->y, pcity_dest->x, pcity_dest->y)) 
+          if (can_establish_trade_route(pcity_homecity, pcity_dest)) {
+             int revenue;
+
+             revenue=establish_trade_route(pcity_homecity, pcity_dest);
+             connection_do_buffer(pplayer->conn);
+             notify_player_ex(pplayer, pcity_dest->x, pcity_dest->y, E_NOEVENT,
                       "Game: Your %s has arrived in %s, and revenues amount to 
%d in gold.", 
                       unit_name(punit->type), pcity_dest->name, revenue);
-      wipe_unit(0, punit);
-      pplayer->economic.gold+=revenue;
-      send_player_info(pplayer, pplayer);
-      city_refresh(pcity_homecity);
-      city_refresh(pcity_dest);
-      send_city_info(pplayer, pcity_homecity, 0);
-      send_city_info(city_owner(pcity_dest), pcity_dest, 0);
-      connection_do_unbuffer(pplayer->conn);
-    }
+             wipe_unit(0, punit);
+             pplayer->economic.gold+=revenue;
+             send_player_info(pplayer, pplayer);
+             city_refresh(pcity_homecity);
+             city_refresh(pcity_dest);
+             send_city_info(pplayer, pcity_homecity, 0);
+             send_city_info(city_owner(pcity_dest), pcity_dest, 0);
+             connection_do_unbuffer(pplayer->conn);
+          } else 
+             notify_player_ex(pplayer, pcity_dest->x, pcity_dest->y, E_NOEVENT,
+                    "Game: Sorry. Your %s cannot establish a trade route 
here!", unit_name(punit->type));
   }
 }
 /**************************************************************************


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Patch: handle caravans/freights in a more user-friendly way., rizos <=