[Freeciv-Dev] (PR#9800) unit_type_exists should be removed
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#9800) unit_type_exists should be removed |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Thu, 2 Sep 2004 21:33:23 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9800 >
This patch removes unit_type_exists.
In most places where this function used to be called we can simply
ignore it. In a few places we need to check the type against -1
(U_NONE) instead. I added a new macro CHECK_UNIT_TYPE which verifies
the unit type is valid.
IMO this makes things a fair bit simpler. Only 40 lines of code are
removed but the logic is a lot cleaner.
Also I removed all the nonexistent units (necessary for the code patch,
but it can be applied separately). They were previously needed for
backwards-compatibility with savegames, but aren't any more. This
removes 800 lines of ruleset data...
jason
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.334
diff -u -r1.334 aiunit.c
--- ai/aiunit.c 1 Sep 2004 11:47:25 -0000 1.334
+++ ai/aiunit.c 3 Sep 2004 04:28:37 -0000
@@ -2412,7 +2412,7 @@
int i = 0;
unit_type_iterate(id) {
- if (unit_type_exists(id) && !unit_type_flag(id, F_NONMIL)
+ if (!unit_type_flag(id, F_NONMIL)
&& !unit_type_flag(id, F_MISSILE)
&& !unit_type_flag(id, F_NO_LAND_ATTACK)
&& get_unit_type(id)->move_type != AIR_MOVING
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.73
diff -u -r1.73 helpdata.c
--- client/helpdata.c 31 Aug 2004 04:40:48 -0000 1.73
+++ client/helpdata.c 3 Sep 2004 04:28:37 -0000
@@ -241,13 +241,11 @@
help_list_init(&category_nodes);
if (current_type == HELP_UNIT) {
unit_type_iterate(i) {
- if (unit_type_exists(i)) {
- pitem = new_help_item(current_type);
- my_snprintf(name, sizeof(name), " %s", unit_name(i));
- pitem->topic = mystrdup(name);
- pitem->text = mystrdup("");
- help_list_insert_back(&category_nodes, pitem);
- }
+ pitem = new_help_item(current_type);
+ my_snprintf(name, sizeof(name), " %s", unit_name(i));
+ pitem->topic = mystrdup(name);
+ pitem->text = mystrdup("");
+ help_list_insert_back(&category_nodes, pitem);
} unit_type_iterate_end;
} else if (current_type == HELP_TECH) {
tech_type_iterate(i) {
@@ -561,10 +559,6 @@
struct unit_type *utype;
assert(buf&&user_text);
- if (!unit_type_exists(i)) {
- strcpy(buf, user_text);
- return;
- }
utype = get_unit_type(i);
buf[0] = '\0';
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.103
diff -u -r1.103 options.c
--- client/options.c 26 Aug 2004 07:59:01 -0000 1.103
+++ client/options.c 3 Sep 2004 04:28:38 -0000
@@ -721,8 +721,10 @@
secfile_lookup_int_default(file, 0, idpath,wlinx, i);
if ((pwl->wlefs[i] <= WEF_END) || (pwl->wlefs[i] >= WEF_LAST) ||
- ((pwl->wlefs[i] == WEF_UNIT) && !unit_type_exists(pwl->wlids[i])) ||
- ((pwl->wlefs[i] == WEF_IMPR) && !improvement_exists(pwl->wlids[i])))
{
+ (pwl->wlefs[i] == WEF_UNIT
+ && (pwl->wlids[i] < 0 || pwl->wlids[i] >= game.num_unit_types))
+ || ((pwl->wlefs[i] == WEF_IMPR)
+ && !improvement_exists(pwl->wlids[i]))) {
pwl->wlefs[i] = WEF_END;
pwl->wlids[i] = 0;
end = TRUE;
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.196
diff -u -r1.196 tilespec.c
--- client/tilespec.c 25 Aug 2004 18:24:18 -0000 1.196
+++ client/tilespec.c 3 Sep 2004 04:28:38 -0000
@@ -1547,8 +1547,7 @@
struct unit_type *ut = get_unit_type(id);
ut->sprite = lookup_sprite_tag_alt(ut->graphic_str, ut->graphic_alt,
- unit_type_exists(id), "unit_type",
- ut->name);
+ TRUE, "unit_type", ut->name);
/* should maybe do something if NULL, eg generic default? */
}
Index: client/gui-gtk/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/repodlgs.c,v
retrieving revision 1.83
diff -u -r1.83 repodlgs.c
--- client/gui-gtk/repodlgs.c 2 Aug 2004 23:44:57 -0000 1.83
+++ client/gui-gtk/repodlgs.c 3 Sep 2004 04:28:38 -0000
@@ -913,9 +913,10 @@
*****************************************************************/
void activeunits_list_callback(GtkWidget *w, gint row, gint column)
{
- if ((unit_type_exists(activeunits_type[row])) &&
- (can_upgrade_unittype(game.player_ptr, activeunits_type[row]) != -1))
+ CHECK_UNIT_TYPE(activeunits_type[row]);
+ if (can_upgrade_unittype(game.player_ptr, activeunits_type[row]) != -1) {
gtk_widget_set_sensitive(upgrade_command, can_client_issue_orders());
+ }
}
/****************************************************************
@@ -950,8 +951,7 @@
row = GPOINTER_TO_INT(selection->data);
ut1 = activeunits_type[row];
- if (!(unit_type_exists (ut1)))
- return;
+ CHECCK_UNIT_TYPE(ut1);
/* puts(unit_types[ut1].name); */
ut2 = can_upgrade_unittype(game.player_ptr, activeunits_type[row]);
@@ -1027,9 +1027,9 @@
}
unit_list_iterate_end;
city_list_iterate(game.player_ptr->cities,pcity) {
- if (pcity->is_building_unit &&
- (unit_type_exists (pcity->currently_building)))
+ if (pcity->is_building_unit) {
(unitarray[pcity->currently_building].building_count)++;
+ }
}
city_list_iterate_end;
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.55
diff -u -r1.55 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c 28 Aug 2004 07:21:02 -0000 1.55
+++ client/gui-gtk-2.0/repodlgs.c 3 Sep 2004 04:28:39 -0000
@@ -1039,11 +1039,7 @@
n = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(activeunits_store),
NULL);
- if (row < n - 1 && unit_type_exists(activeunits_type[row])) {
- is_unit_type = TRUE;
- } else {
- is_unit_type = FALSE;
- }
+ is_unit_type = (row < n - 1);
}
if (!is_unit_type) {
@@ -1119,10 +1115,7 @@
/* nearest & upgrade commands. */
row = gtk_tree_selection_get_row(activeunits_selection);
ut1 = activeunits_type[row];
-
- if (!unit_type_exists(ut1)) {
- return;
- }
+ CHECK_UNIT_TYPE(ut1);
if (response_id == ACTIVEUNITS_NEAREST) {
int cx, cy;
@@ -1192,9 +1185,9 @@
}
unit_list_iterate_end;
city_list_iterate(game.player_ptr->cities,pcity) {
- if (pcity->is_building_unit &&
- (unit_type_exists (pcity->currently_building)))
+ if (pcity->is_building_unit) {
(unitarray[pcity->currently_building].building_count)++;
+ }
}
city_list_iterate_end;
Index: client/gui-mui/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/repodlgs.c,v
retrieving revision 1.36
diff -u -r1.36 repodlgs.c
--- client/gui-mui/repodlgs.c 19 Jul 2004 20:29:12 -0000 1.36
+++ client/gui-mui/repodlgs.c 3 Sep 2004 04:28:39 -0000
@@ -820,9 +820,9 @@
city_list_iterate(game.player_ptr->cities, pcity)
{
- if (pcity->is_building_unit &&
- (unit_type_exists(pcity->currently_building)))
+ if (pcity->is_building_unit) {
(unitarray[pcity->currently_building].building_count)++;
+ }
}
city_list_iterate_end;
Index: client/gui-sdl/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/dialogs.c,v
retrieving revision 1.47
diff -u -r1.47 dialogs.c
--- client/gui-sdl/dialogs.c 13 Jul 2004 22:52:16 -0000 1.47
+++ client/gui-sdl/dialogs.c 3 Sep 2004 04:28:39 -0000
@@ -406,11 +406,12 @@
ut1 = pUnit->type;
- if (pUnit_Upgrade_Dlg || !unit_type_exists(ut1)) {
+ if (pUnit_Upgrade_Dlg) {
/* just in case */
flush_dirty();
return;
}
+ CHECK_UNIT_TYPE(ut1);
pUnit_Upgrade_Dlg = MALLOC(sizeof(struct SMALL_DLG));
Index: client/gui-sdl/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/repodlgs.c,v
retrieving revision 1.37
diff -u -r1.37 repodlgs.c
--- client/gui-sdl/repodlgs.c 23 Apr 2004 22:58:05 -0000 1.37
+++ client/gui-sdl/repodlgs.c 3 Sep 2004 04:28:40 -0000
@@ -104,13 +104,12 @@
} unit_list_iterate_end;
city_list_iterate(game.player_ptr->cities, pCity) {
- if (pCity->is_building_unit &&
- (unit_type_exists(pCity->currently_building))) {
- (entries[pCity->currently_building].building_count)++;
- (total->building_count)++;
- entries[pCity->currently_building].soonest_completions =
- MIN(entries[pCity->currently_building].soonest_completions,
- city_turns_to_build(pCity,
+ if (pCity->is_building_unit) {
+ (entries[pCity->currently_building].building_count)++;
+ (total->building_count)++;
+ entries[pCity->currently_building].soonest_completions =
+ MIN(entries[pCity->currently_building].soonest_completions,
+ city_turns_to_build(pCity,
pCity->currently_building, TRUE, TRUE));
}
} city_list_iterate_end;
@@ -173,9 +172,10 @@
ut1 = MAX_ID - pWidget->ID;
- if (pUnits_Upg_Dlg || !unit_type_exists(ut1)) {
+ if (pUnits_Upg_Dlg) {
return 1;
}
+ CHECK_UNIT_TYPE(ut1);
set_wstate(pWidget, FC_WS_NORMAL);
pSellected_Widget = NULL;
Index: client/gui-win32/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/repodlgs.c,v
retrieving revision 1.39
diff -u -r1.39 repodlgs.c
--- client/gui-win32/repodlgs.c 28 Aug 2004 00:54:05 -0000 1.39
+++ client/gui-win32/repodlgs.c 3 Sep 2004 04:28:40 -0000
@@ -486,14 +486,15 @@
case WM_NOTIFY:
if (sel>=0) {
- if ((unit_type_exists(activeunits_type[sel])) &&
- (can_upgrade_unittype(game.player_ptr,
- activeunits_type[sel]) != -1))
+ CHECK_UNIT_TYPE(activeunits_type[sel]);
+ if (can_upgrade_unittype(game.player_ptr,
+ activeunits_type[sel]) != -1) {
EnableWindow(GetDlgItem(activeunits_dlg,ID_MILITARY_UPGRADE),
TRUE);
- else
+ } else {
EnableWindow(GetDlgItem(activeunits_dlg,ID_MILITARY_UPGRADE),
FALSE);
+ }
}
break;
case WM_COMMAND:
@@ -511,9 +512,9 @@
{
char buf[512];
int ut1,ut2;
+
ut1 = activeunits_type[sel];
- if (!(unit_type_exists (ut1)))
- break;
+ CHECK_UNIT_TYPE(ut1);
ut2=can_upgrade_unittype(game.player_ptr,activeunits_type[sel]);
my_snprintf(buf, sizeof(buf),
_("Upgrade as many %s to %s as possible for %d gold
each?\n"
@@ -581,9 +582,9 @@
unit_list_iterate_end;
city_list_iterate(game.player_ptr->cities,pcity) {
- if (pcity->is_building_unit &&
- (unit_type_exists (pcity->currently_building)))
+ if (pcity->is_building_unit) {
(unitarray[pcity->currently_building].building_count)++;
+ }
}
city_list_iterate_end;
Index: client/gui-xaw/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/repodlgs.c,v
retrieving revision 1.61
diff -u -r1.61 repodlgs.c
--- client/gui-xaw/repodlgs.c 19 Jul 2004 20:29:12 -0000 1.61
+++ client/gui-xaw/repodlgs.c 3 Sep 2004 04:28:40 -0000
@@ -917,7 +917,6 @@
may_upgrade =
((inx != XAW_LIST_NONE) &&
- (unit_type_exists (activeunits_type[inx])) &&
(can_upgrade_unittype (game.player_ptr, activeunits_type[inx]) != -1));
XtSetSensitive (upgrade_command, may_upgrade);
@@ -956,9 +955,8 @@
if(ret->list_index!=XAW_LIST_NONE) {
ut1 = activeunits_type[ret->list_index];
- if (!(unit_type_exists (ut1))) {
- return;
- }
+ CHECK_UNIT_TYPE(ut1);
+
/* puts(unit_types[ut1].name); */
ut2 = can_upgrade_unittype(game.player_ptr,
@@ -1041,9 +1039,9 @@
}
unit_list_iterate_end;
city_list_iterate(game.player_ptr->cities,pcity) {
- if (pcity->is_building_unit &&
- (unit_type_exists (pcity->currently_building)))
+ if (pcity->is_building_unit) {
(unitarray[pcity->currently_building].building_count)++;
+ }
}
city_list_iterate_end;
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.240
diff -u -r1.240 city.c
--- common/city.c 1 Sep 2004 19:45:19 -0000 1.240
+++ common/city.c 3 Sep 2004 04:28:41 -0000
@@ -484,7 +484,7 @@
if (!can_build_unit_direct(pcity, id)) {
return FALSE;
}
- while (unit_type_exists((id = unit_types[id].obsoleted_by))) {
+ while ((id = unit_types[id].obsoleted_by) != -1) {
if (can_player_build_unit_direct(city_owner(pcity), id)) {
return FALSE;
}
Index: common/combat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/combat.c,v
retrieving revision 1.45
diff -u -r1.45 combat.c
--- common/combat.c 25 Aug 2004 18:24:19 -0000 1.45
+++ common/combat.c 3 Sep 2004 04:28:41 -0000
@@ -407,7 +407,11 @@
{
struct city *pcity = map_get_city(x, y);
- if (unit_type_exists(att_type)) {
+ CHECK_UNIT_TYPE(def_type);
+
+ if (att_type != U_LAST) {
+ CHECK_UNIT_TYPE(att_type);
+
if (unit_type_flag(def_type, F_PIKEMEN)
&& unit_type_flag(att_type, F_HORSE)) {
defensepower *= 2;
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.39
diff -u -r1.39 unittype.c
--- common/unittype.c 26 Aug 2004 06:26:09 -0000 1.39
+++ common/unittype.c 3 Sep 2004 04:28:41 -0000
@@ -67,21 +67,6 @@
};
/**************************************************************************
-Returns 1 if the unit_type "exists" in this game, 0 otherwise.
-A unit_type doesn't exist if one of:
-- id is out of range
-- the unit_type has been flagged as removed by setting its
- tech_requirement to A_LAST.
-**************************************************************************/
-bool unit_type_exists(Unit_Type_id id)
-{
- if (id<0 || id>=U_LAST || id>=game.num_unit_types)
- return FALSE;
- else
- return unit_types[id].tech_requirement!=A_LAST;
-}
-
-/**************************************************************************
...
**************************************************************************/
struct unit_type *get_unit_type(Unit_Type_id id)
@@ -340,9 +325,11 @@
if (!can_player_build_unit_direct(pplayer, id))
return -1;
- while (unit_type_exists(id = unit_types[id].obsoleted_by))
- if (can_player_build_unit_direct(pplayer, id))
+ while ((id = unit_types[id].obsoleted_by) != -1) {
+ if (can_player_build_unit_direct(pplayer, id)) {
best_upgrade = id;
+ }
+ }
return best_upgrade;
}
@@ -474,8 +461,7 @@
Impr_Type_id impr_req;
Tech_Type_id tech_req;
- if (!unit_type_exists(id))
- return FALSE;
+ CHECK_UNIT_TYPE(id);
if (unit_type_flag(id, F_NUCLEAR) && game.global_wonders[B_MANHATTEN] == 0)
return FALSE;
if (unit_type_flag(id, F_NOBUILD)) {
@@ -517,9 +503,11 @@
{
if (!can_player_build_unit_direct(p, id))
return FALSE;
- while(unit_type_exists((id = unit_types[id].obsoleted_by)))
- if (can_player_build_unit_direct(p, id))
+ while ((id = unit_types[id].obsoleted_by) != -1) {
+ if (can_player_build_unit_direct(p, id)) {
return FALSE;
+ }
+ }
return TRUE;
}
@@ -530,13 +518,11 @@
**************************************************************************/
bool can_player_eventually_build_unit(struct player *p, Unit_Type_id id)
{
- if (!unit_type_exists(id)) {
- return FALSE;
- }
+ CHECK_UNIT_TYPE(id);
if (unit_type_flag(id, F_NOBUILD)) {
return FALSE;
}
- while (unit_type_exists((id = unit_types[id].obsoleted_by))) {
+ while ((id = unit_types[id].obsoleted_by) != -1) {
if (can_player_build_unit_direct(p, id)) {
return FALSE;
}
@@ -549,7 +535,6 @@
which unit types have given flag or role.
For these functions flags and roles are considered to be in the same "space",
and any "role" argument can also be a "flag".
-Only units which pass unit_type_exists are counted.
Unit order is in terms of the order in the units ruleset.
**************************************************************************/
static bool first_init = TRUE;
@@ -565,7 +550,7 @@
/* Count: */
unit_type_iterate(u) {
- if(unit_type_exists(u) && func_has(u, i)) {
+ if (func_has(u, i)) {
n_with_role[i]++;
}
} unit_type_iterate_end;
@@ -574,7 +559,7 @@
with_role[i] = fc_malloc(n_with_role[i]*sizeof(Unit_Type_id));
j = 0;
unit_type_iterate(u) {
- if(unit_type_exists(u) && func_has(u, i)) {
+ if (func_has(u, i)) {
with_role[i][j++] = u;
}
} unit_type_iterate_end;
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.30
diff -u -r1.30 unittype.h
--- common/unittype.h 20 Jul 2004 10:54:30 -0000 1.30
+++ common/unittype.h 3 Sep 2004 04:28:41 -0000
@@ -223,8 +223,8 @@
extern struct unit_type unit_types[U_LAST];
+#define CHECK_UNIT_TYPE(ut) (assert((ut) >= 0 && (ut) < game.num_unit_types))
-bool unit_type_exists(Unit_Type_id id);
struct unit_type *get_unit_type(Unit_Type_id id);
struct unit_type *unit_type(struct unit *punit);
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.258
diff -u -r1.258 cityturn.c
--- server/cityturn.c 28 Aug 2004 19:15:39 -0000 1.258
+++ server/cityturn.c 3 Sep 2004 04:28:43 -0000
@@ -804,6 +804,8 @@
we can build. Return id if we can't upgrade at all. NB: returning
id doesn't guarantee that pcity really _can_ build id; just that
pcity can't build whatever _obsoletes_ id.
+
+ FIXME: this function is a duplicate of can_upgrade_unittype.
**************************************************************************/
static Unit_Type_id unit_upgrades_to(struct city *pcity, Unit_Type_id id)
{
@@ -812,7 +814,7 @@
if (!can_build_unit_direct(pcity, check)) {
return -1;
}
- while(unit_type_exists(check = unit_types[check].obsoleted_by)) {
+ while ((check = unit_types[check].obsoleted_by) != -1) {
if (can_build_unit_direct(pcity, check)) {
latest_ok = check;
}
@@ -833,7 +835,7 @@
int id = pcity->currently_building;
int id2 = unit_upgrades_to(pcity, pcity->currently_building);
- if (can_build_unit_direct(pcity, id2)) {
+ if (id2 != -1 && can_build_unit_direct(pcity, id2)) {
pcity->currently_building = id2;
notify_player_ex(pplayer, pcity->x, pcity->y, E_UNIT_UPGRADED,
_("Game: Production of %s is upgraded to %s in %s."),
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.192
diff -u -r1.192 ruleset.c
--- server/ruleset.c 31 Aug 2004 04:40:50 -0000 1.192
+++ server/ruleset.c 3 Sep 2004 04:28:43 -0000
@@ -865,25 +865,16 @@
free(def_vblist);
}
- /* Tech requirement is used to flag removed unit_types, which
- we might want to know for other fields. After this we
- can use unit_type_exists()
- */
unit_type_iterate(i) {
u = &unit_types[i];
u->tech_requirement = lookup_tech(file, sec[i], "tech_req",
- FALSE, filename, u->name);
+ TRUE, filename, u->name);
} unit_type_iterate_end;
unit_type_iterate(i) {
u = &unit_types[i];
- if (unit_type_exists(i)) {
- u->obsoleted_by = lookup_unit_type(file, sec[i],
- "obsolete_by", FALSE, filename,
u->name);
- } else {
- (void) section_file_lookup(file, "%s.obsolete_by", sec[i]); /* unused */
- u->obsoleted_by = -1;
- }
+ u->obsoleted_by = lookup_unit_type(file, sec[i], "obsolete_by",
+ FALSE, filename, u->name);
} unit_type_iterate_end;
/* main stats: */
@@ -1014,20 +1005,12 @@
/* Some more consistency checking: */
unit_type_iterate(i) {
- if (unit_type_exists(i)) {
- u = &unit_types[i];
- if (!tech_exists(u->tech_requirement)) {
- freelog(LOG_ERROR,
- "unit_type \"%s\" depends on removed tech \"%s\" (%s)",
- u->name, advances[u->tech_requirement].name, filename);
- u->tech_requirement = A_LAST;
- }
- if (u->obsoleted_by!=-1 && !unit_type_exists(u->obsoleted_by)) {
- freelog(LOG_ERROR,
- "unit_type \"%s\" obsoleted by removed unit \"%s\" (%s)",
- u->name, unit_types[u->obsoleted_by].name, filename);
- u->obsoleted_by = -1;
- }
+ u = &unit_types[i];
+ if (!tech_exists(u->tech_requirement)) {
+ freelog(LOG_ERROR,
+ "unit_type \"%s\" depends on removed tech \"%s\" (%s)",
+ u->name, advances[u->tech_requirement].name, filename);
+ u->tech_requirement = A_LAST;
}
} unit_type_iterate_end;
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.183
diff -u -r1.183 savegame.c
--- server/savegame.c 3 Sep 2004 01:21:03 -0000 1.183
+++ server/savegame.c 3 Sep 2004 04:28:44 -0000
@@ -1145,7 +1145,7 @@
}
if ((pwl->wlefs[i] <= WEF_END) || (pwl->wlefs[i] >= WEF_LAST) ||
- ((pwl->wlefs[i] == WEF_UNIT) && !unit_type_exists(pwl->wlids[i])) ||
+ pwl->wlefs[i] == WEF_UNIT ||
((pwl->wlefs[i] == WEF_IMPR) && !improvement_exists(pwl->wlids[i]))) {
pwl->wlefs[i] = WEF_END;
pwl->wlids[i] = 0;
@@ -1184,7 +1184,7 @@
name = old_unit_type_name(id-68);
pwl->wlefs[i] = WEF_UNIT;
pwl->wlids[i] = find_unit_type_by_name_orig(name);
- end = !unit_type_exists(pwl->wlids[i]);
+ end = (pwl->wlids[i] < 0 || pwl->wlids[i] >= game.num_unit_types);
} else { /* must be an improvement id */
name = old_impr_type_name(id);
pwl->wlefs[i] = WEF_IMPR;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9800) unit_type_exists should be removed,
Jason Short <=
|
|