produce_secondary.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_production_by_cargo_1   4 // per output cargo; can be made temporary
  33. +#define var_production_by_cargo_2   5 // per output cargo; can be made temporary
  34. +#define var_production_by_cargo_3   6 // per output cargo; can be made temporary
  35. +
  36. +#define var_input_cargo_1           7 // stores only last processed input
  37. +#define var_input_cargo_2           8 // stores only last processed input
  38. +#define var_input_cargo_3           9 // stores only last processed input
  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
  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,100 @@
  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)) <= LOAD_PERM(var_production_span), var_reveived_timely_1),
  111. +			STORE_TEMP( (current_date - LOAD_PERM(var_date_received_2)) <= LOAD_PERM(var_production_span), var_reveived_timely_2),
  112. +			STORE_TEMP( (current_date - LOAD_PERM(var_date_received_3)) <= LOAD_PERM(var_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. +
  130. +			STORE_PERM( waiting_cargo_1 * LOAD_PERM(var_ratio_cargo_1) / (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS) +
  131. +			            ((waiting_cargo_1 * LOAD_PERM(var_ratio_cargo_1) % (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS)) > 0),
  132. +			    var_production_by_cargo_1
  133. +			),
  134. +			STORE_PERM( waiting_cargo_2 * LOAD_PERM(var_ratio_cargo_2) / (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS) +
  135. +			            ((waiting_cargo_2 * LOAD_PERM(var_ratio_cargo_2) % (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS)) > 0),
  136. +			    var_production_by_cargo_2
  137. +			),
  138. +			STORE_PERM( waiting_cargo_3 * LOAD_PERM(var_ratio_cargo_3) / (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS) +
  139. +			            ((waiting_cargo_3 * LOAD_PERM(var_ratio_cargo_3) % (MAX_SUM_PROD_RATIO * NUM_OUTPUT_CARGOS)) > 0),
  140. +			    var_production_by_cargo_3
  141. +			),
  142. +			
  143. +			STORE_TEMP( LOAD_PERM(var_production_by_cargo_1) +
  144. +			            LOAD_PERM(var_production_by_cargo_2) +
  145. +			            LOAD_PERM(var_production_by_cargo_3),
  146. +			    var_output_cargo_1
  147. +			),
  148. +			STORE_TEMP( LOAD_TEMP(var_output_cargo_1) * (NUM_OUTPUT_CARGOS > 1), var_output_cargo_2),
  149. +
  150. +			1
  151. +			] {
  152. +	IND_ID(simple_produce)
  153. +}
  154. +
  155. +#undef MAX_SUM_PROD_RATIO
  156. \ No newline at end of file
  157. diff --git a/sprites/nml/templates/undefs.pnml b/sprites/nml/templates/undefs.pnml
  158. --- a/sprites/nml/templates/undefs.pnml
  159. +++ b/sprites/nml/templates/undefs.pnml
  160. @@ -5,4 +5,19 @@
  161.   * 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/>.
  162.   */
  163.  
  164. +// for each industry
  165.  #undef IND_ID
  166. +
  167. +// from secondary production template
  168. +#undef NUM_OUTPUT_CARGOS
  169. +#undef IND_PROD_RATIO_CARGO1
  170. +#undef IND_PROD_RATIO_CARGO2
  171. +#undef IND_PROD_RATIO_CARGO3
  172. +
  173. +#undef IND_BOOST_12
  174. +#undef IND_BOOST_13
  175. +#undef IND_BOOST_21
  176. +#undef IND_BOOST_23
  177. +#undef IND_BOOST_31
  178. +#undef IND_BOOST_32
  179. +
  180.  

Return to top