produce_secondary2.diff

Return to the initial folder
  1. diff --git a/sprites/nml/defines.pnml b/sprites/nml/defines.pnml
  2. --- a/sprites/nml/defines.pnml
  3. +++ b/sprites/nml/defines.pnml
  4. @@ -1,3 +1,10 @@
  5. +/*
  6. + * This file is part of FIRS industry set.
  7. + * FIRS industry set is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
  8. + * FIRS industry set is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRS industry set. If not, see <http://www.gnu.org/licenses/>.
  10. + */
  11. +
  12.  #define SPRITE_TREE 1593
  13.  #define SPRITE_TREE_DEAD 1596
  14.  
  15. @@ -8,7 +15,32 @@
  16.  /* Persistant storage for industries */
  17.  #define store_produced_1      0
  18.  
  19. +/* persistant storage for secondary industries (template produce_secondary_C) */
  20.  #define var_waiting_cargo_1   13
  21.  #define var_waiting_cargo_2   14
  22.  
  23. -#define store_closure_counter 15
  24. \ No newline at end of file
  25. +/* persistant storage for secondary industries (template produce_secondary) */
  26. +//                                  0 // unused
  27. +
  28. +#define var_ratio_cargo_1           1 // output per 8 units input of cargo 1; can be made temporary
  29. +#define var_ratio_cargo_2           2 // output per 8 units input of cargo 2; can be made temporary
  30. +#define var_ratio_cargo_3           3 // output per 8 units input of cargo 3; can be made temporary
  31. +
  32. +#define var_leftover_cargo_1        4 // non-processed cargo 1
  33. +#define var_leftover_cargo_2        5 // non-processed cargo 2
  34. +#define var_leftover_cargo_3        6 // non-processed cargo 3
  35. +
  36. +#define var_input_cargo_1           7 // stores only last processed input; for debugging only
  37. +#define var_input_cargo_2           8 // stores only last processed input; for debugging only
  38. +#define var_input_cargo_3           9 // stores only last processed input; for debugging only
  39. +
  40. +#define var_date_received_1        10 // date of last cargo 1 delivered
  41. +#define var_date_received_2        11 // date of last cargo 2 delivered
  42. +#define var_date_received_3        12 // date of last cargo 3 delivered
  43. +#define var_production_span        13 // time to consider a cargo usable for production boost (not yet used)
  44. +
  45. +//                                 14 // unused
  46. +
  47. +// for all industries (?)
  48. +
  49. +#define store_closure_counter      15 
  50. \ No newline at end of file
  51. diff --git a/sprites/nml/templates/produce_secondary.pnml b/sprites/nml/templates/produce_secondary.pnml
  52. new file mode 100644
  53. --- /dev/null
  54. +++ b/sprites/nml/templates/produce_secondary.pnml
  55. @@ -0,0 +1,110 @@
  56. +/*
  57. + * This file is part of FIRS industry set.
  58. + * FIRS industry set is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
  59. + * FIRS industry set is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  60. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRS industry set. If not, see <http://www.gnu.org/licenses/>.
  61. + */
  62. +
  63. +/* Production template for secondary industries with equal output to all output cargos
  64. + *
  65. + * Delivery period to consider a cargo for production ratios is the the last var_production_span days
  66. + * 
  67. + * It accepts up to three input cargos and produes up to two output cargos
  68. + * It uses the following permanent storages:
  69. + *
  70. + * var_date_received_1, var_date_received_2, var_date_received_3
  71. + * var_input_cargo_1, var_input_cargo_2, var_input_cargo_3
  72. + * var_ratio_cargo_1, var_ratio_cargo_2, var_ratio_cargo_3
  73. + * var_production_by_cargo_1, var_production_by_cargo_2, var_production_by_cargo_3
  74. + * var_production_span
  75. + *
  76. + * Needed defines:
  77. + * NUM_OUTPUT_CARGOS             number of output cargos
  78. + *
  79. + * The sum of the following should not exceed MAX_SUM_PROD_RATIO (see below):
  80. + * IND_PROD_RATIO_CARGO1         output per MAX_SUM_PROD_RATIO units input
  81. + * IND_PROD_RATIO_CARGO2         output per MAX_SUM_PROD_RATIO units input
  82. + * IND_PROD_RATIO_CARGO3         output per MAX_SUM_PROD_RATIO units input
  83. + *
  84. + * How cargos boost eachother (give in units of 1/MAX_SUM_PROD_RATIO)
  85. + * It should be noted that IND_PROD_RATIO_CARGO1 + IND_BOOST_21 + IND_BOOST_31 never should exceed MAX_SUM_PROD_RATIO
  86. + * and similar for the other two cargos
  87. + * IND_BOOST_12
  88. + * IND_BOOST_13
  89. + * IND_BOOST_21
  90. + * IND_BOOST_23
  91. + * IND_BOOST_31
  92. + * IND_BOOST_32
  93. + *
  94. + * IND_PRODUCTION_SPAN           time span which is considered for production ratios
  95. + *
  96. + */
  97. +
  98. +#define MAX_SUM_PROD_RATIO 8
  99. +
  100. +produce (IND_ID(simple_produce), waiting_cargo_1, waiting_cargo_2, waiting_cargo_3, LOAD_TEMP(var_output_cargo_1), LOAD_TEMP(var_output_cargo_2))
  101. +
  102. +switch (FEAT_INDUSTRIES, IND_ID(produce), 
  103. +			[
  104. +			STORE_PERM( max(LOAD_PERM(var_date_received_1),(waiting_cargo_1 > 0) * current_date), var_date_received_1),
  105. +			STORE_PERM( max(LOAD_PERM(var_date_received_2),(waiting_cargo_2 > 0) * current_date), var_date_received_2),
  106. +			STORE_PERM( max(LOAD_PERM(var_date_received_3),(waiting_cargo_3 > 0) * current_date), var_date_received_3),
  107. +			STORE_PERM( waiting_cargo_1, var_input_cargo_1),
  108. +			STORE_PERM( waiting_cargo_2, var_input_cargo_2),
  109. +			STORE_PERM( waiting_cargo_3, var_input_cargo_3),
  110. +			STORE_TEMP( (current_date - LOAD_PERM(var_date_received_1)) <= IND_PRODUCTION_SPAN, var_reveived_timely_1),
  111. +			STORE_TEMP( (current_date - LOAD_PERM(var_date_received_2)) <= IND_PRODUCTION_SPAN, var_reveived_timely_2),
  112. +			STORE_TEMP( (current_date - LOAD_PERM(var_date_received_3)) <= IND_PRODUCTION_SPAN, var_reveived_timely_3),
  113. +
  114. +			STORE_PERM( IND_PROD_RATIO_CARGO1 + 
  115. +			            LOAD_TEMP(var_reveived_timely_2) * IND_BOOST_21 +
  116. +			            LOAD_TEMP(var_reveived_timely_3) * IND_BOOST_31,
  117. +			    var_ratio_cargo_1
  118. +			),
  119. +			STORE_PERM( IND_PROD_RATIO_CARGO2 + 
  120. +			            LOAD_TEMP(var_reveived_timely_1) * IND_BOOST_12 +
  121. +			            LOAD_TEMP(var_reveived_timely_3) * IND_BOOST_32,
  122. +			    var_ratio_cargo_2
  123. +			),
  124. +			STORE_PERM( IND_PROD_RATIO_CARGO3 + 
  125. +			            LOAD_TEMP(var_reveived_timely_1) * IND_BOOST_13 +
  126. +			            LOAD_TEMP(var_reveived_timely_2) * IND_BOOST_23,
  127. +			    var_ratio_cargo_3
  128. +			),
  129. +			STORE_TEMP( waiting_cargo_1 + LOAD_PERM(var_leftover_cargo_1), var_amount_input_cargo_1),
  130. +			STORE_TEMP( waiting_cargo_2 + LOAD_PERM(var_leftover_cargo_1), var_amount_input_cargo_3),
  131. +			STORE_TEMP( waiting_cargo_3 + LOAD_PERM(var_leftover_cargo_1), var_amount_input_cargo_3),
  132. +			
  133. +
  134. +			STORE_TEMP( LOAD_TEMP(var_amount_input_cargo_1) * LOAD_PERM(var_ratio_cargo_1) / (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS),
  135. +			    var_production_by_cargo_1
  136. +			),
  137. +			STORE_PERM( LOAD_TEMP(var_amount_input_cargo_1) * LOAD_PERM(var_ratio_cargo_1) % (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS),
  138. +			    var_leftover_cargo_1
  139. +			)
  140. +			STORE_TEMP( LOAD_TEMP(var_amount_input_cargo_2) * LOAD_PERM(var_ratio_cargo_2) / (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS),
  141. +			    var_production_by_cargo_2
  142. +			),
  143. +			STORE_PERM( LOAD_TEMP(var_amount_input_cargo_2) * LOAD_PERM(var_ratio_cargo_2) % (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS),
  144. +			    var_leftover_cargo_2
  145. +			)
  146. +			STORE_TEMP( LOAD_TEMP(var_amount_input_cargo_3) * LOAD_PERM(var_ratio_cargo_3) / (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS),
  147. +			    var_production_by_cargo_3
  148. +			),
  149. +			STORE_PERM( LOAD_TEMP(var_amount_input_cargo_3) * LOAD_PERM(var_ratio_cargo_3) % (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS),
  150. +			    var_leftover_cargo_3
  151. +			)
  152. +			
  153. +			STORE_TEMP( LOAD_TEMP(var_production_by_cargo_1) +
  154. +			            LOAD_TEMP(var_production_by_cargo_2) +
  155. +			            LOAD_TEMP(var_production_by_cargo_3),
  156. +			    var_output_cargo_1
  157. +			),
  158. +			STORE_TEMP( LOAD_TEMP(var_output_cargo_1) * (NUM_OUTPUT_CARGOS > 1), var_output_cargo_2),
  159. +
  160. +			1
  161. +			] {
  162. +	IND_ID(simple_produce)
  163. +}
  164. +
  165. +#undef MAX_SUM_PROD_RATIO
  166. \ No newline at end of file
  167. diff --git a/sprites/nml/templates/undefs.pnml b/sprites/nml/templates/undefs.pnml
  168. --- a/sprites/nml/templates/undefs.pnml
  169. +++ b/sprites/nml/templates/undefs.pnml
  170. @@ -5,4 +5,19 @@
  171.   * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRS industry set. If not, see <http://www.gnu.org/licenses/>.
  172.   */
  173.  
  174. +// for each industry
  175.  #undef IND_ID
  176. +
  177. +// from secondary production template
  178. +#undef NUM_OUTPUT_CARGOS
  179. +#undef IND_PROD_RATIO_CARGO1
  180. +#undef IND_PROD_RATIO_CARGO2
  181. +#undef IND_PROD_RATIO_CARGO3
  182. +
  183. +#undef IND_BOOST_12
  184. +#undef IND_BOOST_13
  185. +#undef IND_BOOST_21
  186. +#undef IND_BOOST_23
  187. +#undef IND_BOOST_31
  188. +#undef IND_BOOST_32
  189. +
  190.  

Return to top