Author: cazfi Date: Sun Apr 10 22:55:37 2016 New Revision: 32341 URL: http://svn.gna.org/viewcvs/freeciv?rev=32341&view=rev Log: Transported units can be automatically upgraded if, and only if, their current transport can carry also the resulting unit type.
Reported by Jacob Nevins <jtn> See bug #24368 Modified: branches/S2_6/client/text.c branches/S2_6/common/unit.c branches/S2_6/common/unit.h Modified: branches/S2_6/client/text.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/text.c?rev=32341&r1=32340&r2=32341&view=diff ============================================================================== --- branches/S2_6/client/text.c (original) +++ branches/S2_6/client/text.c Sun Apr 10 22:55:37 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/********************************************************************** Freeciv - Copyright (C) 2002 - The Freeciv Project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1193,7 +1193,7 @@ Returns TRUE iff any units can be upgraded. ****************************************************************************/ bool get_units_upgrade_info(char *buf, size_t bufsz, - struct unit_list *punits) + struct unit_list *punits) { if (unit_list_size(punits) == 0) { fc_snprintf(buf, bufsz, _("No units to upgrade!")); Modified: branches/S2_6/common/unit.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unit.c?rev=32341&r1=32340&r2=32341&view=diff ============================================================================== --- branches/S2_6/common/unit.c (original) +++ branches/S2_6/common/unit.c Sun Apr 10 22:55:37 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2046,7 +2046,12 @@ return UU_NOT_ENOUGH_ROOM; } - if (!can_exist_at_tile(to_unittype, unit_tile(punit))) { + if (punit->transporter != NULL) { + if (!can_unit_type_transport(unit_type_get(punit->transporter), + unit_class_get(punit))) { + return UU_UNSUITABLE_TRANSPORT; + } + } else if (!can_exist_at_tile(to_unittype, unit_tile(punit))) { /* The new unit type can't survive on this terrain. */ return UU_NOT_TERRAIN; } @@ -2140,6 +2145,14 @@ utype_name_translation(from_unittype), utype_name_translation(to_unittype)); break; + case UU_UNSUITABLE_TRANSPORT: + fc_snprintf(buf, bufsz, + _("Upgrading this %s would result in a %s which its " + "current transport, %s, could not transport."), + utype_name_translation(from_unittype), + utype_name_translation(to_unittype), + unit_name_translation(punit->transporter)); + break; } return result; Modified: branches/S2_6/common/unit.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unit.h?rev=32341&r1=32340&r2=32341&view=diff ============================================================================== --- branches/S2_6/common/unit.h (original) +++ branches/S2_6/common/unit.h Sun Apr 10 22:55:37 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -76,7 +76,8 @@ UU_NOT_IN_CITY, UU_NOT_CITY_OWNER, UU_NOT_ENOUGH_ROOM, - UU_NOT_TERRAIN /* The upgraded unit could not survive. */ + UU_NOT_TERRAIN, /* The upgraded unit could not survive. */ + UU_UNSUITABLE_TRANSPORT /* Can't upgrade inside current transport. */ }; enum unit_airlift_result { _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits