diff -u2r -X ../diff-ignore ../freeciv-orig/client/packhand.c ./client/packhand.c --- ../freeciv-orig/client/packhand.c Tue Jan 4 00:03:13 2000 +++ ./client/packhand.c Tue Jan 4 15:03:29 2000 @@ -1169,4 +1169,6 @@ b->obsolete_by = p->obsolete_by; b->variant = p->variant; + b->requires = p->requires; + b->need_terrain = p->need_terrain; free(b->helptext); diff -u2r -X ../diff-ignore ../freeciv-orig/common/city.c ./common/city.c --- ../freeciv-orig/common/city.c Tue Jan 4 00:03:13 2000 +++ ./common/city.c Tue Jan 4 14:58:09 2000 @@ -341,31 +341,26 @@ city_got_building(pcity, B_NUCLEAR)) && (id==B_POWER || id==B_HYDRO || id==B_NUCLEAR)) return 0; - if (id==B_RESEARCH && !city_got_building(pcity, B_UNIVERSITY)) + if (is_wonder(id) && get_improvement_type(id)->requires!=B_LAST && !city_got_building(pcity, get_improvement_type(id)->requires)) return 0; - if (id==B_UNIVERSITY && !city_got_building(pcity, B_LIBRARY)) - return 0; - if (id==B_STOCK && !city_got_building(pcity, B_BANK)) - return 0; - if (id == B_SEWER && !city_got_building(pcity, B_AQUEDUCT)) - return 0; - if (id==B_BANK && !city_got_building(pcity, B_MARKETPLACE)) - return 0; - if (id==B_MFG && !city_got_building(pcity, B_FACTORY)) - return 0; - if ((id==B_HARBOUR || id==B_COASTAL || id == B_OFFSHORE || id == B_PORT) && !is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN)) - return 0; - if ((id == B_HYDRO || id == B_HOOVER) - && !(map_get_terrain(pcity->x, pcity->y) == T_RIVER) - && !(map_get_special(pcity->x, pcity->y) & S_RIVER) - && !(map_get_terrain(pcity->x, pcity->y) == T_MOUNTAINS) - && !is_terrain_near_tile(pcity->x, pcity->y, T_MOUNTAINS) - && !is_terrain_near_tile(pcity->x, pcity->y, T_RIVER) - && !is_special_near_tile(pcity->x, pcity->y, S_RIVER) - ) + if (!is_wonder(id) && get_improvement_type(id)->requires!=B_LAST && !game.global_wonders[get_improvement_type(id)->requires]) return 0; + switch (get_improvement_type(id)->need_terrain) { + case 0: break; + case 1: if (!is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN)) return 0; + break; + case 2: if (!(map_get_terrain(pcity->x, pcity->y) == T_RIVER) + && !(map_get_special(pcity->x, pcity->y) & S_RIVER) + && !(map_get_terrain(pcity->x, pcity->y) == T_MOUNTAINS) + && !is_terrain_near_tile(pcity->x, pcity->y, T_MOUNTAINS) + && !is_terrain_near_tile(pcity->x, pcity->y, T_RIVER) + && !is_special_near_tile(pcity->x, pcity->y, S_RIVER)) + return 0; + break; + case 3: if (!is_terrain_near_tile(pcity->x, pcity->y, T_MOUNTAINS)) return 0; + break; + default: freelog(LOG_FATAL, "improvement type need_terrain corrupted in common/city.c"); + exit(1); + } if (id == B_SSTRUCTURAL || id == B_SCOMP || id == B_SMODULE) { - if (!game.global_wonders[B_APOLLO]) { - return 0; - } else { struct player *p=city_owner(pcity); if (p->spaceship.state >= SSHIP_LAUNCHED) @@ -377,5 +372,4 @@ if (id == B_SMODULE && p->spaceship.modules >= NUM_SS_MODULES) return 0; - } } if (is_wonder(id)) { diff -u2r -X ../diff-ignore ../freeciv-orig/common/city.h ./common/city.h --- ../freeciv-orig/common/city.h Tue Jan 4 00:03:13 2000 +++ ./common/city.h Tue Jan 4 14:32:41 2000 @@ -47,4 +47,6 @@ int obsolete_by; int variant; + int requires; + int need_terrain; char *helptext; }; diff -u2r -X ../diff-ignore ../freeciv-orig/common/packets.c ./common/packets.c --- ../freeciv-orig/common/packets.c Tue Jan 4 00:03:13 2000 +++ ./common/packets.c Tue Jan 4 14:33:24 2000 @@ -2356,4 +2356,6 @@ cptr=put_uint8(cptr, packet->obsolete_by); cptr=put_uint8(cptr, packet->variant); + cptr=put_uint8(cptr, packet->requires); + cptr=put_uint8(cptr, packet->need_terrain); cptr=put_string(cptr, packet->name); @@ -2387,4 +2389,6 @@ iget_uint8(&iter, &packet->obsolete_by); iget_uint8(&iter, &packet->variant); + iget_uint8(&iter, &packet->requires); + iget_uint8(&iter, &packet->need_terrain); iget_string(&iter, packet->name, sizeof(packet->name)); diff -u2r -X ../diff-ignore ../freeciv-orig/common/packets.h ./common/packets.h --- ../freeciv-orig/common/packets.h Mon Jan 3 13:47:29 2000 +++ ./common/packets.h Tue Jan 4 14:32:59 2000 @@ -540,4 +540,6 @@ int obsolete_by; int variant; + int requires; + int need_terrain; char *helptext; /* same as for packet_ruleset_unit, above */ }; diff -u2r -X ../diff-ignore ../freeciv-orig/data/default/buildings.ruleset ./data/default/buildings.ruleset --- ../freeciv-orig/data/default/buildings.ruleset Tue Jan 4 00:03:13 2000 +++ ./data/default/buildings.ruleset Tue Jan 4 14:51:34 2000 @@ -37,4 +37,8 @@ ; variant = controls hardwired effects options, unique to each ; building; 0 means default effect; see README.rulesets +; requires = optional dependency on the presence of a specific +; building in the city, or, if it is a wonder, in the world +; need_terrain = optional depency on nearby terrain; can be "none", "ocean", +; "hydro" or "mountain" ; helptext = optional help text string; should escape all raw newlines ; so that xgettext parsing works @@ -77,4 +81,5 @@ upkeep = 3 variant = 0 +requires = _("Marketplace") helptext = _("\ Together with the Marketplace improvement, a Bank increases the\ @@ -245,4 +250,5 @@ upkeep = 1 variant = 0 +need_terrain= "ocean" helptext = _("\ Gives one extra food resource on all Ocean squares. The city needs\ @@ -258,4 +264,5 @@ upkeep = 4 variant = 0 +need_terrain= "hydro" helptext = _("\ Reduces the amount of pollution generated in a city. It also\ @@ -356,4 +363,5 @@ upkeep = 3 variant = 0 +need_terrain= "ocean" helptext = _("\ Adds 1 extra shield resource on all Ocean squares in a city. The\ @@ -405,4 +413,5 @@ upkeep = 3 variant = 0 +need_terrain= "ocean" helptext = _("\ Allows a city to build veteran sea units. Also, damaged sea units\ @@ -454,4 +463,5 @@ upkeep = 3 variant = 0 +requires = _("University") helptext = _("\ Together with a Library and a University, a Research Lab increases\ @@ -494,4 +504,5 @@ upkeep = 2 variant = 0 +requires = _("Aqueduct") ; auto-help @@ -514,4 +525,5 @@ upkeep = 0 variant = 0 +requires = _("Apollo Program") helptext = _("\ Space Components can be differentiated into Propulsion and Fuel\ @@ -531,4 +543,5 @@ upkeep = 0 variant = 0 +requires = _("Apollo Program") helptext = _("\ Space Modules are the most expensive parts of spaceships. There\ @@ -557,4 +570,5 @@ upkeep = 0 variant = 0 +requires = _("Apollo Program") helptext = _("\ Space Structurals form the base of your spaceship. All other\ @@ -574,4 +588,5 @@ upkeep = 4 variant = 0 +requires = _("Bank") helptext = _("\ Together with a Marketplace and a Bank, a Stock Exchange boosts\ @@ -628,4 +643,5 @@ upkeep = 3 variant = 0 +requires = _("Library") helptext = _("\ Together with a Library, a University increases the science\ @@ -771,4 +787,5 @@ upkeep = 0 variant = 0 +need_terrain= "hydro" helptext = _("\ Works as if you had a Hydro Plant in every city. (This reduces\ diff -u2r -X ../diff-ignore ../freeciv-orig/server/citytools.c ./server/citytools.c --- ../freeciv-orig/server/citytools.c Tue Jan 4 00:03:13 2000 +++ ./server/citytools.c Mon Jan 3 15:00:52 2000 @@ -450,5 +450,5 @@ /************************************************************************** -corruption, corruption is halfed during love the XXX days. +corruption, corruption is halved during love the XXX days. **************************************************************************/ int city_corruption(struct city *pcity, int trade) diff -u2r -X ../diff-ignore ../freeciv-orig/server/ruleset.c ./server/ruleset.c --- ../freeciv-orig/server/ruleset.c Tue Jan 4 00:03:13 2000 +++ ./server/ruleset.c Tue Jan 4 14:51:06 2000 @@ -756,12 +756,26 @@ } } - + /************************************************************************** -... + Converts the name of an improvement into its index number +**************************************************************************/ +static int ruleset_find_building(char *building_name) +{ + struct improvement_type *b; + int i=0; + b = &improvement_types[i]; + while ((strcmp(building_name,b->name) != 0) && (i != B_LAST )) { + b = &improvement_types[++i]; + } + return i; +} + +/************************************************************************** + Loads and interprets buildings.ruleset **************************************************************************/ static void load_ruleset_buildings(char *ruleset_subdir) { struct section_file file; - char *filename, *datafile_options; + char *filename, *datafile_options, *t; char **sec; int i, j, nval; @@ -797,8 +811,33 @@ b->shield_upkeep = secfile_lookup_int(&file, "%s.upkeep", sec[i]); b->variant = secfile_lookup_int(&file, "%s.variant", sec[i]); - + b->helptext = lookup_helptext(&file, sec[i]); } + /* Baby one more time ... 'cos we need all names read first */ + for ( i=0; irequires = ruleset_find_building(t); + if (b->requires != B_LAST) { + if (0 == strcmp(t,"none")) { + freelog(LOG_FATAL, "Cannot find building %s required for %s in ruleset\n", t, b->name); + exit(1); + } + } + + t = secfile_lookup_str_default(&file, "none", "%s.need_terrain", sec[i]); + if (strcmp(t,"none")==0) { + b->need_terrain = 0; + } else if (strcmp(t,"ocean")==0) { + b->need_terrain = 1; + } else if (strcmp(t,"hydro")==0) { + b->need_terrain = 2; + } else if (strcmp(t,"mountain")==0) { + b->need_terrain = 3; + } + } + /* Some more consistency checking: */ for( i=0; iobsolete_by; packet.variant = b->variant; + packet.requires = b->requires; + packet.need_terrain = b->need_terrain; packet.helptext = b->helptext; /* pointer assignment */