21 #include "ai/ai.h" |
21 #include "ai/ai.h" |
22 #include "newgrf_house.h" |
22 #include "newgrf_house.h" |
23 #include "date.h" |
23 #include "date.h" |
24 #include "cargotype.h" |
24 #include "cargotype.h" |
25 #include "group.h" |
25 #include "group.h" |
|
26 #include "viewport.h" |
26 |
27 |
27 char _name_array[512][32]; |
28 char _name_array[512][32]; |
28 |
|
29 #ifndef MERSENNE_TWISTER |
|
30 |
|
31 #ifdef RANDOM_DEBUG |
|
32 #include "network/network_data.h" |
|
33 uint32 DoRandom(int line, const char *file) |
|
34 #else // RANDOM_DEBUG |
|
35 uint32 Random() |
|
36 #endif // RANDOM_DEBUG |
|
37 { |
|
38 |
|
39 uint32 s; |
|
40 uint32 t; |
|
41 |
|
42 #ifdef RANDOM_DEBUG |
|
43 if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server)) |
|
44 printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_player, file, line); |
|
45 #endif |
|
46 |
|
47 s = _random_seeds[0][0]; |
|
48 t = _random_seeds[0][1]; |
|
49 _random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7) + 1; |
|
50 return _random_seeds[0][1] = ROR(s, 3) - 1; |
|
51 } |
|
52 #endif // MERSENNE_TWISTER |
|
53 |
|
54 #if defined(RANDOM_DEBUG) && !defined(MERSENNE_TWISTER) |
|
55 uint DoRandomRange(uint max, int line, const char *file) |
|
56 { |
|
57 return GB(DoRandom(line, file), 0, 16) * max >> 16; |
|
58 } |
|
59 #else |
|
60 uint RandomRange(uint max) |
|
61 { |
|
62 return GB(Random(), 0, 16) * max >> 16; |
|
63 } |
|
64 #endif |
|
65 |
|
66 |
|
67 uint32 InteractiveRandom() |
|
68 { |
|
69 uint32 t = _random_seeds[1][1]; |
|
70 uint32 s = _random_seeds[1][0]; |
|
71 _random_seeds[1][0] = s + ROR(t ^ 0x1234567F, 7) + 1; |
|
72 return _random_seeds[1][1] = ROR(s, 3) - 1; |
|
73 } |
|
74 |
|
75 uint InteractiveRandomRange(uint max) |
|
76 { |
|
77 return GB(InteractiveRandom(), 0, 16) * max >> 16; |
|
78 } |
|
79 |
29 |
80 void InitializeVehicles(); |
30 void InitializeVehicles(); |
81 void InitializeWaypoints(); |
31 void InitializeWaypoints(); |
82 void InitializeDepots(); |
32 void InitializeDepots(); |
83 void InitializeEngines(); |
33 void InitializeEngines(); |
103 { |
53 { |
104 AllocateMap(size_x, size_y); |
54 AllocateMap(size_x, size_y); |
105 |
55 |
106 AddTypeToEngines(); // make sure all engines have a type |
56 AddTypeToEngines(); // make sure all engines have a type |
107 |
57 |
108 SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, 0, WC_MAIN_WINDOW, 0); |
58 SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0); |
109 |
59 |
110 _pause_game = 0; |
60 _pause_game = 0; |
111 _fast_forward = 0; |
61 _fast_forward = 0; |
112 _tick_counter = 0; |
62 _tick_counter = 0; |
113 _realtime_tick = 0; |
63 _realtime_tick = 0; |