[Freeciv-Dev] (PR#12811) civ server crashing when i buid barracks
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12811 >
Very well. This is a real bug. Probably in 2.0 as well. Of course
you'd never see it in the default ruleset. I think.
-jason
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.303
diff -u -r1.303 cityturn.c
--- server/cityturn.c 14 Apr 2005 04:49:15 -0000 1.303
+++ server/cityturn.c 16 Apr 2005 05:08:25 -0000
@@ -618,9 +618,18 @@
!can_build_unit(pcity, target)) {
int new_target = unit_upgrades_to(pcity, target);
- /* If the city can never build this unit or its descendants, drop it. */
- if (!can_eventually_build_unit(pcity, new_target)) {
- /* Nope, never in a million years. */
+ /* Maybe we can just upgrade the target to what the city /can/ build. */
+ if (new_target == U_NOT_OBSOLETED) {
+ /* Nope, we're stuck. Dump this item from the worklist. */
+ notify_player_ex(pplayer, pcity->tile, E_CITY_CANTBUILD,
+ _("%s can't build %s from the worklist; "
+ "tech not yet available. Postponing..."),
+ pcity->name,
+ get_unit_type(target)->name);
+ continue;
+ } else if (!can_eventually_build_unit(pcity, new_target)) {
+ /* If the city can never build this unit or its descendants,
+ * drop it. */
notify_player_ex(pplayer, pcity->tile, E_CITY_CANTBUILD,
_("%s can't build %s from the worklist. "
"Purging..."),
@@ -635,17 +644,6 @@
i--;
continue;
- }
-
- /* Maybe we can just upgrade the target to what the city /can/ build. */
- if (new_target == target) {
- /* Nope, we're stuck. Dump this item from the worklist. */
- notify_player_ex(pplayer, pcity->tile, E_CITY_CANTBUILD,
- _("%s can't build %s from the worklist; "
- "tech not yet available. Postponing..."),
- pcity->name,
- get_unit_type(target)->name);
- continue;
} else {
/* Yep, we can go after new_target instead. Joy! */
notify_player_ex(pplayer, pcity->tile, E_WORKLIST,
@@ -885,7 +883,7 @@
Unit_Type_id check = id, latest_ok = id;
if (!can_build_unit_direct(pcity, check)) {
- return -1;
+ return U_NOT_OBSOLETED;
}
while ((check = unit_types[check].obsoleted_by) != U_NOT_OBSOLETED) {
if (can_build_unit_direct(pcity, check)) {
@@ -893,7 +891,7 @@
}
}
if (latest_ok == id) {
- return -1; /* Can't upgrade */
+ return U_NOT_OBSOLETED; /* Can't upgrade */
}
return latest_ok;
|
|