diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/client/control.c gtk_etc/client/control.c --- freeciv/client/control.c Wed Apr 26 16:14:41 2000 +++ gtk_etc/client/control.c Wed Apr 26 22:31:41 2000 @@ -693,7 +693,7 @@ append_output_window(_("Game: Only paratrooper units can do this.")); return; } - if(!can_unit_paradropped(punit)) + if(!can_unit_paradrop(punit)) return; paradrop_state=1; @@ -850,6 +850,7 @@ nuke_state=0; paradrop_state=0; connect_state=0; + update_unit_info_label(punit); return; } @@ -859,6 +860,7 @@ nuke_state=0; paradrop_state=0; connect_state=0; + update_unit_info_label(punit); return; } @@ -880,6 +882,7 @@ send_packet_unit_request(&aconnection, &req, PACKET_UNIT_GOTO_TILE); if(nuke_state && (!pcity)) do_unit_nuke(punit); + update_unit_info_label(punit); } goto_state=0; @@ -1260,7 +1263,7 @@ void key_unit_paradrop(void) { if(get_unit_in_focus()) - if(can_unit_paradropped(punit_focus)) + if(can_unit_paradrop(punit_focus)) request_unit_paradrop(punit_focus); } diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/client/gui-gtk/menu.c gtk_etc/client/gui-gtk/menu.c --- freeciv/client/gui-gtk/menu.c Wed Apr 26 16:14:41 2000 +++ gtk_etc/client/gui-gtk/menu.c Wed Apr 26 19:31:56 2000 @@ -278,7 +278,7 @@ request_unit_connect(); break; case MENU_ORDER_POLLUTION: - if(can_unit_paradropped(get_unit_in_focus())) + if(can_unit_paradrop(get_unit_in_focus())) key_unit_paradrop(); else key_unit_pollution(); @@ -912,7 +912,7 @@ can_unit_do_connect(punit, ACTIVITY_IDLE)); menus_set_sensitive("
/Orders/Clean Pollution", can_unit_do_activity(punit, ACTIVITY_POLLUTION) || - can_unit_paradropped(punit)); + can_unit_paradrop(punit)); menus_set_sensitive("
/Orders/Fortify", can_unit_do_activity(punit, ACTIVITY_FORTIFYING)); menus_set_sensitive("
/Orders/Sentry", diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/client/gui-mui/gui_main.c gtk_etc/client/gui-mui/gui_main.c --- freeciv/client/gui-mui/gui_main.c Wed Apr 26 16:14:52 2000 +++ gtk_etc/client/gui-mui/gui_main.c Wed Apr 26 19:23:38 2000 @@ -507,7 +507,7 @@ request_unit_connect(); break; case MENU_ORDER_POLLUTION: - if(can_unit_paradropped(get_unit_in_focus())) + if(can_unit_paradrop(get_unit_in_focus())) key_unit_paradrop(); else key_unit_pollution(); @@ -1162,7 +1162,7 @@ menu_entry_sensitive(MENU_ORDER_TRANSFORM, can_unit_do_activity(punit, ACTIVITY_TRANSFORM)); menu_entry_sensitive(MENU_ORDER_FORTRESS, can_unit_do_activity(punit, ACTIVITY_FORTRESS)); - if (can_unit_paradropped(punit)) + if (can_unit_paradrop(punit)) { menu_entry_rename(MENU_ORDER_POLLUTION, "Paradrop", FALSE); menu_entry_sensitive(MENU_ORDER_POLLUTION, TRUE); diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/client/gui-mui/mapclass.c gtk_etc/client/gui-mui/mapclass.c --- freeciv/client/gui-mui/mapclass.c Wed Apr 26 16:14:52 2000 +++ gtk_etc/client/gui-mui/mapclass.c Wed Apr 26 19:24:29 2000 @@ -1861,7 +1861,7 @@ Map_InsertCommand(&list, "Auto Attack", PACK_USERDATA(punit, MENU_ORDER_AUTO_ATTACK)); if (can_unit_do_activity(punit, ACTIVITY_EXPLORE)) Map_InsertCommand(&list, "Auto Explore", PACK_USERDATA(punit, MENU_ORDER_AUTO_EXPLORE)); - if (can_unit_paradropped(punit)) + if (can_unit_paradrop(punit)) Map_InsertCommand(&list, "Paradrop", PACK_USERDATA(punit, MENU_ORDER_POLLUTION)); if (unit_flag(punit->type, F_NUCLEAR)) Map_InsertCommand(&list, "Explode Nuclear", PACK_USERDATA(punit, MENU_ORDER_NUKE)); diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/client/gui-xaw/menu.c gtk_etc/client/gui-xaw/menu.c --- freeciv/client/gui-xaw/menu.c Wed Apr 26 16:14:54 2000 +++ gtk_etc/client/gui-xaw/menu.c Wed Apr 26 19:24:22 2000 @@ -304,7 +304,7 @@ can_unit_do_activity(punit, ACTIVITY_AIRBASE)); menu_entry_sensitive(MENU_ORDER, MENU_ORDER_POLLUTION, can_unit_do_activity(punit, ACTIVITY_POLLUTION) || - can_unit_paradropped(punit)); + can_unit_paradrop(punit)); menu_entry_sensitive(MENU_ORDER, MENU_ORDER_FORTIFY, can_unit_do_activity(punit, ACTIVITY_FORTIFYING)); menu_entry_sensitive(MENU_ORDER, MENU_ORDER_SENTRY, diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/common/unit.c gtk_etc/common/unit.c --- freeciv/common/unit.c Wed Apr 26 16:14:56 2000 +++ gtk_etc/common/unit.c Wed Apr 26 19:21:51 2000 @@ -864,7 +864,7 @@ special, have enough movepoints left and have not paradropped before in this turn. **************************************************************************/ -int can_unit_paradropped(struct unit *punit) +int can_unit_paradrop(struct unit *punit) { struct city *pcity; struct unit_type *utype; diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/common/unit.h gtk_etc/common/unit.h --- freeciv/common/unit.h Wed Apr 26 16:14:56 2000 +++ gtk_etc/common/unit.h Wed Apr 26 19:22:06 2000 @@ -257,7 +257,7 @@ int unit_can_defend_here(struct unit *punit); int unit_can_airlift_to(struct unit *punit, struct city *pcity); -int can_unit_paradropped(struct unit *punit); +int can_unit_paradrop(struct unit *punit); int can_unit_change_homecity(struct unit *punit); int can_unit_do_connect(struct unit *punit, enum unit_activity activity); char* get_activity_text (int activity); diff -Nur -X/home/thue/freeciv-dev/no.freeciv freeciv/server/unitfunc.c gtk_etc/server/unitfunc.c --- freeciv/server/unitfunc.c Wed Apr 26 16:15:03 2000 +++ gtk_etc/server/unitfunc.c Wed Apr 26 21:38:01 2000 @@ -2091,90 +2091,91 @@ } /************************************************************************** -... +Returns whether the drop was made or not. Note that it also returns 1 in +the case where the drop was succesfull, but the unit was killed by +barbarians in a hut **************************************************************************/ int do_paradrop(struct player *pplayer, struct unit *punit, int x, int y) { - int paradropped=0; + if (!unit_flag(punit->type, F_PARATROOPERS)) { + notify_player_ex(&game.players[punit->owner], punit->x, punit->y, E_NOEVENT, + _("Game: This unit type can not be paradropped.")); + return 0; + } - connection_do_buffer(pplayer->conn); + if (!can_unit_paradrop(punit)) + return 0; - if (unit_flag(punit->type, F_PARATROOPERS)) { - if(can_unit_paradropped(punit)) { - if(map_get_known(x,y,pplayer)) { - if(map_get_terrain(x,y) != T_OCEAN) { - if(!is_enemy_unit_tile(x,y,punit->owner)) { - int range = get_unit_type(punit->type)->paratroopers_range; - if(real_map_distance(punit->x, punit->y, x, y) <= range) { - struct city *start_city = map_get_city(punit->x, punit->y); - struct city *dest_city = map_get_city(x, y); - int ok=1; - - /* light the squares the unit is entering */ - teleport_unit_sight_points(punit->x, punit->y, x, y, punit); - - unit_list_unlink(&map_get_tile(punit->x, punit->y)->units, punit); - punit->x = x; punit->y = y; - unit_list_insert(&map_get_tile(x, y)->units, punit); - - ok = 1; - if((map_get_tile(x, y)->special&S_HUT)) { - /* punit might get killed by horde of barbarians */ - ok = handle_unit_enter_hut(punit); - } - - if(ok) { - punit->moves_left -= get_unit_type(punit->type)->paratroopers_mr_sub; - if(punit->moves_left < 0) punit->moves_left = 0; - punit->paradropped = 1; - send_unit_info(0, punit); - - if(start_city) { - send_city_info(pplayer, start_city); - } - - if(dest_city) { - handle_unit_enter_city(pplayer, dest_city); - send_city_info(city_owner(dest_city), dest_city); - } - - punit->moved = 1; - } - paradropped=1; - } - else { - notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, - _("Game: Too far for this unit.")); - } - } - else { /*FIXME: this is a fog-of-war cheat. - You get to know if there is an enemy on the tile*/ - notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, - _("Game: Cannot paradrop because there are" - " enemy units on the destination location.")); - } - } - else { - notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, - _("Game: Cannot paradrop into ocean.")); - } - } - else { - notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, - _("Game: The destination location is not known.")); - } - } + if (!map_get_known(x,y,pplayer)) { + notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, + _("Game: The destination location is not known.")); + return 0; } - else { - notify_player_ex(&game.players[punit->owner], punit->x, punit->y, E_NOEVENT, - _("Game: This unit type can not be paradropped.")); + + + if (map_get_terrain(x,y) == T_OCEAN) { + notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, + _("Game: Cannot paradrop into ocean.")); + return 0; } - if(!paradropped) + /*FIXME: this is a fog-of-war cheat. + You get to know if there is an enemy on the tile*/ + if (is_enemy_unit_tile(x,y,punit->owner)) { + notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, + _("Game: Cannot paradrop because there are" + " enemy units on the destination location.")); + return 0; + } + + { + int range = get_unit_type(punit->type)->paratroopers_range; + int distance = real_map_distance(punit->x, punit->y, x, y); + if (distance > range) { + notify_player_ex(&game.players[punit->owner], x, y, E_NOEVENT, + _("Game: The distance to the target (%i) " + "is greater than the unit's range(%i)."), + distance, range); + return 0; + } + } + + /* All ok */ + { + struct city *start_city = map_get_city(punit->x, punit->y); + struct city *dest_city = map_get_city(x, y); + + /* unfog the squares the unit is entering */ + teleport_unit_sight_points(punit->x, punit->y, x, y, punit); + + unit_list_unlink(&map_get_tile(punit->x, punit->y)->units, punit); + punit->x = x; punit->y = y; + unit_list_insert(&map_get_tile(x, y)->units, punit); + + punit->moves_left -= get_unit_type(punit->type)->paratroopers_mr_sub; + if(punit->moves_left < 0) punit->moves_left = 0; + punit->paradropped = 1; send_unit_info(0, punit); - connection_do_unbuffer(pplayer->conn); - return 0; + if(start_city) { + send_city_info(pplayer, start_city); + } + + if(dest_city) { + handle_unit_enter_city(pplayer, dest_city); + send_city_info(city_owner(dest_city), dest_city); + } + + punit->moved = 1; + + if((map_get_tile(x, y)->special&S_HUT)) { + /* punit might get killed by horde of barbarians */ + if (! (handle_unit_enter_hut(punit)) ) + return 1; /* We died, but we did do the paradrop */ + } + } + + return 1; } /**************************************************************************