src/industry_cmd.cpp
changeset 7205 0a6d45455ae5
parent 7203 39f68ddb39cc
child 7207 277c6c315403
equal deleted inserted replaced
7204:ef8181ff2c1e 7205:0a6d45455ae5
   927 	TileIndex tile = TileAddWrap(i->xy, x, y);
   927 	TileIndex tile = TileAddWrap(i->xy, x, y);
   928 
   928 
   929 	if (tile != INVALID_TILE) PlantFarmField(tile, i->index);
   929 	if (tile != INVALID_TILE) PlantFarmField(tile, i->index);
   930 }
   930 }
   931 
   931 
   932 static void MaybePlantFarmField(const Industry *i)
       
   933 {
       
   934 	if (CHANCE16(1, 8)) PlantRandomFarmField(i);
       
   935 }
       
   936 
       
   937 /**
   932 /**
   938  * Search callback function for ChopLumberMillTrees
   933  * Search callback function for ChopLumberMillTrees
   939  * @param tile to test
   934  * @param tile to test
   940  * @param data that is passed by the caller.  In this case, nothing
   935  * @param data that is passed by the caller.  In this case, nothing
   941  * @return the result of the test
   936  * @return the result of the test
   996 
   991 
   997 		IndustyBehaviour indbehav = indsp->behaviour;
   992 		IndustyBehaviour indbehav = indsp->behaviour;
   998 		i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + i->production_rate[0]);
   993 		i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + i->production_rate[0]);
   999 		i->produced_cargo_waiting[1] = min(0xffff, i->produced_cargo_waiting[1] + i->production_rate[1]);
   994 		i->produced_cargo_waiting[1] = min(0xffff, i->produced_cargo_waiting[1] + i->production_rate[1]);
  1000 
   995 
  1001 		if (indbehav & INDUSTRYBEH_PLANT_FIELDS) {
   996 		if ((indbehav & INDUSTRYBEH_PLANT_FIELDS) != 0) {
  1002 			MaybePlantFarmField(i);
   997 			bool plant;
  1003 		} else if ((indbehav & INDUSTRYBEH_CUT_TREES) && (i->counter & 0x1FF) == 0) {
   998 			if (HASBIT(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) {
  1004 			ChopLumberMillTrees(i);
   999 				plant = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->xy) != 0);
       
  1000 			} else {
       
  1001 				plant = CHANCE16(1, 8);
       
  1002 			}
       
  1003 
       
  1004 			if (plant) PlantRandomFarmField(i);
       
  1005 		}
       
  1006 		if ((indbehav & INDUSTRYBEH_CUT_TREES) != 0) {
       
  1007 			bool cut = ((i->counter & 0x1FF) == 0);
       
  1008 			if (HASBIT(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) {
       
  1009 				cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->xy) != 0);
       
  1010 			}
       
  1011 
       
  1012 			if (cut) ChopLumberMillTrees(i);
  1005 		}
  1013 		}
  1006 	}
  1014 	}
  1007 }
  1015 }
  1008 
  1016 
  1009 void OnTick_Industry()
  1017 void OnTick_Industry()