| [Freeciv-Dev] Re: [PATCH] city_landlocked_sell_coastal_improvements gene[Top] [All Lists][Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
 
 I give the revised version my stamp of approval ;)
It could be simplified by changing 
+        while (improvement_types[impr].terr_gate[i] != T_OCEAN
+               && improvement_types[impr].terr_gate[i] != T_LAST) {
+          ++i;
+        }
+        if (improvement_types[impr].terr_gate[i] == T_OCEAN
+            && !city_has_terr_spec_gate(pcity, impr)) {
to 
if(!city_has_terr_spec_gate(pcity, impr) { 
but that would decrease speed. (Possibly a comment to this effect should
be added.)  Speed could be improved by keeping a 
list of improvements that had T_OCEAN in terr_gate, but that would 
increase complexity.  
I agree with the comment that at some point it should be generalized
to sell all relevant buildings after a terrain change.  For the 
present building.ruleset this is irrelevant.
It might be a good idea to use is_terrain_near_tile rather than 
adjc_iterate to check for nearness to T_OCEAN.
I think that this code is a useful improvement in generality of the 
code without any significant side effects (it does add a small 
constant factor time increase, however this is a rarely called function).
As such I think it should be applied.
-- 
Josh Cogliati
 
 |  |