[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
rt-guest@xxxxxxxxxxx |
Subject: |
[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate |
From: |
"Jason Short" <rt@xxxxxxxxxxx> |
Date: |
Thu, 6 Nov 2003 10:23:39 -0800 |
Raimar Falke wrote:
> On Wed, Nov 05, 2003 at 05:27:59AM -0800, Per I. Mathisen wrote:
>
>>On Wed, 5 Nov 2003, Raimar Falke wrote:
>>
>>>>I think the simplest solution to this problem is simply to ban upgrades of
>>>>transporters with passengers where the result is a unit with less
>>>>transport capacity than the number of passengers transported.
>>>
>>>I agree. What changes to the ruleset are required?
>>
>>No ruleset changes. We just check, when you want to upgrade, if transport
>>is carrying more passengers than we could carry if we upgraded - if that
>>is the case, no upgrade for you (for now).
>
>
> So this patch is a 4-liner?!
Changes should be done in the client to disable the upgrade (disable the
menu, and probably some changes to the units dialog) and to the server
(with an error message).
Attached patch (untested) mmakes the server change. However I'd suggest
a can_upgrade_unit() be added to common/unit.[ch] for use by the clients
and one of the server functions (but not the other, which gives a
specific error message).
jason
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.277
diff -u -r1.277 unithand.c
--- server/unithand.c 2003/10/29 08:00:39 1.277
+++ server/unithand.c 2003/11/06 17:50:58
@@ -180,12 +180,17 @@
/* Only units in cities can be upgraded. */
if (pcity && pcity->owner == player_no) {
- upgrade_unit(punit, to_unittype);
- number_of_upgraded_units++;
- if ((pplayer->economic.gold -= cost) < cost) {
- /* We can't upgrade any more units. */
- break;
- }
+
+ /* Don't upgrade transporters without enough capacity. */
+ if (get_transporter_occupancy(punit)
+ <= unit_types[to_unittype].transport_capacity) {
+ upgrade_unit(punit, to_unittype);
+ number_of_upgraded_units++;
+ if ((pplayer->economic.gold -= cost) < cost) {
+ /* We can't upgrade any more units. */
+ break;
+ }
+ }
}
}
} unit_list_iterate_end;
@@ -231,6 +236,15 @@
unit_type(punit)->name);
return;
}
+
+ if (get_transporter_occupancy(punit)
+ > unit_types[to_unit].transport_capacity) {
+ notify_player(pplayer, _("Game: cannot upgrade %s because it is "
+ "transporting other units."),
+ unit_type(punit)->name);
+ return;
+ }
+
cost = unit_upgrade_price(pplayer, punit->type, to_unit);
if(cost > pplayer->economic.gold) {
notify_player(pplayer, _("Game: Insufficient funds, upgrade costs %d."),
[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate,
Jason Short <=
[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate, Gregory Berkolaiko, 2003/11/09
[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate, Per I. Mathisen, 2003/11/09
[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate, Jason Short, 2003/11/09
[Freeciv-Dev] Re: (PR#6735) Server crashed upgrading a frigate, Raimar Falke, 2003/11/10
|
|