Complete.Org: Mailing Lists: Archives: freeciv-dev: January 1999:
[Freeciv-Dev] Patch, make it possible to detect required buildings
Home

[Freeciv-Dev] Patch, make it possible to detect required buildings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Patch, make it possible to detect required buildings
From: Lindqvist Marko <caz@xxxxxxxxxxxxxxxxx>
Date: Sun, 10 Jan 1999 17:32:30 +0200 (EET)

 I have been thinking some changes that would make it easier for AI to
check rules real time. My motive is of course that I'm making AI client
and want make it easier to maintain. If AI depends on me changing it's
source code every time any rule at FreeCiv changes, it will probably
always use a bit out of date rules. In the other hand, these changes at
FreeCiv code would also make it freeciv even easier to hack in some
respects.
 Changes may look like memory wasting at first, since new entries at
structures would be almost always zero (or some other 'normal' value). But
then again, structures in which new entries are added, are unique,
allocated just once for each server and client.

 There's several buildings that require another building being already
built in the city. After next few changes such buildings would be easier
to detect. (All changes against 1.7.2)

common/city.h:


 Add entry B_NONE to improvement type id:s

 enum improvement_type_id {
 B_NONE = -1,   /* Just in case some part of the program depends real
                   buildings beginning at 0. */
 B_AIRPORT,B_AQUEDUCT...


 Addition to improvement_type -structure:
 
 enum improvement_type_id required_building;


common/city.c:

 Add B_NONE as required building to all buildings
at improvement_types -array except:

 - Bank        requires B_MARKETPLACE
 - Mfg. Plant           B_FACTORY
 - Research lab         B_UNIVERSITY
 - Sewer system         B_AQUEDUCT
 - Stock exchange       B_BANK
 - University           B_LIBRARY


 At int could_build_improvement() replace lines

  if (id==B_RESEARCH && !city_got_building(pcity, B_UNIVERSITY))
  .
  .
  .
  if (id==B_MFG && !city_got_building(pcity, B_FACTORY))
    return 0;

  with

  if( ! city_got_building(pcity,improvement_types[id].required_building ))
    return 0;



 Caz

--

- No english sig available.



[Prev in Thread] Current Thread [Next in Thread]