forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simfab.h
751 lines (613 loc) · 21.9 KB
/
simfab.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
/*
* Copyright (c) 1997 - 2001 Hansjörg Malthaner
*
* This file is part of the Simutrans project under the artistic license.
* (see license.txt)
*/
#ifndef simfab_h
#define simfab_h
#include "dataobj/koord3d.h"
#include "dataobj/translator.h"
#include "tpl/slist_tpl.h"
#include "tpl/vector_tpl.h"
#include "tpl/array_tpl.h"
#include "descriptor/factory_desc.h"
#include "halthandle_t.h"
#include "simworld.h"
#include "utils/plainstring.h"
class player_t;
class stadt_t;
class ware_t;
class leitung_t;
/**
* Factory statistics
* @author Knightly
*/
#define MAX_MONTH (12)
#define FAB_PRODUCTION (0)
#define FAB_POWER (1)
#define FAB_BOOST_ELECTRIC (2)
#define FAB_BOOST_PAX (3)
#define FAB_BOOST_MAIL (4)
#define FAB_PAX_GENERATED (5)
#define FAB_PAX_DEPARTED (6)
#define FAB_PAX_ARRIVED (7)
#define FAB_MAIL_GENERATED (8)
#define FAB_MAIL_DEPARTED (9)
#define FAB_MAIL_ARRIVED (10)
#define MAX_FAB_STAT (11)
// reference lines
#define FAB_REF_MAX_BOOST_ELECTRIC (0)
#define FAB_REF_MAX_BOOST_PAX (1)
#define FAB_REF_MAX_BOOST_MAIL (2)
#define FAB_REF_DEMAND_ELECTRIC (3)
#define FAB_REF_DEMAND_PAX (4)
#define FAB_REF_DEMAND_MAIL (5)
#define MAX_FAB_REF_LINE (6)
// statistics for goods
#define MAX_FAB_GOODS_STAT (4)
// common to both input and output goods
#define FAB_GOODS_STORAGE (0)
// input goods
#define FAB_GOODS_RECEIVED (1)
#define FAB_GOODS_CONSUMED (2)
#define FAB_GOODS_TRANSIT (3)
// output goods
#define FAB_GOODS_DELIVERED (1)
#define FAB_GOODS_PRODUCED (2)
// production happens in every second
#define PRODUCTION_DELTA_T_BITS (10)
#define PRODUCTION_DELTA_T (1 << PRODUCTION_DELTA_T_BITS)
// default production factor
#define DEFAULT_PRODUCTION_FACTOR_BITS (8)
#define DEFAULT_PRODUCTION_FACTOR (1 << DEFAULT_PRODUCTION_FACTOR_BITS)
// precision of apportioned demand (i.e. weights of factories at target cities)
#define DEMAND_BITS (4)
/**
* JIT2 output scale constants.
*/
// The fixed point precision for work done fraction.
static const uint32 WORK_BITS = 16;
// The minimum allowed production rate for a factory. This is to limit the time outputs take to fill completly (so factories idle sooner).
// Fixed point form range must be between 0.0 and 1.0.
static const sint32 WORK_SCALE_MINIMUM_FRACTION = (5 << WORK_BITS) / 100; // ~5%, 1/20 of the full production rate.
// The number of times minimum_shipment must be in current storage before rampdown starts.
// Must be at least 2 to allow for full production as shipment is not instant.
static const sint32 OUTPUT_SCALE_RAMPDOWN_MULTIPLYER = 2; // Two shipments must be ready.
// The maximum rate at which power boost change change per second.
// This limit is required to help stiffen overloaded networks to combat oscilations caused by feedback.
static const sint32 BOOST_POWER_CHANGE_RATE = (5 << DEFAULT_PRODUCTION_FACTOR_BITS) / 100; // ~5%
/**
* Shipment size constants.
*/
// The maximum shipment size in whole units.
// Must be greater than 0.
static const uint32 SHIPMENT_MAX_SIZE = 10; // Traditional value.
// The minimum number of whole shipments a facotry can store.
// Must be greater than 0 to prevent division by 0.
static const uint32 SHIPMENT_NUM_MIN = 4; // Quarters should allow reasonably fair distribution.
/**
* Convert internal values to displayed values
*/
sint64 convert_goods(sint64 value);
sint64 convert_power(sint64 value);
sint64 convert_boost(sint64 value);
class ware_production_t
{
private:
const goods_desc_t *type;
// Knightly : statistics for each goods
sint64 statistics[MAX_MONTH][MAX_FAB_GOODS_STAT];
sint64 weighted_sum_storage;
/// clears statistics, transit, and weighted_sum_storage
void init_stats();
public:
ware_production_t() : type(NULL), menge(0), max(0)/*, transit(statistics[0][FAB_GOODS_TRANSIT])*/,
max_transit(0), placing_orders(false), index_offset(0)
{
#ifdef TRANSIT_DISTANCE
count_suppliers = 0;
#endif
init_stats();
}
const goods_desc_t* get_typ() const { return type; }
void set_typ(const goods_desc_t *t) { type=t; }
// Knightly : functions for manipulating goods statistics
void roll_stats(uint32 factor, sint64 aggregate_weight);
void rdwr(loadsave_t *file);
const sint64* get_stats() const { return *statistics; }
void book_stat(sint64 value, int stat_type) { assert(stat_type<MAX_FAB_GOODS_STAT); statistics[0][stat_type] += value; }
void set_stat(sint64 value, int stat_type) { assert(stat_type<MAX_FAB_GOODS_STAT); statistics[0][stat_type] = value; }
sint64 get_stat(int month, int stat_type) const { assert(stat_type<MAX_FAB_GOODS_STAT); return statistics[month][stat_type]; }
/**
* convert internal units to displayed values
*/
sint64 get_stat_converted(int month, int stat_type) const {
assert(stat_type<MAX_FAB_GOODS_STAT);
sint64 value = statistics[month][stat_type];
if (stat_type==FAB_GOODS_STORAGE || stat_type==FAB_GOODS_CONSUMED) {
value = convert_goods(value);
}
return value;
}
void book_weighted_sum_storage(uint32 factor, sint64 delta_time);
sint32 menge; // in internal units shifted by precision_bits (see step)
sint32 max;
/// Cargo currently in transit from/to this slot. Equivalent to statistics[0][FAB_GOODS_TRANSIT].
sint32 get_in_transit() const { return (sint32)statistics[0][FAB_GOODS_TRANSIT]; }
/// Annonmyous union used to save memory and readability. Contains supply flow control limiters.
union{
// Classic : Current limit on cargo in transit (maximum network capacity), depending on sum of all supplier output storage.
sint32 max_transit; //JIT<2 Input
// JIT Version 2 : Current demand for the good. Orders when greater than 0.
sint32 demand_buffer; //JIT2 Input
// The minimum shipment size. Used to control delivery to stops and for production ramp-down.
sint32 min_shipment; // Output
};
// Ordering lasts at least 1 tick period to allow all suppliers time to send (fair). Used by inputs.
bool placing_orders;
#ifdef TRANSIT_DISTANCE
sint32 count_suppliers; // only needed for averaging
#endif
uint32 index_offset; // used for haltlist and lieferziele searches in verteile_waren to produce round robin results
// Production rate for outputs. Returns fixed point with WORK_BITS fractional bits.
sint32 calculate_output_production_rate() const;
// Production rate for JIT2 demands. Returns fixed point with WORK_BITS fractional bits.
sint32 calculate_demand_production_rate() const;
};
/**
* Eine Klasse für Fabriken in Simutrans. Fabriken produzieren und
* verbrauchen Waren und beliefern nahe Haltestellen.
*
* @date 1998
* @see haltestelle_t
* @author Hj. Malthaner
*/
class fabrik_t
{
public:
/**
* Constants
* @author Hj. Malthaner
*/
enum { precision_bits = 10, old_precision_bits = 10, precision_mask = 1023 };
private:
/**
* Factory statistics
* @author Knightly
*/
sint64 statistics[MAX_MONTH][MAX_FAB_STAT];
sint64 weighted_sum_production;
sint64 weighted_sum_boost_electric;
sint64 weighted_sum_boost_pax;
sint64 weighted_sum_boost_mail;
sint64 weighted_sum_power;
sint64 aggregate_weight;
// Control logic type determines how a factory behaves with regards to inputs and outputs.
enum CL_TYPE {
CL_NONE, // This factory does nothing! (might be useful for scenarios)
// Producers are at the bottom of every supply chain.
CL_PROD_CLASSIC, // Classic producer logic.
CL_PROD_MANY, // Producer of many outputs.
// Factories are in the middle of every supply chain.
CL_FACT_CLASSIC, // Classic factory logic, consume at maximum output rate or minimum input.
CL_FACT_MANY, // Enhanced factory logic, consume at average of output rate or minimum input averaged.
// Consumers are at the top of every supply chain.
CL_CONS_CLASSIC, // Classic consumer logic. Can generate power.
CL_CONS_MANY, // Consumer that consumes multiple inputs, possibly produces power.
// Electricity producers provide power.
CL_ELEC_PROD, // Simple electricity source. (green energy)
CL_ELEC_CLASSIC, // Classic electricity producer behaviour with no inputs.
} control_type;
// Demand buffer order logic;
enum DL_TYPE {
DL_NONE, // Has no inputs to demand.
DL_SYNC, // All inputs ordered together.
DL_ASYNC, // All inputs ordered separatly.
DL_OLD // Use maximum in-transit and storage to determine demand.
} demand_type;
// Boost logic determines what factors boost factory production.
enum BL_TYPE {
BL_NONE, // Production cannot be boosted.
BL_PAXM, // Production boosted only using passengers/mail.
BL_POWER, // Production boosted with power as well. Needs aditional logic for correct ordering.
BL_CLASSIC, // Production boosted in classic way.
} boost_type;
// Knightly : Functions for manipulating factory statistics
void init_stats();
void set_stat(sint64 value, int stat_type) { assert(stat_type<MAX_FAB_STAT); statistics[0][stat_type] = value; }
// Knightly : For accumulating weighted sums for average statistics
void book_weighted_sums(sint64 delta_time);
/**
* Die möglichen Lieferziele
* @author Hj. Malthaner
*/
vector_tpl <koord> lieferziele;
uint32 lieferziele_active_last_month;
/**
* suppliers to this factory
* @author hsiegeln
*/
vector_tpl <koord> suppliers;
/**
* fields of this factory (only for farms etc.)
* @author prissi/Knightly
*/
struct field_data_t
{
koord location;
uint16 field_class_index;
field_data_t() : field_class_index(0) {}
explicit field_data_t(const koord loc) : location(loc), field_class_index(0) {}
field_data_t(const koord loc, const uint16 class_index) : location(loc), field_class_index(class_index) {}
bool operator==(const field_data_t &other) const { return location==other.location; }
};
vector_tpl <field_data_t> fields;
/**
* Distribute products to connected stops
* @author Hj. Malthaner
*/
void verteile_waren(const uint32 product);
// List of target cities
vector_tpl<stadt_t *> target_cities;
player_t *owner;
static karte_ptr_t welt;
const factory_desc_t *desc;
/**
* Is construction site rotated?
* @author V.Meyer
*/
uint8 rotate;
/**
* production base amount
* @author Hj. Malthaner
*/
sint32 prodbase;
/**
* multipliers for the production base amount
* @author Hj. Malthaner
*/
sint32 prodfactor_electric;
sint32 prodfactor_pax;
sint32 prodfactor_mail;
array_tpl<ware_production_t> input; ///< array for input/consumed goods
array_tpl<ware_production_t> output; ///< array for output/produced goods
/**
* Zeitakkumulator für Produktion
* @author Hj. Malthaner
*/
sint32 delta_sum;
uint32 delta_menge;
// production remainder when scaled to PRODUCTION_DELTA_T. added back next step to eliminate cumulative error
uint32 menge_remainder;
// Knightly : number of rounds where there is active production or consumption
uint8 activity_count;
// The adjacent connected transformer, if any.
leitung_t *transformer;
// true, if the factory did produce enough in the last step to require power
bool currently_producing;
uint32 last_sound_ms;
uint32 total_input, total_transit, total_output;
uint8 status;
/**
* Inactive caches, used to speed up logic when dealing with inputs and outputs.
*/
uint8 inactive_outputs;
uint8 inactive_inputs;
uint8 inactive_demands;
/// Position of a building of the factory.
koord3d pos;
/// Position of the nw-corner tile of the factory.
koord3d pos_origin;
/**
* Number of times the factory has expanded so far
* Only for factories without fields
* @author Knightly
*/
uint16 times_expanded;
/**
* Electricity amount scaled with prodbase
* @author TurfIt
*/
uint32 scaled_electric_demand;
/**
* Pax/mail demand scaled with prodbase and month length
* @author Knightly
*/
uint32 scaled_pax_demand;
uint32 scaled_mail_demand;
/**
* Update scaled electricity amount
* @author TurfIt
*/
void update_scaled_electric_demand();
/**
* Update scaled pax/mail demand
* @author Knightly
*/
void update_scaled_pax_demand();
void update_scaled_mail_demand();
/**
* Update production multipliers for pax and mail
* @author Knightly
*/
void update_prodfactor_pax();
void update_prodfactor_mail();
/**
* Re-calculate the pax/mail demands of factory at target cities
* @author Knightly
*/
void recalc_demands_at_target_cities();
/**
* Recalculate storage capacities based on prodbase or capacities contributed by fields
* @author Knightly
*/
void recalc_storage_capacities();
/**
* Class for collecting arrival data and calculating pax/mail boost with fixed period length
* @author Knightly
*/
#define PERIOD_BITS (18) // determines period length on which boost calculation is based
#define SLOT_BITS (6) // determines the number of time slots available
#define SLOT_COUNT (1<<SLOT_BITS) // number of time slots for accumulating arrived pax/mail
class arrival_statistics_t
{
private:
uint16 slots[SLOT_COUNT];
uint16 current_slot;
uint16 active_slots; // number of slots covered since aggregate arrival last increased from 0 to +ve
uint32 aggregate_arrival;
uint32 scaled_demand;
public:
void init();
void rdwr(loadsave_t *file);
void set_scaled_demand(const uint32 demand) { scaled_demand = demand; }
#define ARRIVALS_CHANGED (1)
#define ACTIVE_SLOTS_INCREASED (2)
sint32 advance_slot();
void book_arrival(const uint16 amount);
uint16 get_active_slots() const { return active_slots; }
uint32 get_aggregate_arrival() const { return aggregate_arrival; }
uint32 get_scaled_demand() const { return scaled_demand; }
};
void update_transit_intern( const ware_t *ware, bool add );
/**
* Arrival data for calculating pax/mail boost
* @author Knightly
*/
arrival_statistics_t arrival_stats_pax;
arrival_statistics_t arrival_stats_mail;
plainstring name;
/**
* For advancement of slots for boost calculation
* @author Knightly
*/
sint32 delta_slot;
void recalc_factory_status();
// create some smoke on the map
void smoke() const;
// scales the amount of production based on the amount already in storage
uint32 scale_output_production(const uint32 product, uint32 menge) const;
/**
* Convenience method that deals with casting.
*/
void set_power_supply(uint32 supply);
/**
* Convenience method that deals with casting.
*/
uint32 get_power_supply() const;
/**
* Convenience method that deals with casting.
*/
sint32 get_power_consumption() const;
/**
* Convenience method that deals with casting.
*/
void set_power_demand(uint32 demand);
/**
* Convenience method that deals with casting.
*/
uint32 get_power_demand() const;
/**
* Convenience method that deals with casting.
*/
sint32 get_power_satisfaction() const;
/**
*
*/
sint64 get_power() const;
public:
fabrik_t(loadsave_t *file);
fabrik_t(koord3d pos, player_t* owner, const factory_desc_t* factory_desc, sint32 initial_prod_base);
~fabrik_t();
/**
* Return/book statistics
* @author Knightly
*/
const sint64* get_stats() const { return *statistics; }
sint64 get_stat(int month, int stat_type) const { assert(stat_type<MAX_FAB_STAT); return statistics[month][stat_type]; }
void book_stat(sint64 value, int stat_type) { assert(stat_type<MAX_FAB_STAT); statistics[0][stat_type] += value; }
// This updates maximum in-transit. Important for loading.
static void update_transit( const ware_t *ware, bool add );
// This updates transit stats for freshly produced goods. Includes logic to decrement demand counters.
static void apply_transit( const ware_t *ware );
/**
* convert internal units to displayed values
*/
sint64 get_stat_converted(int month, int stat_type) const {
assert(stat_type<MAX_FAB_STAT);
sint64 value = statistics[month][stat_type];
switch(stat_type) {
case FAB_POWER:
value = convert_power(value);
break;
case FAB_BOOST_ELECTRIC:
case FAB_BOOST_PAX:
case FAB_BOOST_MAIL:
value = convert_boost(value);
break;
default: ;
}
return value;
}
static fabrik_t * get_fab(const koord &pos);
/**
* @return vehicle description object
* @author Hj. Malthaner
*/
const factory_desc_t *get_desc() const {return desc; }
void finish_rd();
/// gets position of a building belonging to factory
koord3d get_pos() const { return pos; }
void rotate90( const sint16 y_size );
void link_halt(halthandle_t halt);
void unlink_halt(halthandle_t halt);
const vector_tpl<koord>& get_lieferziele() const { return lieferziele; }
bool is_active_lieferziel( koord k ) const;
const vector_tpl<koord>& get_suppliers() const { return suppliers; }
/**
* Functions for manipulating the list of connected cities
* @author Hj. Malthaner/prissi/Knightly
*/
void add_target_city(stadt_t *const city);
void remove_target_city(stadt_t *const city);
void clear_target_cities();
const vector_tpl<stadt_t *>& get_target_cities() const { return target_cities; }
/**
* Fügt ein neues Lieferziel hinzu
* @author Hj. Malthaner
*/
void add_lieferziel(koord ziel);
void rem_lieferziel(koord pos);
/**
* adds a supplier
* @author Hj. Malthaner
*/
void add_supplier(koord pos);
void rem_supplier(koord pos);
/**
* @return menge der ware typ
* -1 wenn typ nicht produziert wird
* sonst die gelagerte menge
*/
sint32 input_vorrat_an(const goods_desc_t *ware); // Vorrat von Warentyp
sint32 vorrat_an(const goods_desc_t *ware); // Vorrat von Warentyp
// true, if there was production requiring power in the last step
bool is_currently_producing() const { return currently_producing; }
/**
* True if a transformer is connected to this factory.
*/
bool is_transformer_connected() const { return transformer != NULL; }
/**
* Connect transformer to this factory.
*/
void set_transformer_connected(leitung_t *transformer) { this->transformer = transformer; }
/**
* @return 1 wenn consumption,
* 0 wenn Produktionsstopp,
* -1 wenn Ware nicht verarbeitet wird
*/
sint8 is_needed(const goods_desc_t *) const;
sint32 liefere_an(const goods_desc_t *, sint32 menge);
/**
* Calculate the JIT2 logic power boost amount using the currently attached transformer.
*/
sint32 get_jit2_power_boost() const;
void step(uint32 delta_t); // factory muss auch arbeiten
void new_month();
char const* get_name() const;
void set_name( const char *name );
PIXVAL get_color() const { return desc->get_color(); }
player_t *get_owner() const
{
grund_t const* const p = welt->lookup(pos);
return p ? p->first_obj()->get_owner() : 0;
}
void open_info_window();
// infostring on production
void info_prod(cbuffer_t& buf) const;
// infostring on targets/sources
void info_conn(cbuffer_t& buf) const;
void rdwr(loadsave_t *file);
/*
* Fills the vector with the koords of the tiles.
*/
void get_tile_list( vector_tpl<koord> &tile_list ) const;
/**
* gibt eine NULL-Terminierte Liste von Fabrikpointern zurück
*
* @author Hj. Malthaner
*/
static vector_tpl<fabrik_t *> & sind_da_welche(koord min, koord max);
// hier die methoden zum parametrisieren der Fabrik
/**
* Baut die Gebäude für die Fabrik
*
* @author Hj. Malthaner, V. Meyer
*/
void build(sint32 rotate, bool build_fields, bool force_initial_prodbase);
sint16 get_rotate() const { return rotate; }
/* field generation code
* spawns a field for sure if probability>=1000
* @author Kieron Green
*/
bool add_random_field(uint16 probability);
void remove_field_at(koord pos);
uint32 get_field_count() const { return fields.get_count(); }
/**
* total and current procduction/storage values
* @author Hj. Malthaner
*/
const array_tpl<ware_production_t>& get_input() const { return input; }
const array_tpl<ware_production_t>& get_output() const { return output; }
/**
* Production multipliers
* @author Hj. Malthaner
*/
sint32 get_prodfactor_electric() const { return prodfactor_electric; }
sint32 get_prodfactor_pax() const { return prodfactor_pax; }
sint32 get_prodfactor_mail() const { return prodfactor_mail; }
sint32 get_prodfactor() const { return DEFAULT_PRODUCTION_FACTOR + prodfactor_electric + prodfactor_pax + prodfactor_mail; }
/* does not takes month length into account */
sint32 get_base_production() const { return prodbase; }
void set_base_production(sint32 p);
sint32 get_current_production() const { return (sint32)welt->scale_with_month_length( ((sint64)prodbase * (sint64)get_prodfactor())>>8 ); }
/* prissi: returns the status of the current factory, as well as output */
enum { bad, medium, good, inactive, nothing };
static uint8 status_to_color[5];
uint8 get_status() const { return status; }
uint32 get_total_in() const { return total_input; }
uint32 get_total_transit() const { return total_transit; }
uint32 get_total_out() const { return total_output; }
/**
* Crossconnects all factories
* @author prissi
*/
void add_all_suppliers();
/* adds a new supplier to this factory
* fails if no matching goods are there
*/
bool add_supplier(fabrik_t* fab);
/**
* Return the scaled electricity amount and pax/mail demand
* @author Knightly
*/
uint32 get_scaled_electric_demand() const { return scaled_electric_demand; }
uint32 get_scaled_pax_demand() const { return scaled_pax_demand; }
uint32 get_scaled_mail_demand() const { return scaled_mail_demand; }
bool is_end_consumer() const { return (output.empty() && !desc->is_electricity_producer()); }
// Returns a list of goods produced by this factory.
slist_tpl<const goods_desc_t*> *get_produced_goods() const;
// Rebuild the factory inactive caches.
void rebuild_inactive_cache();
double get_production_per_second() const;
/* Calculate work rate using a ramp function.
* amount: The current amount.
* minimum: Minimum amount before work rate starts ramp down.
* maximum: Maximum before production stops.
* (opt) precision: Work rate fixed point fractional precision.
* returns: Work rate in fixed point form.
*/
static sint32 calculate_work_rate_ramp(sint32 const amount, sint32 const minimum, sint32 const maximum, uint32 const precision = WORK_BITS);
};
#endif