1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-14 01:59:09 +00:00

Compare commits

..

396 Commits

Author SHA1 Message Date
rubidium
7def546fca (svn r11869) -Release: 0.6.0-beta3
Took way too long, but that happens when real life interferes and the bugcount is rising instead of declining.
2008-01-15 20:55:36 +00:00
rubidium
ef112812c6 (svn r11868) -Fix: some files were still mentioning that beta1 is the latest release when that's not the case. 2008-01-15 20:44:31 +00:00
rubidium
6891bc2011 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
-Fix: store changes to persistent storages after performing all the game logic instead of resetting them.
2008-01-15 18:51:46 +00:00
rubidium
576f8ad93e (svn r11866) -Codechange: swap OFB_* and OF_* so it conceptually in sync with other cases of *B_* vs *_* like VETSB_* and VETS_*. 2008-01-15 18:44:22 +00:00
ab7cb0804d (svn r11865) -Feature(tte): Support scrolling of drop down lists when in drag mode by moving the pointer above or below the list. 2008-01-15 16:30:08 +00:00
smatz
245f05a7cc (svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later 2008-01-15 15:00:01 +00:00
932c586dfe (svn r11863) -Fix (r11848): One day I'll learn C++... Delete all items in a drop down list before deleting the list. 2008-01-15 13:20:58 +00:00
rubidium
26c621945d (svn r11862) -Fix [FS#1559]: when two NewGRFs 'fight' to define the same cargo it could happen that the strings are defined by one cargo and the 'action2' by another and when one assumes that both come from the same NewGRF... So store the GRF ID with the strings. To be extra sure add the same protection mechanism to industries and towns too. 2008-01-15 13:19:49 +00:00
smatz
0078fd1699 (svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge 2008-01-15 11:45:29 +00:00
ea6535c864 (svn r11860) -Fix: Test station class validity against number of classes, not abosolute limit. 2008-01-15 11:43:06 +00:00
68a3df82b9 (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list. 2008-01-15 10:36:51 +00:00
2723128ba9 (svn r11858) -Fix (r1679): Mask and rule colour in drop down lists using wrong source value. (r1679 partially reverted r1368) 2008-01-15 08:14:22 +00:00
rubidium
c1108bd293 (svn r11857) -Fix: some compile time warnings. 2008-01-15 00:48:14 +00:00
glx
af59eb2543 (svn r11856) -Revert (r11772): since FS#1335 is solved, we do not need the extra checking and such anymore. 2008-01-15 00:11:28 +00:00
glx
8c13852373 (svn r11855) -Fix [FS#1335]: recompute town population when removing a 'newhouses' grf, or when loading a game with missing 'newhouses' grfs 2008-01-15 00:03:48 +00:00
1bcca5aae2 (svn r11854) -Fix (r11848): Nightly build farm showed up more compiler warnings... c++ is fun 2008-01-14 20:52:43 +00:00
bjarni
57ecf117c9 (svn r11853) -Fix [r11837]: [OSX] reconfigure killed the space in shared-dir
Thanks to TrueLight for finding the solution to this one
  Note: if the shared-dir setting is already broken due to this then you have to manually run configure again
2008-01-14 20:30:05 +00:00
miham
277ec663cb (svn r11852) -Update: WebTranslator2 update to 2008-01-14 21:05:38
brazilian_portuguese - 36 changed by fukumori (36)
korean     - 1 fixed by leejaeuk5 (1)
piglatin   - 20 fixed by adammw (20)
portuguese - 1 fixed by nars (1)
2008-01-14 20:06:18 +00:00
belugas
e789ee83ab (svn r11851) -Codechange: A few magic numbers removal, plus a little code style 2008-01-14 18:19:29 +00:00
ea808b2bfa (svn r11850) -Fix (r11848): forgot to update vc project files 2008-01-14 16:40:31 +00:00
bf0a7ae4fb (svn r11849) -Fix (r11848): Incomplete(?) class broke MSVC/mingw compilation 2008-01-14 16:35:49 +00:00
e4c05f8d78 (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed. 2008-01-14 16:10:58 +00:00
smatz
7beb63a93b (svn r11847) -Fix: do not affect the speed a train is entering a depot by trackbits behind it 2008-01-14 14:46:09 +00:00
027112e1fe (svn r11846) -Fix [FS#1651]: implicit conversion from unsigned to signed int caused compilation failure with MSVC. 2008-01-14 11:18:43 +00:00
smatz
bfc4d80c8e (svn r11845) -Codechange: simplify train collision detection a bit 2008-01-13 23:53:33 +00:00
glx
7d2d4314ec (svn r11844) -Fix: road vehicle count was incorrect in network lobby window 2008-01-13 22:27:06 +00:00
smatz
311c14c9f5 (svn r11843) -Fix: mark dirty canal tile even in diagonal direction from flooded tile 2008-01-13 22:12:39 +00:00
rubidium
933aea42cb (svn r11842) -Fix: libtimidity.cpp did not compile anymore. 2008-01-13 22:10:54 +00:00
glx
48861a9fae (svn r11841) -Fix: win32 compilation 2008-01-13 22:07:33 +00:00
rubidium
392d59f6a9 (svn r11840) -Codechange: split network.h so not everything in there needs to be included when wanting to know whether we are a server. 2008-01-13 21:51:53 +00:00
rubidium
3ca95f2a85 (svn r11839) -Codechange: move some variables from variables.h to a more logical location. 2008-01-13 21:41:24 +00:00
smatz
27e5deb719 (svn r11838) -Fix (r11320): draw correctly canal next to half flooded rail tile 2008-01-13 17:55:00 +00:00
bjarni
e281180d06 (svn r11837) -Feature: [OSX] added "/Library/Application Support/OpenTTD" to the search paths (based on patch by pv2b)
It is possible to set this to something else setting shared-dir with config
  This works on other OSes as well but it's off by default (and not really tested)
2008-01-13 17:45:29 +00:00
bjarni
ef219245af (svn r11836) -Fix [r11834]: [OSX] fixed compilation 2008-01-13 17:37:17 +00:00
smatz
8da51e5eb2 (svn r11835) -Fix: mark depot, viewports, vehicle lists and vehicle details dirty when a train crashes 2008-01-13 14:42:28 +00:00
rubidium
dc87b05e8c (svn r11834) -Codechange: only include settings_type.h if needed. 2008-01-13 14:37:30 +00:00
bjarni
2f9aab3217 (svn r11833) -Cleanup: changed save_params_array into one item for each line in config.lib
This should increase readability and conflict solving
2008-01-13 13:53:53 +00:00
rubidium
5c4150d304 (svn r11832) -Codechange: get rid of (quite) some VARDEFs. 2008-01-13 13:36:01 +00:00
smatz
b0c34f4d62 (svn r11831) -Fix: call TrainConsistChanged() when removing crashed train part to be consistent with saveload process 2008-01-13 13:11:59 +00:00
rubidium
cc52a56052 (svn r11830) -Fix [FS#1625]: road vehicles would not wait in line, but at a single point on bridges. Based on a patch by SmatZ. 2008-01-13 12:08:35 +00:00
rubidium
079abbd04b (svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral. 2008-01-13 01:39:22 +00:00
rubidium
d4e6a6bf57 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h. 2008-01-13 01:21:35 +00:00
rubidium
a78d73805f (svn r11827) -Codechange: do not include enum_type.hpp unnecessary. 2008-01-13 00:28:01 +00:00
glx
aa1d429d7f (svn r11826) -Fix (r10444): at least one instance of dmusic driver is needed for it to be registered and usable 2008-01-13 00:14:29 +00:00
rubidium
853ca6386e (svn r11825) -Fix (FS#1627): an articulated road vehicle could split up when it turned around at a corner and then would enter a drive through station at the next tile. 2008-01-12 22:10:00 +00:00
c7debf7908 (svn r11824) -Fix (r11822): Converting signs from TTD games incomplete 2008-01-12 21:25:04 +00:00
e677814a4b (svn r11823) -Fix (r11822): Custom names from old TTD games were not updated. 2008-01-12 21:01:27 +00:00
ab8382c0db (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
no limit to the amount of names.
-Fix: NewGRF engines could not be renamed.
2008-01-12 19:58:06 +00:00
smatz
a222fe2e86 (svn r11821) -Fix (r11802): 'optimization assert' when removing crashed wagon in some cases 2008-01-12 19:33:25 +00:00
smatz
704a75871a (svn r11820) -Fix: invalidate depot window when removing crashed train 2008-01-12 19:24:58 +00:00
smatz
712d4b6259 (svn r11819) -Fix: do not access the Vehicle struct that has been already deleted when removing crashed train 2008-01-12 19:20:44 +00:00
rubidium
ac528411df (svn r11818) -Codechange: split player.h into smaller pieces. 2008-01-12 14:10:35 +00:00
cbbc53e8f8 (svn r11817) -Codechange: Base vehicle group validity on owner, not name. 2008-01-12 13:36:22 +00:00
rubidium
ed727f9a64 (svn r11816) -Fix: forgot clearing one byte, causing the passwords to differ slightly on different platforms. 2008-01-12 08:34:16 +00:00
smatz
a4c1280945 (svn r11815) -Codechange (r11802): some compilers were giving a false warning about uninitialized variable 2008-01-11 22:29:47 +00:00
orudge
79e0a48c42 (svn r11814) -Fix: Get OpenTTD compiling again on OS/2 2008-01-11 18:53:52 +00:00
frosch
cbe7e5d668 (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots. 2008-01-11 17:12:41 +00:00
smatz
4d04077156 (svn r11812) -Codechange: introduce TrainExitDir() to simplify some functions 2008-01-11 15:10:59 +00:00
rubidium
04f936c2c6 (svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area'). 2008-01-11 00:30:32 +00:00
smatz
e5d33482b4 (svn r11810) -Fix (r11802): reset sets when leaving prematurely 2008-01-10 22:46:04 +00:00
smatz
a1266da782 (svn r11809) -Fix [FS#1643]: set expenses type when selling all vehicles in depot 2008-01-10 21:54:45 +00:00
smatz
40ef636f43 (svn r11808) -Fix: remember --with-ccache in config.cache
-Codechange: shuffle params a bit, sort params in save_params_array in the same order as the table above
2008-01-10 18:59:16 +00:00
frosch
1b936179ca (svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed. 2008-01-10 18:02:15 +00:00
glx
3976bb987d (svn r11806) -Fix (r11793) [FS#1638]: sign inversion when updating income and expenses 2008-01-10 15:51:34 +00:00
frosch
930f875c51 (svn r11805) -Fix [FS#1620]: VEHICLE_TRIGGER_EMPTY was triggered continuously while train waiting in station. 2008-01-10 13:13:18 +00:00
belugas
0181678cde (svn r11804) -Fix(r11797,FS#1636): Industry tiles should receive the same medecine as indstries themselves regarding the resolver's object 2008-01-10 00:53:17 +00:00
d30321d2af (svn r11803) -Fix: unlikely but possible infinite loop leading to undefined behaviour 2008-01-09 23:17:40 +00:00
smatz
f44a9a5d5b (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
-Codechange: use dedicated pathfinder for signal updating, resulting in better performance and possible future improvements
2008-01-09 23:00:59 +00:00
rubidium
6c954cad5f (svn r11801) -Codechange: remove some unneeded includes from some header files. 2008-01-09 21:27:39 +00:00
rubidium
998d7644f6 (svn r11800) -Codechange: move some functions to a more logical location + some type safety. 2008-01-09 21:05:03 +00:00
82fe2885ab (svn r11799) -Codechange: no need to special-case helicopter rotor 'overrides' 2008-01-09 20:23:12 +00:00
belugas
6375ea065b (svn r11798) -Codechange: add comments and give a more representative function's name 2008-01-09 18:35:18 +00:00
belugas
f67b5798a0 (svn r11797) -Fix: Add protection against not already created industry while doing industry callback.
Some variables used were linked to invalid industry.
2008-01-09 18:14:29 +00:00
glx
785572ea32 (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed. 2008-01-09 17:47:05 +00:00
glx
d133edd026 (svn r11794) -Fix [FS#1632]: reversing a train when loading at a station with an adjacent station in the same axis crashed. 2008-01-09 17:09:53 +00:00
rubidium
46650c54b6 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114). 2008-01-09 16:55:48 +00:00
rubidium
b4337eba83 (svn r11792) -Codechange: move some (virtually) globally included AI related structs to a place where they are only included a few times. 2008-01-09 16:40:02 +00:00
a27a240b87 (svn r11791) -Cleanup: move railtype data into table/, like other data files. 2008-01-09 16:02:13 +00:00
rubidium
ebb6259057 (svn r11790) -Update: apparantly it's 2008 already ;). Patch by Anne Stellingwerf (FS#1613). 2008-01-09 11:46:40 +00:00
a01fc4c142 (svn r11789) -Codechange: coding style for global variable names 2008-01-09 10:15:20 +00:00
rubidium
b4b3190b62 (svn r11788) -Fix (11787): makedepend doesn't mark delete files as changed... 2008-01-09 09:57:48 +00:00
rubidium
0e517fe023 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h. 2008-01-09 09:45:45 +00:00
931e6ea49d (svn r11786) -Codechange: shuffle more includes 2008-01-09 08:12:10 +00:00
rubidium
cd92981e9f (svn r11785) -Codechange: remove some unneeded includes. 2008-01-09 00:59:02 +00:00
ce2104ed47 (svn r11784) -Codechange: set up initial engine data in one place 2008-01-08 18:25:51 +00:00
814f47a3cc (svn r11783) -Codechange: compare engine type with its type property, not by its index 2008-01-08 18:16:26 +00:00
352f13dad1 (svn r11782) -Codechange: e->type was used before being properly initialized (it relied on previous runs) but there is no need to invalidate window data during game load as the windows in question cannot be open. 2008-01-08 16:07:32 +00:00
4479c06e2d (svn r11781) -Codechange: variable scope and initialization 2008-01-07 22:38:30 +00:00
77717563e1 (svn r11780) -Codechange: When compiling a dedicated server build, select the dedicated video driver by default. 2008-01-07 16:41:03 +00:00
glx
2832a6cafb (svn r11779) -Fix: win32 compile failed. Also removed a duplicate include 2008-01-07 15:35:36 +00:00
rubidium
eced1fb4ae (svn r11778) -Fix: compiles with ICONV failed. 2008-01-07 15:17:23 +00:00
rubidium
a3ccdcea36 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary. 2008-01-07 14:23:25 +00:00
rubidium
38115acf5a (svn r11776) -Codechange: more header splittings to reduce the dependencies. 2008-01-07 14:02:26 +00:00
rubidium
a8a3a7e3f2 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location. 2008-01-07 09:19:53 +00:00
rubidium
b0ac283aec (svn r11774) -Change: do not include variables.h in a header when it is not needed. 2008-01-07 00:57:19 +00:00
rubidium
64fc2ade9e (svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location. 2008-01-07 00:45:05 +00:00
glx
119b03ea70 (svn r11772) -Change: add some extra checking in the hope to find the cause of FS#1335 2008-01-07 00:43:03 +00:00
rubidium
acc7c9eb01 (svn r11771) -Codechange: split settings.h into better separated headers. 2008-01-07 00:19:09 +00:00
7be2160cfb (svn r11770) -Codechange: An engine type's type is EngineID, not byte. 2008-01-06 20:54:55 +00:00
miham
fd330ce743 (svn r11769) -Update: WebTranslator2 update to 2008-01-06 19:58:01
brazilian_portuguese - 2 fixed, 15 changed by fukumori (17)
bulgarian  - 29 fixed, 10 changed by groupsky (39)
croatian   - 13 fixed by knovak (13)
czech      - 2 fixed by Hadez (2)
dutch      - 1 fixed by habell (1)
estonian   - 1 fixed by kristjans (1)
french     - 1 fixed, 1 changed by glx (2)
galician   - 38 fixed by Condex (38)
italian    - 1 fixed by lorenzodv (1)
japanese   - 1 fixed by ickoonite (1)
norwegian_bokmal - 1 fixed by brygge_2 (1)
romanian   - 1 fixed by kneekoo (1)
slovak     - 1 fixed by lengyel (1)
swedish    - 2 fixed by daishan (2)
ukrainian  - 2 fixed by mad (2)
2008-01-06 18:58:55 +00:00
rubidium
aeff6e5761 (svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin. 2008-01-06 18:56:43 +00:00
smatz
f7a293f074 (svn r11767) -Fix: do not call rail specific functions when building road bridge
-Fix: missing space in terraform_gui.cpp
2008-01-06 11:39:40 +00:00
belugas
f9a592cfdd (svn r11766) -Codechange: Last fine tunings on smooth economy, by Sirkoz. 2008-01-06 01:06:12 +00:00
rubidium
279bfad275 (svn r11765) -Fix: compile warning (Roujin). 2008-01-05 22:34:04 +00:00
rubidium
f8f86420f8 (svn r11764) -Change: make the 'do characters exist in the current font file(s)' more robust. 2008-01-05 22:19:27 +00:00
smatz
e165aad4db (svn r11763) -Fix: update signal states after merging a company 2008-01-05 22:04:11 +00:00
glx
91be5d7531 (svn r11762) -Fix: compilation with DEBUG_DUMP_COMMANDS was broken 2008-01-05 21:42:34 +00:00
5d837282ee (svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there. 2008-01-05 15:39:22 +00:00
smatz
7302d8c88b (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
-Fix: adding road/tram to tram/road bridge was cheaper by one tile
2008-01-04 19:45:29 +00:00
9299f76af4 (svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin. 2008-01-04 18:18:46 +00:00
6a13067931 (svn r11758) -Fix(ette): Populate 'void' cargo slots (unused slots in temperate and arctic) with default data as per pre-newcargo support. These slots are still disabled by default, but some NewGRFs (erroneously?) expect the default data. 2008-01-04 17:25:53 +00:00
belugas
6b37ab36ea (svn r11757) -Fix(r11727): Don't use a function's default parameter when the value can be (more adequately, even better) computed from another source.
Thanks peter1138.
2008-01-04 15:39:08 +00:00
1cd2c3d517 (svn r11756) -Fix: Out of bounds access caused if a vehicle's cargo amount was higher than its capacity when resolving sprite groups. 2008-01-04 13:40:23 +00:00
3182cbb332 (svn r11755) -Fix: Debug level string buffer was not long enough to contain all debug levels. 2008-01-04 10:09:57 +00:00
belugas
23fab42b2f (svn r11754) -Fix(r11753): One too much command separator (;). Thanks glx for spotting 2008-01-04 03:31:08 +00:00
belugas
c59ea520a7 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
Hoping it makes the whole file easier to follow/read
2008-01-04 03:11:36 +00:00
belugas
b0ef12e0e9 (svn r11752) -Fix(r11745): Silence a MSVC warning (glx) 2008-01-04 03:04:19 +00:00
belugas
8f94ac8f03 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style 2008-01-04 02:32:58 +00:00
glx
72afdb8d34 (svn r11750) -Revert (r11749): commited too much 2008-01-03 23:54:23 +00:00
glx
42bddcf723 (svn r11749) -Fix (r11352): when a bankrupted company is bought, reset vehicle color mapping so the vehicles use the new owner color 2008-01-03 23:50:58 +00:00
belugas
aebcd80088 (svn r11748) -Codechange: Remove magic numbers introduced on r11746 and r11727
-Codechange: A few bad coding style inadvertendly applied too
2008-01-03 14:33:10 +00:00
belugas
7e4b7e3ad4 (svn r11747) -Change: Return of the prodigal son (or something). Little update (but highly noticed) on the OpenTTD Team 2008-01-03 14:04:08 +00:00
belugas
6ce70b17ca (svn r11746) -Fix(r11727): Make sure that action 0A does follow the same new ordering of shore sprites. It was not considered in the missing shore patch 2008-01-03 02:39:06 +00:00
skidd13
ade37de6c6 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware. 2008-01-02 23:59:11 +00:00
glx
6f7f4adffc (svn r11744) -Codechange: don't redefine snprintf when using MinGW Runtime 3.14 or superior, as it now have snprintf() and vsnprintf conform to C99 2008-01-02 18:42:51 +00:00
rubidium
19f8990f64 (svn r11743) -Fix [FS#1614]: group names got not deallocated in the command test run. 2008-01-01 22:39:11 +00:00
fa83291a76 (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused. 2008-01-01 22:34:00 +00:00
47082fec5c (svn r11741) -Feature: Add support for NewGRF's train 'tilt' flag. Trains with tilt capability (specific details are per NewGRF set) will be given a 20% speed limit bonus on curves. 2008-01-01 22:24:18 +00:00
egladil
9a2547b5a7 (svn r11740) -Fix [FS#1610]: Modify and possibly discard key events for code points in the unicode private use area. 2008-01-01 18:55:15 +00:00
c94a6b8c78 (svn r11739) -Fix [FS#1609]: Set the new scroll position after zooming in instead of before, as the zoom will cancel it out. 2008-01-01 18:35:31 +00:00
47d23eb003 (svn r11738) -Codechange: Refactor realistic acceleration's curve counting to use DirDiffs instead of local tables, and remove an unnecessary loop. 2008-01-01 18:12:17 +00:00
24784b7e0d (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window. 2008-01-01 17:01:06 +00:00
miham
f0e9c0cfc9 (svn r11736) -Update: WebTranslator2 update to 2008-01-01 17:42:54
catalan    - 1 fixed by arnaullv (1)
german     - 4 fixed by chu (4)
hungarian  - 23 fixed by miham (23)
romanian   - 17 fixed, 2 changed by kneekoo (19)
slovenian  - 1 fixed by Necrolyte (1)
2008-01-01 16:43:31 +00:00
aab495604a (svn r11735) -Fix [FS#1574]: Don't reset loading indicator IDs when only reloading NewGRFs. 2008-01-01 15:06:37 +00:00
belugas
3dd61f423a (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
-Fix[FS#1519]: When you can not use this resolution at full screen, now you'll know that it failed.
As for the reason it did not work, each computer/OS has its reason.
2008-01-01 14:20:48 +00:00
a8611311ac (svn r11733) -Fix: Max speed for entering stations overrode the max speed of curves 2008-01-01 14:15:28 +00:00
a967a7287f (svn r11732) -Fix (r4150): elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype. 2008-01-01 14:00:31 +00:00
7031358cff (svn r11731) -Fix [FS#1582]: Clear sprite override data before performing NewGRF wagon attach callback. This stopped
the callback working for autoreplace and when moving wagons from train to train in a depot.
-Fix (r11724): Don't check wagon attach callback for the chain when moving a single wagon.
2007-12-31 21:51:16 +00:00
miham
d8f4a80b0a (svn r11730) -Update: WebTranslator2 update to 2007-12-31 19:55:44
catalan    - 1 fixed by arnaullv (1)
dutch      - 1 fixed by webfreakz (1)
estonian   - 1 fixed by kristjans (1)
french     - 1 fixed by glx (1)
german     - 27 fixed by moewe2 (27)
hungarian  - 21 fixed by miham (21)
italian    - 1 fixed by lorenzodv (1)
japanese   - 1 fixed by ickoonite (1)
korean     - 1 fixed by leejaeuk5 (1)
norwegian_bokmal - 23 fixed by jhsoby (23)
polish     - 2 fixed by meush (2)
portuguese - 96 fixed, 7 changed by nars (103)
slovak     - 1 fixed by lengyel (1)
spanish    - 12 fixed by eusebio (12)
swedish    - 13 fixed by ChrillDeVille (13)
turkish    - 14 fixed by jnmbk (14)
2007-12-31 18:56:39 +00:00
75472cbc16 (svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations. 2007-12-31 11:13:51 +00:00
rubidium
b1be9f0137 (svn r11728) -Fix [FS#1577]: if there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available. 2007-12-31 07:14:25 +00:00
belugas
8ee1faca6c (svn r11726) -Feature[newGRF]: Extend the Action 5, feature 0D usage. Patch by BigBB 2007-12-31 04:38:11 +00:00
belugas
31e2ed8b4c (svn r11725) -Codechange: less a magical number 2007-12-31 02:39:50 +00:00
rubidium
1a70eed58c (svn r11724) -Fix: make it impossible (for users) to circumvent the length checking of the NewGRF 'allow wagon attach' callback by moving several wagons at a time. 2007-12-30 21:35:48 +00:00
skidd13
566a24d6ee (svn r11723) -Feature: add initial support for Intel C Compiler on linux
-Codechange: silence a few warnings of ICC
2007-12-30 19:32:09 +00:00
glx
892e231aad (svn r11722) -Fix (r11703): invalid plural form 2007-12-30 16:34:32 +00:00
rubidium
a3b19fd50c (svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games. 2007-12-29 23:49:48 +00:00
06d578d07e (svn r11720) -Codechange: [NewGRF] Add support for bit 30 of station tile layouts; forcing a sprite to always be opaque. 2007-12-29 21:06:54 +00:00
rubidium
e5e75bd8f8 (svn r11719) -Codechange: split sound.h in a header with types and one with functions. 2007-12-29 09:24:26 +00:00
egladil
6ae9302708 (svn r11718) -Fix [FS#1483]: Show the fullscreen modes available to the cocoa driver in windowed mode too. 2007-12-29 05:15:13 +00:00
smatz
108ab3b910 (svn r11717) -Fix [FS#1590]: make sure invalid players have all shares owned by PLAYER_SPECTATOR 2007-12-28 18:25:30 +00:00
glx
c87f20ff37 (svn r11716) -Fix [FS#1561]: don't put more than one Random() in function calls because parameter evaluation order is not guaranteed in the c++ standard (can lead to desyncs) 2007-12-28 16:21:29 +00:00
smatz
8e1f21e29b (svn r11715) -Fix: do not use GetTrackBits() for depots and waypoints while converting railtype 2007-12-28 15:27:12 +00:00
belugas
e9a039b845 (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
This will not (yet) be true if you are loading a scenario with the "-g" command line option.
2007-12-28 04:20:56 +00:00
belugas
5087a6cdd7 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition 2007-12-28 03:14:55 +00:00
maedhros
e2efaaff87 (svn r11712) -Fix (r9315): Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids. 2007-12-27 20:49:44 +00:00
belugas
e67ed0a808 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum 2007-12-27 17:29:27 +00:00
bjarni
6196fa01ab (svn r11710) -Feature: [build vehicles windows] added sorting for cost, running costs and speed to road vehicles and ships build windows 2007-12-27 15:47:08 +00:00
bjarni
2ecb31ae3f (svn r11709) -Fix [FS#1385 FS#1386]: [OSX] Compiles on Leopard with the default settings
-Change:                [OSX] configure will no longer enable static by default
   Turns out that Leopard can't handle static builds without the user installing extra libs
   The tradeoff is that now people might have to enable static manually if moving the binary around
2007-12-27 15:05:46 +00:00
egladil
6e1cae5256 (svn r11708) -Fix [FS#1598]: Removed include of variables.h as it was no longer needed and caused compilation to fail. 2007-12-27 14:45:10 +00:00
smatz
38f0e422ac (svn r11707) -Fix: do not allow refitting flooded (destroyed) vehicles 2007-12-27 14:10:47 +00:00
rubidium
384503e7d3 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes. 2007-12-27 13:35:39 +00:00
smatz
4e66f5a04b (svn r11705) -Fix [FS#1557]: trains could have sprites with wrong direction when reversing, also was inconsistent with save/load process (possible desyncs) 2007-12-27 13:25:23 +00:00
rubidium
0b1d3e43e5 (svn r11704) -Codechange: remove another bunch of useless includes. 2007-12-26 23:04:26 +00:00
miham
c124792fd2 (svn r11703) -Update: WebTranslator2 update to 2007-12-26 17:33:24
estonian   - 16 changed by kristjans (16)
polish     - 94 fixed, 6 changed by meush (100)
russian    - 22 fixed by Smoky555 (22)
spanish    - 11 fixed by eusebio (11)
traditional_chinese - 25 fixed, 4 changed by xbddc (29)
2007-12-26 16:38:34 +00:00
rubidium
b9046c97fb (svn r11702) -Codechange: move all date related stuff to date*. 2007-12-26 13:50:40 +00:00
rubidium
2786d789a1 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h). 2007-12-26 11:45:43 +00:00
rubidium
aac835171e (svn r11700) -Codechange: reduce the amount of unnecessary includes. 2007-12-25 23:42:52 +00:00
skidd13
6cb68b9144 (svn r11699) -Cleanup: Remove some headers from the project files which aren't there anymore 2007-12-25 18:25:25 +00:00
skidd13
59d6c5e157 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
-Change: Make the highscore button in the difficulty window a bit more obvious
-Codechange: Enumify the window-widgets of the difficulty window
2007-12-25 15:56:41 +00:00
rubidium
0bd93f5c37 (svn r11697) -Fix [FS#1585]: strgen did not (always) compile properly. 2007-12-25 14:08:56 +00:00
rubidium
87bd412885 (svn r11696) -Fix: remove BUGS as that is not about any real bugs, but rather things noted in the development of the new bridges/elrail. 2007-12-25 14:03:06 +00:00
skidd13
7963963d98 (svn r11695) -Codechange: Converted the md5 algorithm to OOP
-Codechange: Adapt the md5 algorithm to the OpenTTD source
2007-12-25 13:59:21 +00:00
rubidium
b3f6c0734b (svn r11694) -Codechange: move more endianness related stuff to endian_func.hpp. 2007-12-25 13:28:09 +00:00
rubidium
429521a7d1 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h' 2007-12-25 11:26:07 +00:00
rubidium
bf98e25e43 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed. 2007-12-25 09:48:53 +00:00
egladil
e2f79f0eb5 (svn r11690) -Fix: Since indices into the patch array is sent over the network having conditionally compiled entries in the table can cause desyncs. Moving them to the end will hide this issue, but it should really be solved in a better way. 2007-12-25 01:29:54 +00:00
smatz
17d1b522bc (svn r11689) -Fix: compilation error and most of warnings for gcc 4.3 2007-12-23 21:02:40 +00:00
egladil
22f79df328 (svn r11688) -Fix [FS#1581]: Compilation was broken on OS X again. 2007-12-23 18:08:39 +00:00
skidd13
da5d3a7b3b (svn r11687) -Codechange: move some defines to a better place 2007-12-23 14:06:03 +00:00
glx
451abbecb1 (svn r11686) -Fix (r11684): win32 compilation was broken again :) 2007-12-23 13:31:24 +00:00
rubidium
970fd6220a (svn r11685) -Codechange: remove a few 'useless' includes. 2007-12-23 11:20:41 +00:00
rubidium
a773d45885 (svn r11684) -Codechange: split gfx.h in a type and functional header. 2007-12-23 10:56:02 +00:00
belugas
82d240e300 (svn r11683) -Fix(r11682): win32.cpp still requires gfx.h inclusion, at least for now. 2007-12-23 04:31:45 +00:00
rubidium
8f0e68285b (svn r11682) -Codechange: move some 'generic' geometry related types into a single file and do not include gfx.h everywhere to get a Point type. 2007-12-22 23:30:28 +00:00
rubidium
a7d54cf946 (svn r11681) -Fix (r11674): hopefully fix the compile error on big endian machines. 2007-12-22 21:01:49 +00:00
rubidium
6a9e77e079 (svn r11680) -Codechange: refactor more out of openttd.h and functions.h. 2007-12-21 22:50:51 +00:00
glx
1b53dbf9cc (svn r11679) -Add: [newgrf] support for station vars 67 and 68 2007-12-21 22:11:55 +00:00
bjarni
18e96ab49f (svn r11678) -Fix (r11674): [OSX] fixed compilation 2007-12-21 22:08:59 +00:00
rubidium
9e9cfe6e59 (svn r11677) -Codechange: move price and command related types/functions to their respective places. 2007-12-21 21:50:46 +00:00
glx
65754b8d12 (svn r11676) -Fix (r11674): some references to macros.h were left 2007-12-21 21:16:14 +00:00
rubidium
433a9f3c09 (svn r11675) -Codechange: split the string types from the string functions. 2007-12-21 19:49:27 +00:00
rubidium
01e20c9140 (svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations. 2007-12-21 19:21:21 +00:00
rubidium
d5c4ba8246 (svn r11673) -Codechange: move the overflow safe type to a separate file. 2007-12-21 08:34:53 +00:00
rubidium
a6b1526c13 (svn r11672) -Codechange: refactor some stuff out of gui.h. 2007-12-21 07:38:36 +00:00
smatz
30c0d6da99 (svn r11671) -Fix: sometimes a vehicle was selected in the vehicle list when it was opened 2007-12-20 22:45:56 +00:00
smatz
4a80cf8482 (svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too 2007-12-19 23:35:14 +00:00
rubidium
5b49e75453 (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h 2007-12-19 23:26:02 +00:00
rubidium
d582aea639 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found. 2007-12-19 20:45:46 +00:00
rubidium
8896bea306 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps. 2007-12-19 19:44:29 +00:00
glx
a9dafdff48 (svn r11666) -Fix (r11504): when removing buoys, return to water or canal depending on their owner 2007-12-19 02:41:25 +00:00
belugas
b8196d36e7 (svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
Fix directly inspired by Csaboka
2007-12-18 21:25:44 +00:00
rubidium
7db6c7db38 (svn r11664) -Codechange: use more specific ("rail_type.h" instead of "rail.h" that includes way more than only "rail_type.h") includes at some places. 2007-12-18 20:58:12 +00:00
rubidium
e4ef359f47 (svn r11663) -Codechange: moving of the road related types and functions. 2007-12-18 20:38:16 +00:00
rubidium
df0c6eb2b9 (svn r11662) -Codechange: move some rail types/related functions around. 2007-12-18 20:10:21 +00:00
rubidium
f56a354d31 (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies. 2007-12-18 19:52:14 +00:00
miham
5dc1fcea04 (svn r11660) -Change: english -> english (uk), english_us ->english (us) 2007-12-18 18:08:51 +00:00
smatz
c26a265f21 (svn r11659) -Fix [FS#1563]: do not allow modifying non-uniform stations when non-uniform stations are disabled 2007-12-18 18:02:00 +00:00
glx
805ac40280 (svn r11658) -Fix (r11654): forgot project files 2007-12-17 23:30:25 +00:00
smatz
0b08f7370d (svn r11657) -Fix: show better error message when trying to convert rail
-Codechange: merge DoConvert functions into one, make test and exec runs the same for tunnels/bridges
2007-12-17 22:29:27 +00:00
smatz
bda9d4a236 (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations 2007-12-17 22:04:07 +00:00
miham
61dcdbf0e0 (svn r11655) -Update: WebTranslator2 update to 2007-12-17 20:16:03
danish     - 22 fixed by ThomasA (22)
estonian   - 18 fixed, 47 changed by kristjans (65)
italian    - 4 changed by lorenzodv (4)
norwegian_nynorsk - 20 fixed by pollux (20)
2007-12-17 19:16:53 +00:00
miham
6f526fd2e1 (svn r11654) -Change: renaming american languagefile to english_US 2007-12-17 18:49:51 +00:00
egladil
2885c66060 (svn r11653) -Feature: [OSX] Allow windowed mode subdrivers to be disabled at compile time. 2007-12-17 07:47:21 +00:00
smatz
93c3e0d6ad (svn r11652) -Codechange: add the svn $ header for several files 2007-12-17 01:35:45 +00:00
rubidium
9ecda0a97a (svn r11651) -Codechange [FS#1555]: implement GRF parameter querying for industries and fix a 'bug' as side effect. 2007-12-16 23:10:30 +00:00
rubidium
85b52f6a64 (svn r11650) -Fix: 'initialised' NewGRFs could still be deactivated in the later 'activation' pass. 2007-12-16 22:21:34 +00:00
smatz
145517fb8e (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642 2007-12-16 19:30:42 +00:00
rubidium
0730b9afc1 (svn r11648) -Fix [FS#1560]: the company password was not set when one pressed the enter key. 2007-12-16 19:28:07 +00:00
rubidium
3bba097bb3 (svn r11647) -Fix (r11646): it did not compile without freetype... 2007-12-16 19:21:28 +00:00
rubidium
ff7ff890f9 (svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen. 2007-12-16 18:38:19 +00:00
glx
5e062d3f15 (svn r11645) -Fix (r8128): station ground tiles may have transparency or company colour 2007-12-16 17:50:09 +00:00
smatz
3cee0abdba (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h 2007-12-16 15:38:51 +00:00
rubidium
ec90ce7e98 (svn r11643) -Codechange: conform with the coding style for the WP macro uses. 2007-12-16 10:54:08 +00:00
smatz
acf6e08f78 (svn r11642) -Codechange: VehicleFromPos does check for v->tile == tile, so remove useless checks 2007-12-15 23:11:18 +00:00
rubidium
cbcfcb3bf4 (svn r11641) -Add: configure time parameter to enable some desync debugging functionality. 2007-12-15 22:42:12 +00:00
rubidium
214d25905a (svn r11640) -Fix: missed change of include when moving stuff to random_func.cpp 2007-12-15 22:05:02 +00:00
smatz
701e9d27fc (svn r11639) -Codechange: simplify EnsureNoVehicleOnGround 2007-12-15 20:30:43 +00:00
smatz
d0ad7688f2 (svn r11638) -Codechange: use faster check in SignalVehicleCheck for tunnel/bridge 2007-12-15 19:46:34 +00:00
smatz
4b22e57b33 (svn r11637) -Fix: mark viewports dirty when removing visible vehicle chain 2007-12-15 16:11:29 +00:00
smatz
46724104fe (svn r11636) -Fix: it was possible to build/remove road/tram in tunnel/bridge when there was vehicle in it 2007-12-15 13:59:38 +00:00
belugas
828c242291 (svn r11635) -Codechange: Give a more informative debug message when encountering unknown newgrf feature in action 00 handling.(FS#1551, Bilbo) 2007-12-15 03:42:41 +00:00
smatz
5992187a85 (svn r11634) -Fix: update signals when deleting crashed train on a bridge, update even when train is rotated 2007-12-15 00:04:01 +00:00
smatz
4b7f8f04a3 (svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge 2007-12-14 23:21:20 +00:00
rubidium
dedb15786c (svn r11632) -Fix [FS#1541]: vehicles were still followed when sold. 2007-12-14 21:11:30 +00:00
glx
ea1ae563c7 (svn r11631) -Fix (r11585, r11626): remove MSVC warnings 2007-12-14 00:25:00 +00:00
rubidium
2921e7482b (svn r11630) -Fix [FS#1544] (r11556): the chat GUI got broken. 2007-12-13 23:26:00 +00:00
rubidium
a0f2366e40 (svn r11629) -Fix [FS#1527]: many viewports could crash the scenario editor. 2007-12-13 18:46:04 +00:00
miham
98d18c5337 (svn r11628) -Update: WebTranslator2 update to 2007-12-13 09:47:23
american   - 30 fixed by WhiteRabbit (30)
brazilian_portuguese - 22 fixed by fukumori (9), tucalipe (13)
bulgarian  - 8 fixed by thetitan (8)
catalan    - 22 fixed by arnaullv (22)
croatian   - 17 fixed by knovak (17)
czech      - 22 fixed by Hadez (22)
danish     - 1 fixed, 4 changed by Bjarni (5)
dutch      - 22 fixed by habell (22)
estonian   - 10 fixed by kristjans (10)
french     - 7 fixed, 2 changed by glx (9)
italian    - 7 fixed, 2 changed by lorenzodv (9)
japanese   - 23 fixed by ickoonite (23)
korean     - 33 fixed, 7 changed by leejaeuk5 (40)
norwegian_nynorsk - 9 fixed by pollux (9)
romanian   - 13 fixed, 3 changed by CrystyB (16)
slovak     - 22 fixed by lengyel (22)
slovenian  - 22 fixed by Necrolyte (22)
swedish    - 10 fixed by daishan (10)
turkish    - 20 fixed by jnmbk (20)
ukrainian  - 22 fixed by mad (22)
2007-12-13 08:53:09 +00:00
glx
1a8afc5fb4 (svn r11627) -Fix [FS#1532] (r11145): poping from text reference stack must be done in a precise order. But some compiler (MSVC) over optimised it and inverted this order. 2007-12-13 02:04:09 +00:00
skidd13
1d9c27e235 (svn r11626) -Fix [FS#1529]: Pause state wasn't set correctly in multiplayer saves 2007-12-12 21:56:10 +00:00
smatz
5acc147c1c (svn r11625) -Codechange: add CO_* enum at some places, add includes of order.h too 2007-12-12 14:37:35 +00:00
belugas
e0646af976 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up. 2007-12-12 02:28:08 +00:00
smatz
ed54703db8 (svn r11623) -Fix [FS#1533] (r11619): assert when train is going over two crossings next to each other 2007-12-11 22:50:13 +00:00
rubidium
78ae599790 (svn r11622) -Codechange: support the unicode version of the 'control' characters. 2007-12-11 21:25:48 +00:00
rubidium
a5bcce4fc8 (svn r11621) -Fix [FS#1525]: there were still some cases where one could not build a tram track, but the tram could become blocked. 2007-12-11 20:28:53 +00:00
belugas
a85c832919 (svn r11620) -Change: Some are going, some are coming, some we do not know exactly. Little update on the OpenTTD Team 2007-12-11 19:59:53 +00:00
smatz
359c9aea3f (svn r11619) -Fix [FS#1531]: do not make crossing red behind depot the train is entering 2007-12-11 19:09:36 +00:00
glx
fb1d768924 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them 2007-12-11 17:44:55 +00:00
belugas
6f73382317 (svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo) 2007-12-11 03:41:33 +00:00
rubidium
a1dbb10c26 (svn r11616) -Fix [FS#1526]: sometimes large values could go off the chart. 2007-12-10 22:26:24 +00:00
glx
ac7c79f039 (svn r11615) -Fix (r11609): temperate banks can only be built in towns (over a house) 2007-12-10 17:26:49 +00:00
skidd13
9124331b0d (svn r11614) -Fix: The about dialog scrolling was connected to the mouse instead of the internal ticks 2007-12-09 22:14:41 +00:00
rubidium
f854b129af (svn r11612) -Change: update some documentation. 2007-12-09 21:23:20 +00:00
glx
6a83f9141b (svn r11611) -Codechange: it is now possible to use a define to enable asserts and show them in crash.log for MSVC release builds 2007-12-09 21:20:21 +00:00
glx
46c0edc80b (svn r11610) -Cleanup (r8572): remove orphan comment 2007-12-09 20:20:52 +00:00
rubidium
6aaa72c918 (svn r11609) -Fix [FS#1524]: wrong error messages were shown when trying to build some industries in the scenario editor. 2007-12-09 18:51:25 +00:00
rubidium
c3ea7e4dc4 (svn r11608) -Fix: do not trigger industries, but only the industry's tiles. 2007-12-09 18:27:40 +00:00
skidd13
f20e414e2e (svn r11607) -Codechange: Enumify the industry widgets
-Feature: Enable doubleclick in the found new industries window to build an industries
2007-12-09 17:07:50 +00:00
rubidium
079c0fd66a (svn r11606) -Revert (r11584): since FS#1482 is solved, we do not need the extra checking and such anymore. 2007-12-09 15:17:49 +00:00
rubidium
5dc0e86d1b (svn r11605) -Fix [FS#1482, FS#1523]: wrong count of Kirby trains when a ship was build. 2007-12-09 15:15:26 +00:00
smatz
5cd0013e5c (svn r11604) -Fix: canal tiles were not marked dirty when surrounding tile got flooded, causing glitches 2007-12-08 21:57:24 +00:00
smatz
dfba33819b (svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic 2007-12-08 19:53:30 +00:00
bjarni
58b4a981e1 (svn r11602) -Change: [OSX] changed default PPC SDK to 10.4 (from 10.3) when building universal binaries
10.5 support needs this and it will not break 10.3 support
2007-12-08 18:53:49 +00:00
smatz
2a62aa1ccd (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change) 2007-12-08 18:50:39 +00:00
glx
b47bce651e (svn r11600) -Cleanup: remove extra out-of-memory checks, since it's now done in *allocT functions. 2007-12-08 15:47:23 +00:00
bjarni
2256d9d378 (svn r11599) -Change: [OSX] 10.4 will now use quickdraw for window mode instead of quartz
The reason is that quickdraw is way faster (try fast forward)
  10.5 will still use quartz as it can't handle quickdraw.
2007-12-08 15:21:37 +00:00
rubidium
625a4f8e9a (svn r11598) -Change [FS#1518]: some tooltips of the main toolbar did not 'enumerate' all options in a drop down menu. 2007-12-08 14:54:43 +00:00
rubidium
f1e4914b5f (svn r11597) -Change: replace all remaining instances of (re|m|c)alloc with (Re|M|C)allocT and add a check for out-of-memory situations to the *allocT functions. 2007-12-08 14:50:41 +00:00
belugas
73c58d8a40 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function 2007-12-08 03:10:50 +00:00
belugas
b23f824f18 (svn r11595) -Codechange: add a new member to Window struct, based on its function counterpart HandleButtonClick. 2007-12-08 02:55:47 +00:00
glx
04f0700357 (svn r11594) -Fix: don't allow changing network only patches settings from console when not in network game 2007-12-08 01:36:40 +00:00
belugas
af4d07b978 (svn r11593) -Cleanup: remove some forgotten pieces of evidence of a mischief 2007-12-08 01:30:18 +00:00
belugas
8c89641dbe (svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function 2007-12-08 01:20:47 +00:00
belugas
6fb71047d6 (svn r11591) -Codechange: remove now unused widget accessors. 2007-12-08 01:02:19 +00:00
glx
8aaa4e7da6 (svn r11590) -Fix (r11193): IsSlopeRefused() result was half wrong 2007-12-07 21:16:38 +00:00
rubidium
cbb2d39860 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals. 2007-12-07 21:14:54 +00:00
glx
c21f588a14 (svn r11588) -Codechange: use the new member introduced in r11551 2007-12-07 18:05:49 +00:00
skidd13
98bd772119 (svn r11587) -Fix (r11457): The one way road button wasn't reset on abort 2007-12-07 17:51:27 +00:00
glx
10e17c30a3 (svn r11586) -Fix: make another widget 'accessor' function const when it should be const. 2007-12-07 17:42:15 +00:00
skidd13
7159007a35 (svn r11585) -Codechange: Enumify the widgets of the newGRF gui and a slight cleanup there 2007-12-07 12:22:34 +00:00
rubidium
42dbdbb7f9 (svn r11584) -Change: add some extra checking in the hope to find the cause of FS#1482. 2007-12-06 22:29:47 +00:00
rubidium
dd68a34e26 (svn r11583) -Fix [FS#1484]: windows could get completely missing when one resized the window to something very small. 2007-12-06 20:55:48 +00:00
smatz
720854ed16 (svn r11582) -Fix: tiles were not marked dirty in some cases when removing a lock 2007-12-06 20:48:15 +00:00
rubidium
3d38b2c8ba (svn r11581) -Codechange: add some missing cargo classes and some documentation. 2007-12-06 20:36:46 +00:00
skidd13
2c3c6593d4 (svn r11580) -Feature: Memorise the resizing of the build bridge selection window during runtime 2007-12-06 18:29:31 +00:00
belugas
6c70cf2d82 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
A better solution will be deviced, but not now.  Let's not cause a ton of bug reports
2007-12-06 15:58:39 +00:00
belugas
7edf28529d (svn r11578) -Codechange: Introduce the window default flag WDF_TEXTENTRY which specifies that the window holding it is actually one that enables an edit box.
Use this flag when dispatching a key event instead of using some hard coded window IDs.
This should ease a little bit the creation of new edit aware windows.
2007-12-06 02:31:47 +00:00
smatz
49d632c31b (svn r11577) -Fix: invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed 2007-12-05 19:13:42 +00:00
smatz
eda5921284 (svn r11576) -Codechange: enumerize and comment station GUI 2007-12-05 17:08:10 +00:00
smatz
079482f0a2 (svn r11575) -Fix [FS#1502]: widget numbers of StationViewWindow were incorrect at some places 2007-12-05 16:55:33 +00:00
smatz
c65c14f06b (svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF) 2007-12-05 00:16:20 +00:00
rubidium
8c5c0e9367 (svn r11573) -Codechange: pause games that miss GRFs by default and throw some warnings and disclaimers when you want to unpause it. 2007-12-04 22:50:07 +00:00
glx
46441ac31c (svn r11572) -Fix [FS#1494]: reinitialise windows system before loading a savegame 2007-12-04 22:22:50 +00:00
rubidium
02c46026b3 (svn r11571) -Fix [FS#1493]: road vehicle getting to the wrong side of a station when trying to overtake in there. 2007-12-04 21:53:09 +00:00
smatz
ddc8f2d16f (svn r11570) -Fix: do not flood rail station tiles when there is a vehicle on it (when non-uniform stations are ON) 2007-12-04 21:39:03 +00:00
rubidium
5f576e12aa (svn r11569) -Fix [FS#1480]: full paths sometimes did not work correctly. 2007-12-04 18:42:08 +00:00
belugas
5847abc9f8 (svn r11568) -Codechange: Use bit shifts instead of values for flags. It helps readability a little bit. 2007-12-04 17:51:50 +00:00
glx
0f43982c72 (svn r11567) -Fix [FS#1512] (r11011): break the chain before moving a vehicle after another in the same chain 2007-12-04 15:32:54 +00:00
smatz
05fca79cf0 (svn r11565) -Revert: part of r11564 2007-12-03 22:40:18 +00:00
skidd13
82913a2134 (svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style 2007-12-03 09:19:19 +00:00
skidd13
1a43c6a6f6 (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs 2007-12-02 21:43:16 +00:00
rubidium
fe76841255 (svn r11562) -Fix [FS#1503] (r11546): aircraft sometimes stopped mid-air when the airport got destroyed. 2007-12-02 21:35:44 +00:00
glx
164d0a4710 (svn r11561) -Fix [FS#1504] (r11463): group list was not updated when removing the last group 2007-12-02 20:13:12 +00:00
rubidium
b7d8681129 (svn r11560) -Codechange: replace 'custom' version of FindLastBit with the generic. 2007-12-02 19:23:46 +00:00
rubidium
faf096f506 (svn r11559) -Fix [FS#1505]: overflow when drawing graphics with high company values. 2007-12-02 19:21:56 +00:00
rubidium
b5a902703e (svn r11557) -Codechange: send and store the passwords a little more secure to/in the servers.
Each server and game yield a (usually) different 'salt'. This salt is used by the clients to hash their passwords. This way the passwords are not sent in clear text and it is not trivial to use those hashes on other servers.
NOTE: It is still NOT safe to use your trusted passwords and it will not stop people from being able to 'hijack' your password, it only makes it harder to do and certainly much less trivial than just dumping passwords from the memory.
2007-12-02 15:12:19 +00:00
rubidium
d9081ad3f5 (svn r11556) -Feature: allow setting a default password for new companies in network games. 2007-12-02 14:48:26 +00:00
rubidium
527b72749d (svn r11555) -Codechange: use the new members introduced in r11551. 2007-12-02 14:29:48 +00:00
rubidium
50fced3c66 (svn r11554) -Codechange: be more consistent with the naming of the widget functions. 2007-12-02 13:32:41 +00:00
rubidium
b20b2f4ec8 (svn r11553) -Fix: make a few widget 'accessor' function const when they should be const. 2007-12-02 12:10:48 +00:00
miham
4e574cab45 (svn r11552) -Update: WebTranslator2 update to 2007-12-02 12:31:46
czech      - 1 fixed by Hadez (1)
french     - 15 fixed by glx (15)
galician   - 2 fixed by Condex (2)
italian    - 15 fixed by lorenzodv (15)
norwegian_bokmal - 6 fixed by jhsoby (6)
russian    - 7 fixed by Smoky555 (7)
slovenian  - 1 fixed by Necrolyte (1)
spanish    - 1 fixed by eusebio (1)
2007-12-02 11:32:24 +00:00
belugas
e2b4afaa4b (svn r11551) -Codechange: Introduction of widget control members on struct Window. These "new" members have the exact same functionalities as their pure functions "genitors"
Ex: "Window::SetWidgetLoweredState(byte widget_index, bool lowered_stat)"  is the member corresponding to "SetWindowWidgetLoweredState(Window *w, byte widget_index, bool lowered_stat)"
2007-12-02 00:59:48 +00:00
skidd13
7be55559b8 (svn r11550) -Fix (r11547): Updated the data files regarding to r11549 2007-12-02 00:53:01 +00:00
rubidium
08ab4e1850 (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB. 2007-12-01 21:40:18 +00:00
belugas
0feaee4124 (svn r11546) -Fix[FS#1496]: If ever the air/heli port is suddenly not available while the "chopper" is descending, just go back into flying.
The code should have been better written, but in respect of newgrf_port branch, i prefer minimalist intervention
2007-12-01 14:04:16 +00:00
belugas
4f030bbfff (svn r11545) -Revert(r11543): The result is not what was expected. Looks like more work might be needed 2007-12-01 02:59:22 +00:00
glx
da9f06252b (svn r11544) -Fix [FS#1501]: revert r11453 as it translated cargo when it should not 2007-12-01 02:47:10 +00:00
belugas
aa0d37854d (svn r11543) -Codechange: Give a more adequate message when trying to place an industry required to be built over a house on any other type of tiles.
In reference to FS#1492, and other "bugs" like that one
2007-12-01 01:31:05 +00:00
bjarni
6b68c6557b (svn r11542) -Fix r11540: [OSX] presumed 10.3 style strings when using GetCurrentLocale nomatter what OSX the target was 2007-11-30 14:49:13 +00:00
bjarni
7162b8ddb3 (svn r11541) -Fix: [OSX] detect statvfs at runtime (based on OSX version) instead of compile time
This should prevent a crash on OSX 10.3 with the precompiled binaries (in the load/save windows)
2007-11-30 14:42:16 +00:00
bjarni
5fcbb8f59b (svn r11540) -Fix: [OSX] Don't try to compile the quartz video driver on OSX 10.3. It will fail 2007-11-30 13:26:24 +00:00
skidd13
4704d4619b (svn r11539) -Feature: Make the bridge selection window resizable 2007-11-29 18:27:39 +00:00
skidd13
6e511188ae (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation 2007-11-28 21:59:06 +00:00
rubidium
981865dbcc (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations. 2007-11-28 15:42:52 +00:00
belugas
440608a6f0 (svn r11536) -Codechange: Align some elements of the _tree_layout_sprite table a little better looking for the eye 2007-11-28 00:41:20 +00:00
miham
34edc93f2a (svn r11535) -Update: WebTranslator2 update to 2007-11-27 20:21:42
ukrainian  - 1 fixed by mad (1)
2007-11-27 19:22:08 +00:00
belugas
b10eea628d (svn r11534) -Feature(newgrf): Implement property 23h for Industries.
This will add a cost to the removal of an industry using the cheat magic bulldozer.
Note that the removal of regular or newgrf industries without specified removal cost will have no cost applied to.
This is a difference from original spec, where a default base cost is added.
2007-11-27 17:13:49 +00:00
belugas
1682d5d679 (svn r11533) -Codechange: Rename some unclear clear_x prices member names.
While at it, remove one unused entry on the clear_price_table array.
It is based on ground type, and the unused one was referencing a non existing one.
2007-11-27 16:02:13 +00:00
belugas
9402d4054a (svn r11532) -Feature[newgrf]: Add decrement(0x0D) / increment(0x0E) production operations from result of production callback cb29/35.
Only var 0x93 will be affected by these operations
2007-11-27 04:16:08 +00:00
rubidium
8c5814156f (svn r11531) -Fix [FS#1459]: version determination did stall (read: never finish) when both svn and git were not installed. 2007-11-26 23:28:29 +00:00
smatz
6f7d37d3d3 (svn r11530) -Codechange: do not update Tpool->first_free_index for PoolItems allocated on stack 2007-11-26 22:56:30 +00:00
miham
a7d4334664 (svn r11529) -Update: WebTranslator2 update to 2007-11-26 21:13:37
brazilian_portuguese - 1 fixed by fukumori (1)
catalan    - 1 fixed, 2 changed by arnaullv (3)
dutch      - 1 fixed by habell (1)
french     - 1 fixed, 1 changed by glx (2)
italian    - 1 fixed by lorenzodv (1)
lithuanian - 4 fixed by Domas (4)
slovak     - 1 fixed, 1 changed by lengyel (2)
ukrainian  - 5 fixed by mad (5)
2007-11-26 20:14:20 +00:00
maedhros
8e273e0f88 (svn r11528) -Fix (r11500): With smooth economy enabled, industries that should only decrease production would always increase it when more than 60% was transported. 2007-11-26 19:23:53 +00:00
skidd13
71c10f7df7 (svn r11527) -Codechange: Split the bitmath functions of to their own files 2007-11-26 17:50:22 +00:00
skidd13
734b22e070 (svn r11526) -Codechange: Rename the function delta fitting to the naming style 2007-11-26 16:01:29 +00:00
rubidium
d736a04b59 (svn r11525) -Fix: do not do all kinds of 'updates' for town, waypoint, station and other signs when you haven't converted the map to the 'current' format as that means you are going to read data in the 'old' format when you assume that it is in the 'current' format. 2007-11-25 20:20:16 +00:00
rubidium
77b6a2674e (svn r11524) -Fix [FS#1485]: assertion when tram reversed at a station. 2007-11-25 19:45:09 +00:00
skidd13
bdc7fd2d76 (svn r11523) -Codechange: Move the CHANCE macros to core/random_func.cpp cause they depend on Random()
-Codechange: Convert the CHANCE macros to functions and rename them fitting to the naming style
2007-11-25 15:35:25 +00:00
skidd13
2bf2be987d (svn r11522) -Fix: The scrollbar of the network gui could run out of bounds 2007-11-25 15:17:16 +00:00
egladil
1d5010edf9 (svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way. 2007-11-25 14:43:16 +00:00
egladil
9aaa455e5d (svn r11520) -Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling. Thanks ln- for pointing this out and providing a fix. 2007-11-25 12:58:32 +00:00
smatz
d061d985d6 (svn r11519) -Codechange: enumerization and cleanup of NetworkLobbyWindow in network_gui.cpp 2007-11-25 11:36:45 +00:00
smatz
2cd25ed2ca (svn r11518) -Codechange: enforce (by assert) unused parameters of widgets to be zero. Better readability of DrawWindowWidgets(), too 2007-11-25 00:41:31 +00:00
smatz
72eb6ae278 (svn r11517) -Codechange: better cleanup of NetworkStartServerWindow in network_gui.cpp 2007-11-24 21:49:49 +00:00
smatz
a62e07b08e (svn r11516) -Codechange: cleanup of NetworkGameWindow in network_gui.cpp 2007-11-24 21:41:59 +00:00
smatz
5dfead8b5c (svn r11515) -Codechange: cleanup of NetworkStartServerWindow in network_gui.cpp 2007-11-24 18:09:02 +00:00
rubidium
bd8bf99139 (svn r11514) -Change: implement the automatic multiplier handler for NewGRF industries. 2007-11-24 14:03:47 +00:00
smatz
cbd1c05218 (svn r11513) -Codechange: enumerize some depot GUI actions 2007-11-24 13:50:29 +00:00
rubidium
6cf5e4cf05 (svn r11512) -Change: make the subsidy window able to resize to something smaller than 640x127 (especially the 640 part) when the screen is really too small. 2007-11-24 13:00:32 +00:00
rubidium
f27acfdf78 (svn r11511) -Revert parts of r11505: forgot that CTRL might be used for other features, like adjacent stations or signals. 2007-11-24 12:36:52 +00:00
skidd13
bf959f926f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style 2007-11-24 10:38:43 +00:00
rubidium
64246a2775 (svn r11509) -Fix: off-by-one error in some sprite numbers; increase sprite number counter before loading the next sprite instead of after doing so. 2007-11-24 10:19:56 +00:00
egladil
fcbfba1e17 (svn r11508) -Cleanup: Removed unused headers from the cocoa video driver. 2007-11-24 09:55:17 +00:00
rubidium
221e9271c5 (svn r11507) -Fix [FS#1463]: signs totally illegible when transparant signs is turned on and zoomed out more than one level. 2007-11-24 09:27:20 +00:00
rubidium
9a70ec1cb2 (svn r11506) -Fix [FS#1471]: selling vehicles could cause the window of others to scroll to that location. 2007-11-24 09:14:58 +00:00
rubidium
81c7ba42af (svn r11505) -Fix/Feature: make CTRL work on all road/rail construction options that 'work' with the 'Bulldozer' button instead of only a few. 2007-11-24 08:56:29 +00:00
rubidium
ea072322fa (svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build. 2007-11-24 08:45:04 +00:00
glx
c8add52504 (svn r11502) -Fix (r11144): don't do standard production change if callbacks 29/35 failed
-Fix (r11144): disable smooth economy for industries using callbacks 29/35
2007-11-23 16:50:54 +00:00
egladil
2e0dd78ccf (svn r11501) -Fix: [OSX] This remedies a problem with right click scrolling that was introduced in r11492. 2007-11-23 13:45:59 +00:00
belugas
536be43411 (svn r11500) -Codechange: Smooth economy fine-tuning, making industries more responsive. Patch by Sirkoz. 2007-11-23 12:12:07 +00:00
glx
ee81e00082 (svn r11499) -Fix (r11144): mul/div factor were wrong (off by two) 2007-11-23 04:17:41 +00:00
egladil
2ebf50e421 (svn r11498) -Add [FS#1411]: [OSX] Added support for using Quartz instead of Quickdraw in windowed mode on OS X 10.4 and higher. Based on a patch by blackis. 2007-11-23 02:44:05 +00:00
rubidium
9d3cc5b271 (svn r11495) -Fix (r11493): some compilers fail to show warnings when they should. 2007-11-22 22:54:49 +00:00
glx
b979995795 (svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;) 2007-11-22 22:37:06 +00:00
rubidium
64a4ac3444 (svn r11493) -Fix [FS#1472]: game crashing on savegame load because it tried to render some part of the window before the savegame conversion was done. 2007-11-22 22:34:30 +00:00
egladil
3ad488e98f (svn r11492) -Codechange: [OSX] Split the cocoa video driver into several files. The reason for this is that the fullscreen and windowed mode api are separate from each other in OS X and thus the driver actual is two drivers in one. This split is to make the code more readable and to prepare for replacing the Quickdraw windowed mode code which uses apis deprecated as of OS X 10.5 (and maybe earlier). 2007-11-22 21:48:17 +00:00
miham
2653d94bcb (svn r11491) -Update: WebTranslator2 update to 2007-11-22 20:55:02
brazilian_portuguese - 5 fixed by tucalipe (5)
catalan    - 5 fixed by arnaullv (5)
czech      - 5 fixed by Hadez (5)
danish     - 6 fixed, 3 changed by MiR (9)
dutch      - 5 fixed by habell (5)
french     - 5 fixed by glx (5)
italian    - 2 fixed by lorenzodv (2)
japanese   - 5 fixed by ickoonite (5)
korean     - 58 fixed by leejaeuk5 (58)
slovak     - 5 fixed, 86 changed by lengyel (91)
slovenian  - 5 fixed by Necrolyte (5)
spanish    - 5 fixed by eusebio (5)
swedish    - 5 fixed by daishan (5)
turkish    - 5 fixed by jnmbk (5)
2007-11-22 19:55:54 +00:00
skidd13
737aec4db6 (svn r11490) -Codechange: Split the math functions to their own header
-Codechange: Replace the rest of the math macros with functions
2007-11-22 18:01:51 +00:00
skidd13
1d56af1d33 (svn r11489) -Fix r11488: Somehow the code was added multiple times 2007-11-21 19:18:34 +00:00
skidd13
83601671c7 (svn r11488) -Codechange: Spilt the random functions out to seperate file
-Codechange: Make the mersenne twister more readable
-Codechange: Unify the seeding process of random
2007-11-21 19:13:38 +00:00
smatz
d53bfd8f2f (svn r11487) -Fix (r11435): move the list of vehicles a bit higher in the player GUI 2007-11-21 13:50:36 +00:00
glx
b168ae34be (svn r11486) -Fix [FS#1457]: industry count was wrong in smallmap 2007-11-21 13:46:29 +00:00
skidd13
a91c2a4c39 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style 2007-11-20 14:11:19 +00:00
skidd13
eeaa348f8b (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style 2007-11-20 13:35:54 +00:00
skidd13
b8885630aa (svn r11483) -Codechange: Replace codeparts with functions that do the same to increase readability 2007-11-20 12:57:24 +00:00
skidd13
5c31a973a1 (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style 2007-11-19 21:32:20 +00:00
skidd13
71c4325c50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style 2007-11-19 21:02:30 +00:00
skidd13
58bb5c7525 (svn r11480) -Codechange: Rename the function ALIGN fitting to the naming style
This fixes also FS#1450
2007-11-19 20:40:14 +00:00
skidd13
d076ea8697 (svn r11479) -Codechange: Move the BIGMUL functions to the file of their usage
-Codechange: Rename the BIGMUL functions to the fitting naming style
2007-11-19 20:18:27 +00:00
rubidium
e815dae3c6 (svn r11478) -Fix: two small layout issues with the vehicle grouping GUI. 2007-11-19 19:54:23 +00:00
rubidium
a4df4728fc (svn r11477) -Fix [FS#1451]: a road vehicle must not show that it is driving max speed when it is standing still waiting for the vehicle in from of it. 2007-11-19 18:58:32 +00:00
skidd13
50bfe1a19d (svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define 2007-11-19 18:58:04 +00:00
skidd13
8be526e499 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style 2007-11-19 18:38:10 +00:00
belugas
006acff183 (svn r11474) -Feature: Allow to resize on creation the smallmap gui in order to show all the types industry available.
-Feature: Allow to enable/disable individually or all at once, the industries shown on small map.
This will permit to easily find those that are of some interest for the player.
Heavily based on gule's patch
2007-11-19 04:34:40 +00:00
belugas
fb0674ee2b (svn r11473) -Codechange: Replace two more instances of widget/smalltype numbers by enum(-a) values 2007-11-19 01:16:53 +00:00
belugas
51bb4a9dc8 (svn r11472) -Codechange: Give enuma for both the widget numbers and the used smallmap currently used type 2007-11-19 00:57:56 +00:00
smatz
2686901d84 (svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode 2007-11-18 23:13:53 +00:00
glx
6097c07e4b (svn r11470) -Codechange: add git detection to MSVC (michi_cc) 2007-11-18 22:39:02 +00:00
glx
400ca1dae5 (svn r11469) -Fix (r11051): only consider changes in src when detecting modified (M) version 2007-11-18 22:37:44 +00:00
glx
272a21077d (svn r11468) -Fix (r11330): rev number detection didn't work for git with msys/mingw 2007-11-18 20:38:24 +00:00
rubidium
e15a5365d1 (svn r11467) -Fix [FS#1450]: OpenBSD has ALIGN already defined, causing compilation failures. 2007-11-18 20:21:41 +00:00
smatz
96d156944f (svn r11466) -Fix (r11339): operator priority problem resulting in problematic autoroad placement in some cases 2007-11-18 20:10:07 +00:00
smatz
cd3c16d789 (svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad) 2007-11-18 20:05:44 +00:00
rubidium
92e0bf68e3 (svn r11464) -Fix: some issue that made OpenTTD on MorphOS seriously unplayable. 2007-11-18 18:28:32 +00:00
rubidium
dc81ea6454 (svn r11463) -Fix: some OSes seem not to handle allocating 0 bytes in the same manner as others do. 2007-11-18 16:41:25 +00:00
451 changed files with 23955 additions and 17485 deletions

12
BUGS
View File

@@ -1,12 +0,0 @@
/* $Id$ */
KNOWN BUGS / PROBLEMS:
bridges:
- Clearing tiles which may not have a bridge above can cause random bridge pieces to appear, which leads to crash in the long run
electrified rails:
Normal and elrail depots look the same. Use 'X' (transparent buildings)
to distinguish between them
Missing curors / icons for construction (currently using the conventional ones)

View File

@@ -79,7 +79,7 @@ ifeq ($(shell if test -f config.cache; then echo 1; fi), 1)
@echo " Going to reconfigure with last known settings..."
@echo "----------------"
# Make sure we don't lock config.cache
@$(shell cat config.cache) || exit 1
@$(shell cat config.cache | sed 's/\\ /\\\\ /g') || exit 1
@echo "----------------"
@echo "Reconfig done. Now compiling..."
@echo "----------------"

View File

@@ -105,14 +105,14 @@ else
# Are we a git dir?
ifeq ($(shell if test -d $(SRC_DIR)/../.git; then echo 1; fi), 1)
# Find the revision like: gXXXXM-branch
REV := g$(shell if head=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`; then echo "$$head" | cut -c1-8; fi)$(shell if git diff-index HEAD | read dummy; then echo M; fi)$(shell git branch|grep '[*]' | sed 's/\* /-/;s/^-master$$//')
REV_NR := $(shell echo `LC_ALL=C cd "$(SRC_DIR)/.." && git log --pretty=format:%s src | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/"` )
REV := g$(shell if head=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`; then echo "$$head" | cut -c1-8; fi)$(shell if cd "$(SRC_DIR)/.." && git diff-index HEAD src | read dummy; then echo M; fi)$(shell git branch|grep '[*]' | sed 's/\* /-/;s/^-master$$//')
REV_NR := $(shell LC_ALL=C cd "$(SRC_DIR)/.." && git log --pretty=format:%s src | grep -m 1 "^(svn r[0-9]*)" | sed "s/.*(svn r\([0-9]*\)).*/\1/" )
else
# Are we a hg (Mercurial) dir?
ifeq ($(shell if test -d $(SRC_DIR)/../.hg; then echo 1; fi), 1)
# Find the revision like: hXXXXM-branch
REV := h$(shell if head=`LC_ALL=C hg tip 2>/dev/null`; then echo "$$head" | head -n 1 | cut -c19-26; fi)$(shell if hg status $(SRC_DIR) | grep -v '^?' | read dummy; then echo M; fi)$(shell hg branch | sed 's/^/-/;s/^-default$$//')
REV_NR := $(shell LC_ALL=C hg log -k "svn" -l 1 --template "{desc}\n" $(SRC_DIR) | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/" )
REV_NR := $(shell LC_ALL=C hg log -k "svn" -l 1 --template "{desc}\n" $(SRC_DIR) | grep -m 1 "^(svn r[0-9]*)" | sed "s/.*(svn r\([0-9]*\)).*/\1/" )
endif
endif
endif

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,94 @@
0.6.0-beta3 (2008-01-16)
------------------------------------------------------------------------
-Feature: Replaced fixed size custom name array. Names are now attached to their object directly and there is no limit to the amount of names (r11822)
-Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match (r11759)
-Feature: Add support for NewGRF's train 'tilt' flag. Trains with tilt capability (specific details are per NewGRF set) will be given a 20% speed limit bonus on curves (r11741)
-Feature: Added sorting for cost, running costs and speed to road vehicles and ships build windows (r11710)
-Feature: List neutral stations where the player has service in the station list too (r11670)
-Feature: Check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen (r11646)
-Feature: Support shore replacement via Action 5 (r11726)
-Fix: When two NewGRFs 'fight' to define the same cargo it could happen that the strings are defined by one cargo and the 'action2' by another and when one assumes that both come from the same NewGRF [FS#1559] (r11862)
-Fix: Recompute town population when removing a 'newhouses' grf, or when loading a game with missing 'newhouses' grfs [FS#1335] (r11855)
-Fix: Road vehicle count was incorrect in network lobby window (r11844)
-Fix: Mark dirty canal tile even in diagonal direction from flooded tile, draw correctly canal next to half flooded rail tile (r11843, r11838)
-Fix: At least one instance of dmusic driver is needed for it to be registered and usable (r11826)
-Fix: An articulated road vehicle could split up when it turned around at a corner and then would enter a drive through station at the next tile [FS#1627] (r11825)
-Fix: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots [FS#1602] (r11813)
-Fix: Do not crash trains when leaving depot to a very long track [FS#716] (r11802)
-Fix: Take town rating into account when testing if a command can be executed [FS#1616] (r11795)
-Fix: Reversing a train when loading at a station with an adjacent station in the same axis crashed [FS#1632] (r11794)
-Fix: Group names got not deallocated in the command test run [FS#1614] (r11743)
-Fix: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused [FS#1319] (r11742)
-Fix: Modify and possibly discard key events for code points in the unicode private use area [FS#1610] (r11740)
-Fix: Set the new scroll position after zooming in instead of before, as the zoom will cancel it out [FS#1609] (r11739)
-Fix: Do not reset loading indicator IDs when only reloading NewGRFs [FS#1574] (r11735)
-Fix: Elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype (r11732)
-Fix: Clear sprite override data before performing NewGRF wagon attach callback. This stopped the callback working for autoreplace and when moving wagons from train to train in a depot [FS#1582] (r11731)
-Fix: If there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available [FS#1577] (r11727)
-Fix: Make it impossible (for users) to circumvent the length checking of the NewGRF 'allow wagon attach' callback by moving several wagons at a time (r11724)
-Fix: Do not put more than one Random() in function calls because parameter evaluation order is not guaranteed in the c++ standard [FS#1561] (r11716)
-Fix: Do not allow player inauguration date on scenarios to be bigger than current year [FS#1569] (r11714)
-Fix: Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids (r11712)
-Fix: Do not allow refitting flooded (destroyed) vehicles (r11707)
-Fix: Trains could have sprites with wrong direction when reversing, also was inconsistent with save/load process [FS#1557] (r11705)
-Fix: When removing buoys, return to water or canal depending on their owner (r11666)
-Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08 (r11665)
-Fix: Do not allow modifying non-uniform stations when non-uniform stations are disabled [FS#1563] (r11659)
-Fix: 'Initialised' NewGRFs could still be deactivated in the later 'activation' pass (r11650)
-Fix: Vehicles were still followed when sold [FS#1541] (r11632)
-Fix: Many viewports could crash the scenario editor [FS#1527] (r11629)
-Fix: Popping from text reference stack must be done in a precise order. But some compiler (MSVC) over optimised it and inverted this order [FS#1532] (r11627)
-Fix: There were still some cases where one could not build a tram track, but the tram could become blocked [FS#1525] (r11621)
-Fix: Do not make crossing red behind depot the train is entering [FS#1531] (r11619)
-Fix: Buoys are just waypoints, so don't allow load/unload/transfert for them (r11618)
-Fix: Sometimes large values could go off the chart [FS#1526] (r11616)
-Fix: Temperate banks can only be built in towns (over a house) (r11615)
0.6.0-beta2 (2007-12-09)
------------------------------------------------------------------------
- Feature: Allow setting a default password for new companies in network games (r11556)
- Feature: Signal selection GUI for the ones that really like to use that over CTRL (r11547)
- Feature: Make the bridge selection window resizable (r11539)
- Feature: [OSX] Added support for using Quartz instead of Quickdraw in windowed mode on OS X 10.4 and higher (r11496)
- Feature: Allow to resize on creation the smallmap gui in order to show all the types industry available, allow to enable/disable individually or all at once, the industries shown on small map (r11474)
- Codechange: Send and store the passwords a little more secure to/in the servers (r11557)
- Fix: Wrong error messages were shown when trying to build some industries in the scenario editor [FS#1524] (r11609)
- Fix: [NewGRF] Do not trigger industries, but only the industry's tiles (r11608)
- Fix: Wrong count of Kirby trains when a ship was build [FS#1482] (r11605)
- Fix: Tiles were not marked dirty in some cases when removing a lock or flooding (r11582, r11604)
- Fix: Make price for railtype conversion more realistic; conversion should not be more expensive than removing and rebuilding [FS#1481] (r11603)
- Fix: Do not allow changing network only patches settings from console when not in network game (r11594)
- Fix: IsSlopeRefused() result was half wrong causing banks to be built on wrong places (r11590)
- Fix: When ship depots got destroyed they always returned to water, even when it should have been canals [FS#1514] (r11589)
- Fix: The one way road button wasn't reset on abort (r11587)
- Fix: Windows could get completely missing when one resized the window to something very small [FS#1484] (r11583)
- Fix: Invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed so it does not become glitchy (r11577)
- Fix: Flood train stations when there are no trains on border tiles too (r11574, r11570)
- Fix: Reinitialise windows system before loading a savegame because not doing so can cause crashes [FS#1494] (r11572)
- Fix: Road vehicle getting to the wrong side of a station when trying to overtake in there [FS#1493] (r11571)
- Fix: Full paths sometimes did not work correctly [FS#1480] (r11568)
- Fix: Break the chain before moving a vehicle after another in the same chain instead of causing an infinite loop [FS#1512] (r11566)
- Fix: Aircraft sometimes stopped mid-air when the airport got destroyed [FS#1503] (r11562)
- Fix: Group list was not updated when removing the last group [FS#1504] (r11561)
- Fix: Overflow when drawing graphics with high company values [FS#1505] (r11558)
- Fix: If ever the air/heliport is suddenly not available while the "chopper" is descending, just go back into flying instead of stopping mid air [FS#1496] (r11546)
- Fix: Cargo translation was sometimes done when it should not be done [FS#1501] (r11544)
- Fix: [OSX] Detect statvfs at runtime (based on OSX version) instead of compile time. This should prevent a crash on OSX 10.3 with the precompiled binaries (in the load/save windows) (r11541)
- Fix: [OSX] Do not try to compile the quartz video driver on OSX 10.3 as it will fail (r11540)
- Fix: Do not do all kinds of 'updates' for town, waypoint, station and other signs when you have not converted the map to the 'current' format as that means you are going to read data in the 'old' format when you assume that it is in the 'current' format, which is eventually going to break (r11525)
- Fix: Assertion when tram reversed at a station [FS#1485] (r11524)
- Fix: The scrollbar of the network gui could run out of bounds (r11522)
- Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling (r11520)
- Fix: Signs totally illegible when transparant signs is turned on and zoomed out more than one level [FS#1463] (r11507)
- Fix: Selling vehicles could cause the window of others to scroll to that location [FS#1471] (r11506)
- Fix: Do not do standard production change if callbacks 29/35 failed, disable smooth economy for industries using callbacks 29/35 (r11502)
- Fix: Two small layout issues with the vehicle grouping GUI (r11478)
- Fix: A road vehicle must not show that it is driving max speed when it is standing still waiting for the vehicle in from of it [FS#1451] (r11477)
- Fix: OpenBSD has ALIGN already defined, causing compilation failures [FS#1450] (r11467)
- Fix: Operator priority problem resulting in problematic autoroad placement in some cases (r11466)
0.6.0-beta1 (2007-11-18)
------------------------------------------------------------------------
- Feature: Make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing (r11442)
@@ -32,7 +123,7 @@
- Feature: New sign editor features including switching to previous/next sign (r10401)
- Feature: Disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overridden with a patch setting [FS#669] (r10353)
- Feature: Add the possibility of automatically filling in timetables based on the times from the first (or subsequent) run-throughs (r10331)
- Feature: Option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map [FS#812] (r10329)
- Feature: Option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map [FS#812] (r10329)
- Feature: Give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches [FS#917] (r10300)
- Feature: A sticky button for the client list window [FS#885] (r10293)
- Feature: Allow double-clicking on certain places: add NewGRF window, build-vehicle and town-action (r10265, r10267)
@@ -384,7 +475,7 @@
- Fix: Draw canal edges under buoys that are in a canal (r8635)
- Fix: Buoys on canal tiles do not flood anymore (r8620)
- Fix: Store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. Prevents certain abuses (r8619)
- Fix: When the currently selected player in the performance details window is no longer active, choose the first active player instead of the first player as that may also be inactive [FS#582] (r8612)
- Fix: When the currently selected player in the performance details window is no longer active, choose the first active player instead of the first player as that may also be inactive [FS#582] (r8612)
- Fix: Road vehicle very close after another (slower) road vehicle gets its speed reset to 0 when entering a tunnel, which causes a traffic jam outside of the tunnel (r8609)
- Fix: Bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge [FS#564] (r8593)
- Fix: Road Vehicles now can obtain a slot even if the station is very spread out [FS#577] (r8536)
@@ -1028,7 +1119,7 @@
- Feature: scrolling credits list (in alphabetical order)
- Feature: Train window now shows the number of vehicles per row (mpetrov)
- Feature: [ 1039061 ] Swiss town-names (vulvulune)
- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops (doode)
- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops (doode)
- Feature: [ 1098254 ] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
- Fix: [ 1031451 ] Catchment area shows when buying sign
- Fix: [ 1040119 ] Flood and wagons in depot

View File

@@ -5,7 +5,7 @@ log() {
}
set_default() {
released_version="0.6.0-beta1"
released_version="0.6.0-beta3"
ignore_extra_parameters="0"
# We set all kinds of defaults for params. Later on the user can override
@@ -30,20 +30,22 @@ set_default() {
data_dir="share/games/openttd"
icon_dir="share/pixmaps"
personal_dir="1"
shared_dir="1"
install_dir="/"
enable_debug="0"
enable_desync_debug="0"
enable_profiling="0"
enable_dedicated="0"
enable_network="1"
enable_static="1"
enable_translator="0"
enable_unicode="1"
enable_assert="1"
enable_strip="1"
enable_universal="1"
enable_osx_g5="0"
enable_unicode="1"
with_distcc="1"
with_ccache="1"
enable_cocoa_quartz="1"
enable_cocoa_quickdraw="1"
with_osx_sysroot="1"
with_application_bundle="1"
with_sdl="1"
@@ -61,8 +63,66 @@ set_default() {
with_fontconfig="1"
with_psp_config="1"
with_threads="1"
with_distcc="1"
with_ccache="1"
save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os cpu_type revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_distcc with_osx_sysroot enable_universal enable_osx_g5 enable_unicode with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config with_threads CC CXX CFLAGS LDFLAGS"
save_params_array="
build
host
cc_build
cc_host
cxx_build
cxx_host
windres
strip
lipo
awk
os
endian
cpu_type
revision
config_log
prefix_dir
binary_dir
data_dir
icon_dir
personal_dir
shared_dir
install_dir
enable_debug
enable_desync_debug
enable_profiling
enable_dedicated
enable_network
enable_static
enable_translator
enable_unicode
enable_assert
enable_strip
enable_universal
enable_osx_g5
enable_cocoa_quartz
enable_cocoa_quickdraw
with_osx_sysroot
with_application_bundle
with_sdl
with_cocoa
with_zlib
with_png
with_makedepend
with_direct_music
with_sort
with_iconv
with_midi
with_midi_arg
with_libtimidity
with_freetype
with_fontconfig
with_psp_config
with_threads
with_distcc
with_ccache
CC CXX CFLAGS LDFLAGS"
}
detect_params() {
@@ -135,6 +195,10 @@ detect_params() {
--personal-dir=*) personal_dir="$optarg";;
--without-personal-dir) personal_dir="";;
--shared-dir) prevp_p="shared-dir";;
--shared-dir=*) shared_dir="$optarg";;
--without-shared-dir) shared_dir="";;
--install-dir) prevp_p="install-dir";;
--install-dir=*) install_dir="$optarg";;
@@ -142,6 +206,8 @@ detect_params() {
--enable-debug) enable_debug="1";;
--enable-debug=*) enable_debug="$optarg";;
--enable-desync-debug) enable_desync_debug="1";;
--enable-desync-debug=*) enable_desync_debug="$optarg";;
--enable-profiling) enable_profiling="1";;
--enable-profiling=*) enable_profiling="$optarg";;
--enable-dedicated) enable_dedicated="1";;
@@ -170,6 +236,13 @@ detect_params() {
--enable-unicode) enable_unicode="2";;
--enable-unicode=*) enable_unicode="$optarg";;
--disable-cocoa-quartz) enable_cocoa_quartz="0";;
--enable-cocoa-quartz) enable_cocoa_quartz="2";;
--enable-cocoa-quartz=*) enable_cocoa_quartz="$optarg";;
--disable-cocoa-quickdraw) enable_cocoa_quickdraw="0";;
--enable-cocoa-quickdraw) enable_cocoa_quickdraw="2";;
--enable-cocoa-quickdraw=*) enable_cocoa_quickdraw="$optarg";;
--with-sdl) with_sdl="2";;
--without-sdl) with_sdl="0";;
--with-sdl=*) with_sdl="$optarg";;
@@ -337,6 +410,13 @@ check_params() {
exit 1
fi
# enable_desync_debug should be between 0 and 3
if [ -z "`echo $enable_desync_debug | egrep '^[012]$'`" ]; then
echo "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
echo " Available options are: --enable-desync-debug[=012]"
exit 1
fi
detect_awk
check_build
@@ -376,7 +456,7 @@ check_params() {
detect_cputype
if [ "$enable_static" = "1" ]; then
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "OSX" ]; then
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ]; then
enable_static="2"
else
enable_static="0"
@@ -419,6 +499,17 @@ check_params() {
log 1 "using debug level... level $enable_debug"
fi
if [ "$enable_desync_debug" = "0" ]; then
log 1 "using desync debug level... no"
else
log 1 "using desync debug level... level $enable_desync_debug"
log 1 "WARNING: desync debug functions slow down the game considerably."
log 1 "WARNING: use only when you are instructed to do so"
log 1 " or when you know what you are doing."
sleep 5
fi
detect_sdl
detect_cocoa
@@ -729,6 +820,15 @@ check_params() {
fi
fi
if [ "$shared_dir" = "1" ]; then
# we are using default values
if [ "$os" = "OSX" ]; then
shared_dir="/Library/Application\\\\ Support/OpenTTD"
else
shared_dir=""
fi
fi
if [ -n "$personal_dir" ]
then
log 1 "personal home directory... $personal_dir"
@@ -736,6 +836,13 @@ check_params() {
log 1 "personal home directory... none"
fi
if [ -n "$shared_dir" ]
then
log 1 "shared data directory... $shared_dir"
else
log 1 "shared data directory... none"
fi
if [ -n "$install_dir" ]
then
log 1 "installation directory... $install_dir"
@@ -799,60 +906,76 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DNO_THREADS"
fi
# Enable some things only for certain GCC versions
cc_version=`$cc_host -dumpversion | cut -c 1,3`
if [ `echo $cc_host | cut -c 1-3` = "icc" ]; then
# Enable some things only for certain ICC versions
cc_version=`$cc_host -dumpversion | cut -c 1-4`
if [ $cc_version -ge 29 ]; then
CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
CFLAGS="$CFLAGS -Wno-uninitialized"
CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
fi
if [ "$cc_version" = "10.1" ]; then
CFLAGS="$CFLAGS -Wno-multichar"
fi
else
# Enable some things only for certain GCC versions
cc_version=`$cc_host -dumpversion | cut -c 1,3`
gcc295=""
if [ "$cc_version" = 29 ]; then
# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
# need a lovely hack there to make it compile correctly.
gcc295="1"
fi
if [ $cc_version -ge 29 ]; then
CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
CFLAGS="$CFLAGS -Wno-uninitialized"
if [ $cc_version -ge 30 ]; then
CFLAGS="$CFLAGS -W -Wno-unused-parameter"
fi
CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
fi
if [ $cc_version -ge 34 ]; then
CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
fi
gcc295=""
if [ "$cc_version" = 29 ]; then
# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
# need a lovely hack there to make it compile correctly.
gcc295="1"
fi
if [ "$os" = "CYGWIN" ]; then
CFLAGS="$CFLAGS -mwin32"
LDFLAGS="$LDFLAGS -mwin32"
fi
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
fi
if [ $cc_version -ge 30 ]; then
CFLAGS="$CFLAGS -W -Wno-unused-parameter"
fi
if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
fi
if [ $cc_version -ge 34 ]; then
CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
fi
# GCC 4.0+ complains about that we break strict-aliasing.
# On most places we don't see how to fix it, and it doesn't
# break anything. So disable strict-aliasing to make the
# compiler all happy.
if [ $cc_version -ge 40 ]; then
CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
if [ "$os" = "CYGWIN" ]; then
CFLAGS="$CFLAGS -mwin32"
LDFLAGS="$LDFLAGS -mwin32"
fi
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
fi
# GCC 4.2+ automatically assumes that signed overflows do
# not occur in signed arithmetics, whereas we are not
# sure that they will not happen. It furthermore complains
# about it's own optimized code in some places.
if [ $cc_version -ge 42 ]; then
CFLAGS="$CFLAGS -fno-strict-overflow"
if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
fi
# GCC 4.0+ complains about that we break strict-aliasing.
# On most places we don't see how to fix it, and it doesn't
# break anything. So disable strict-aliasing to make the
# compiler all happy.
if [ $cc_version -ge 40 ]; then
CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
# GCC 4.2+ automatically assumes that signed overflows do
# not occur in signed arithmetics, whereas we are not
# sure that they will not happen. It furthermore complains
# about it's own optimized code in some places.
if [ $cc_version -ge 42 ]; then
CFLAGS="$CFLAGS -fno-strict-overflow"
fi
# GCC 4.3+ gives a warning about empty body of
# loops and conditions
if [ $cc_version -ge 43 ]; then
CFLAGS="$CFLAGS -Wno-empty-body"
fi
fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
@@ -922,6 +1045,14 @@ make_cflags_and_ldflags() {
if [ "$with_cocoa" != "0" ]; then
CFLAGS="$CFLAGS -DWITH_COCOA"
LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit"
if [ "$enable_cocoa_quartz" != "0" ]; then
CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
fi
if [ "$enable_cocoa_quickdraw" != "0" ]; then
CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
fi
fi
if [ "$with_zlib" != "0" ]; then
@@ -1052,6 +1183,13 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DNDEBUG"
fi
if [ "$enable_desync_debug" = "1" ]; then
CFLAGS="$CFLAGS -DDEBUG_DUMP_COMMANDS"
fi
if [ "$enable_desync_debug" = "2" ]; then
CFLAGS="$CFLAGS -DRANDOM_DEBUG"
fi
if [ "$enable_osx_g5" != "0" ]; then
CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt"
fi
@@ -1065,6 +1203,10 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
fi
if [ -n "$shared_dir" ]; then
CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
fi
CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
@@ -1524,6 +1666,19 @@ detect_cocoa() {
fi
log 1 "checking COCOA... found"
if [ "$enable_cocoa_quartz" != "0" ]; then
log 1 "checking whether to enable the Quartz window subdriver... yes"
else
log 1 "checking whether to enable the Quartz window subdriver... no"
fi
if [ "$enable_cocoa_quickdraw" != "0" ]; then
log 1 "checking whether to enable the Quickdraw window subdriver... yes"
else
log 1 "checking whether to enable the Quickdraw window subdriver... no"
fi
}
detect_library() {
@@ -1976,7 +2131,7 @@ make_sed() {
ppc=`$cc_host -dumpmachine | egrep "powerpc|ppc"`
if [ -n "$ppc" ]; then
T_CFLAGS="$CFLAGS -DFOUR_BYTE_BOOL"
osx_sysroot_version=10.3.9
osx_sysroot_version=10.4u
else
T_CFLAGS="$CFLAGS"
osx_sysroot_version=10.4u
@@ -2022,6 +2177,7 @@ make_sed() {
s#!!DATA_DIR!!#$prefix_dir/$data_dir#g;
s#!!ICON_DIR!!#$prefix_dir/$icon_dir#g;
s#!!PERSONAL_DIR!!#$personal_dir#g;
s#!!SHARED_DIR!!#$shared_dir#g;
s#!!INSTALL_DIR!!#$install_dir#g;
s#!!STRGEN!!#$STRGEN#g;
s#!!ENDIAN_CHECK!!#$ENDIAN_CHECK#g;
@@ -2162,12 +2318,16 @@ showhelp() {
echo " [share/games/openttd]"
echo " --icon-dir=dir location of icons. Will be prefixed"
echo " with the prefix-dir [share/pixmaps]"
echo " --personal-dir=dir location of the personal directory [.openttd]"
echo " --personal-dir=dir location of the personal directory"
echo " [os-dependent default]"
echo " --shared-dir=dir location of shared data files"
echo " [os-dependent default]"
echo " --install-dir=dir specifies the root to install to."
echo " Useful to install into jails [/]"
echo ""
echo "Features and packages:"
echo " --enable-debug[=LVL] enable debug-mode (LVL=[0123], 0 is release)"
echo " --enable_desync_debug=[LVL] enable desync debug options (LVL=[012], 0 is none"
echo " --enable-profiling enables profiling"
echo " --enable-dedicated compile a dedicated server (without video)"
echo " --enable-static enable static compile (doesn't work for"
@@ -2175,6 +2335,8 @@ showhelp() {
echo " --enable-translator enable extra output for translators"
echo " --enable-universal enable universal builds (OSX ONLY)"
echo " --enable-osx-g5 enables optimalizations for G5 (OSX ONLY)"
echo " --disable-cocoa-quartz disable the quartz window mode driver for Cocoa (OSX ONLY)"
echo " --disable-cocoa-quickdraw disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
echo " --disable-unicode disable unicode support to build win9x"
echo " version (Win32 ONLY)"
echo " --disable-network disable network support"

4
configure vendored
View File

@@ -31,13 +31,13 @@ LANG_DIR="$SRC_DIR/lang"
MEDIA_DIR="$ROOT_DIR/media"
SOURCE_LIST="$ROOT_DIR/source.list"
if [ "$1" = "--reconfig" ]; then
if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
if ! [ -f "config.cache" ]; then
echo "can't reconfigure, because never configured before"
exit 1
fi
# Make sure we don't lock config.cache
cat config.cache > cache.tmp
cat config.cache | sed 's/\\ /\\\\ /g' > cache.tmp
sh cache.tmp
rm -f cache.tmp
exit $?

View File

@@ -945,6 +945,7 @@
</tr>
</table>
</li>
<li>m4: Owner of the water</li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul>

View File

@@ -194,8 +194,8 @@ the array so you can quickly see what is used and what is not.
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OO</span>XX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td>
</tr>

View File

@@ -11,20 +11,18 @@ by the number below on http://bugs.openttd.org.
If the bug report is closed, it has been fixed, which then can be verified
in the latest SVN version of /trunk.
Bugs for 0.6.0-beta1
Bugs for 0.6.0-beta3
------------------------------------------------------------------------
URL: http://bugs.openttd.org
- 1434 Network game crashes when player builds SH40
- 1624 Autoreplace refit fails -> crash
- 1549 Timetable + group ID are not backed up with orders
- 1495 Long vehicles block multistop station
- 1487 Ending_year is never written to
- 1473 Train not going to available platform
- 1404 Spinner widget interprets one click as many
- 1401 Crash while scrolling screen
- 1386 Mac OS X fails to compile out of the box on 10.5
- 1264 Autoreplace for multiple NewGRF DMU sets fails
- 1200 Illegal names skip comparisons for uniquity
- 1141 [OSX] Not smooth moving map with touchpad
- 1109 [OSX] Choppy mouse cursor movement in fullscreen mode
- 1094 Foundations showing on 'build on slopes'
- 1140 [OSX] Not smooth moving map with touchpad
- 1074 Large slowdown when building tracks
- 1072 Text overflows in several windows
- 716 Train crash in depot with long long tracks
- 119 Clipping problems with vehicles on slopes

View File

@@ -4,6 +4,18 @@ openttd (0.6~svn) unstable; urgency=low
-- Matthijs Kooijman <m.kooijman@student.utwente.nl> Mon, 26 Feb 2007 21:07:05 +0100
openttd (0.6.0~beta3-1) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <m.kooijman@student.utwente.nl> Tue, 16 Jan 2008 21:40:07 +0100
openttd (0.6.0~beta2-1) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <m.kooijman@student.utwente.nl> Sun, 09 Dec 2007 22:05:05 +0100
openttd (0.6.0~beta1-1) unstable; urgency=low
* New upstream release.

View File

@@ -1,9 +1,9 @@
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "0.6.0" ; Define application version
!define INSTALLERVERSION 39 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
!define INSTALLERVERSION 41 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
!define APPURLLINK "http://www.openttd.org"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta1"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta3"
!define APPVERSIONINTERNAL "${APPVERSION}.0" ; Needs to be of the format X.X.X.X
!define MUI_ICON "..\..\..\media\openttd.ico"

View File

@@ -41,6 +41,12 @@ Sub UpdateFiles(version)
revision = Mid(OExec.StdOut.ReadLine(), 7)
revision = Mid(revision, 1, InStr(revision, ")") - 1)
End If
Case "g" ' git
Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../src")
if Err.Number = 0 Then
revision = Mid(oExec.StdOut.ReadLine(), 7)
revision = Mid(revision, 1, InStr(revision, ")") - 1)
End If
End Select
UpdateFile revision, version, cur_date, "../src/rev.cpp"
@@ -118,25 +124,49 @@ Function DetermineSVNVersion()
version = version & Replace(url, "/", "-")
End If
Else
' svn detection failed, reset error and try mercurial (hg)
' svn detection failed, reset error and try git
Err.Clear
Set oExec = WshShell.Exec("hg tip")
Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD")
If Err.Number = 0 Then
version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
Set oExec = WshShell.Exec("hg status ../src")
If Err.Number = 0 Then
Do
line = OExec.StdOut.ReadLine()
If Mid(line, 1, 1) <> "?" Then
version = version & "M"
Exit Do
End If
Loop While Not OExec.StdOut.atEndOfStream
version = "g" & oExec.StdOut.ReadLine()
Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
Do While oExec.Status = 0 And Err.Number = 0
Loop
If Err.Number = 0 And oExec.ExitCode = 1 Then
version = version & "M"
End If
Set oExec = WshShell.Exec("hg branch")
Set oExec = WshShell.Exec("git symbolic-ref HEAD")
If Err.Number = 0 Then
line = OExec.StdOut.ReadLine()
If line <> "default" Then version = version & "-" & line
line = oExec.StdOut.ReadLine()
line = Mid(line, InStrRev(line, "/")+1)
If line <> "master" Then
version = version & "-" & line
End If
End If
Else
' try mercurial (hg)
Err.Clear
Set oExec = WshShell.Exec("hg tip")
If Err.Number = 0 Then
version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
Set oExec = WshShell.Exec("hg status ../src")
If Err.Number = 0 Then
Do
line = OExec.StdOut.ReadLine()
If Mid(line, 1, 1) <> "?" Then
version = version & "M"
Exit Do
End If
Loop While Not OExec.StdOut.atEndOfStream
End If
Set oExec = WshShell.Exec("hg branch")
If Err.Number = 0 Then
line = OExec.StdOut.ReadLine()
If line <> "default" Then
version = version & "-" & line
End If
End If
End If
End If
End If
@@ -164,7 +194,7 @@ Function IsCachedVersion(version)
End Function
Dim version
version = "0.6.0-beta1"
version = "0.6.0-beta3"
If Not (IsCachedVersion(version) And FSO.FileExists("../src/rev.cpp") And FSO.FileExists("../src/ottdres.rc")) Then
UpdateFiles version
End If

View File

@@ -51,19 +51,6 @@
Outputs="..\bin\lang\afrikaans.lng"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\american.txt">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Generating american language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;
"
AdditionalDependencies=""
Outputs="..\bin\lang\american.lng"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\brazilian_portuguese.txt">
<FileConfiguration
@@ -168,6 +155,19 @@
Outputs="..\bin\lang\english.lng"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_US.txt">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Generating english_US language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;
"
AdditionalDependencies=""
Outputs="..\bin\lang\english_US.lng"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\esperanto.txt">
<FileConfiguration

View File

@@ -61,21 +61,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\american.txt"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating american language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies=""
Outputs="..\bin\lang\american.lng"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\brazilian_portuguese.txt"
>
@@ -196,6 +181,21 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_US.txt"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating english_US language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies=""
Outputs="..\bin\lang\english_US.lng"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\esperanto.txt"
>

View File

@@ -62,21 +62,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\american.txt"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating american language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies=""
Outputs="..\bin\lang\american.lng"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\brazilian_portuguese.txt"
>
@@ -197,6 +182,21 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_US.txt"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating english_US language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;"
AdditionalDependencies=""
Outputs="..\bin\lang\english_US.lng"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\esperanto.txt"
>

View File

@@ -30,7 +30,7 @@
OmitFramePointers="TRUE"
OptimizeForProcessor="1"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="TRUE"
ExceptionHandling="TRUE"
RuntimeLibrary="0"
@@ -197,6 +197,12 @@
<File
RelativePath=".\..\src\console_cmds.cpp">
</File>
<File
RelativePath=".\..\src\core\bitmath_func.cpp">
</File>
<File
RelativePath=".\..\src\core\random_func.cpp">
</File>
<File
RelativePath=".\..\src\currency.cpp">
</File>
@@ -257,9 +263,6 @@
<File
RelativePath=".\..\src\md5.cpp">
</File>
<File
RelativePath=".\..\src\mersenne.cpp">
</File>
<File
RelativePath=".\..\src\minilzo.cpp">
</File>
@@ -341,6 +344,9 @@
<File
RelativePath=".\..\src\settings.cpp">
</File>
<File
RelativePath=".\..\src\signal.cpp">
</File>
<File
RelativePath=".\..\src\signs.cpp">
</File>
@@ -369,7 +375,7 @@
RelativePath=".\..\src\thread.cpp">
</File>
<File
RelativePath=".\..\src\tile.cpp">
RelativePath=".\..\src\tile_map.cpp">
</File>
<File
RelativePath=".\..\src\vehicle.cpp">
@@ -383,6 +389,9 @@
<File
RelativePath=".\..\src\widget.cpp">
</File>
<File
RelativePath=".\..\src\widgets\dropdown.cpp">
</File>
<File
RelativePath=".\..\src\win32.cpp">
</File>
@@ -426,6 +435,15 @@
<File
RelativePath=".\..\src\console.h">
</File>
<File
RelativePath=".\..\src\core\bitmath_func.hpp">
</File>
<File
RelativePath=".\..\src\core\math_func.hpp">
</File>
<File
RelativePath=".\..\src\core\random_func.hpp">
</File>
<File
RelativePath=".\..\src\currency.h">
</File>
@@ -486,9 +504,6 @@
<File
RelativePath=".\..\src\heightmap.h">
</File>
<File
RelativePath=".\..\src\helpers.hpp">
</File>
<File
RelativePath=".\..\src\industry.h">
</File>
@@ -498,9 +513,6 @@
<File
RelativePath=".\..\src\livery.h">
</File>
<File
RelativePath=".\..\src\macros.h">
</File>
<File
RelativePath=".\..\src\map.h">
</File>
@@ -642,6 +654,9 @@
<File
RelativePath=".\..\src\signs.h">
</File>
<File
RelativePath=".\..\src\signal_func.h">
</File>
<File
RelativePath=".\..\src\slope.h">
</File>
@@ -657,6 +672,9 @@
<File
RelativePath=".\..\src\station.h">
</File>
<File
RelativePath=".\..\src\station_gui.h">
</File>
<File
RelativePath=".\..\src\stdafx.h">
</File>
@@ -717,6 +735,15 @@
<File
RelativePath=".\..\src\window.h">
</File>
<File
RelativePath=".\..\src\widgets\dropdown.h">
</File>
<File
RelativePath=".\..\src\widgets\dropdown_type.h">
</File>
<File
RelativePath=".\..\src\widgets\dropdown_func.h">
</File>
<File
RelativePath=".\..\src\zoom.hpp">
</File>
@@ -875,6 +902,9 @@
<File
RelativePath=".\..\src\station_cmd.cpp">
</File>
<File
RelativePath=".\..\src\terraform_cmd.cpp">
</File>
<File
RelativePath=".\..\src\timetable_cmd.cpp">
</File>
@@ -1182,6 +1212,9 @@
<File
RelativePath=".\..\src\tunnel_map.h">
</File>
<File
RelativePath=".\..\src\tunnelbridge_map.h">
</File>
<File
RelativePath=".\..\src\unmovable_map.h">
</File>

View File

@@ -30,7 +30,7 @@
OmitFramePointers="TRUE"
OptimizeForProcessor="1"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="TRUE"
ExceptionHandling="TRUE"
RuntimeLibrary="0"

View File

@@ -61,7 +61,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -272,7 +272,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -495,6 +495,14 @@
RelativePath=".\..\src\console_cmds.cpp"
>
</File>
<File
RelativePath=".\..\src\core\bitmath_func.cpp"
>
</File>
<File
RelativePath=".\..\src\core\random_func.cpp"
>
</File>
<File
RelativePath=".\..\src\currency.cpp"
>
@@ -575,10 +583,6 @@
RelativePath=".\..\src\md5.cpp"
>
</File>
<File
RelativePath=".\..\src\mersenne.cpp"
>
</File>
<File
RelativePath=".\..\src\minilzo.cpp"
>
@@ -687,6 +691,10 @@
RelativePath=".\..\src\settings.cpp"
>
</File>
<File
RelativePath=".\..\src\signal.cpp"
>
</File>
<File
RelativePath=".\..\src\signs.cpp"
>
@@ -724,7 +732,7 @@
>
</File>
<File
RelativePath=".\..\src\tile.cpp"
RelativePath=".\..\src\tile_map.cpp"
>
</File>
<File
@@ -743,6 +751,10 @@
RelativePath=".\..\src\widget.cpp"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown.cpp"
>
</File>
<File
RelativePath=".\..\src\win32.cpp"
>
@@ -799,6 +811,18 @@
RelativePath=".\..\src\console.h"
>
</File>
<File
RelativePath=".\..\src\core\bitmath_func.hpp"
>
</File>
<File
RelativePath=".\..\src\core\math_func.hpp"
>
</File>
<File
RelativePath=".\..\src\core\random_func.hpp"
>
</File>
<File
RelativePath=".\..\src\currency.h"
>
@@ -879,10 +903,6 @@
RelativePath=".\..\src\heightmap.h"
>
</File>
<File
RelativePath=".\..\src\helpers.hpp"
>
</File>
<File
RelativePath=".\..\src\industry.h"
>
@@ -895,10 +915,6 @@
RelativePath=".\..\src\livery.h"
>
</File>
<File
RelativePath=".\..\src\macros.h"
>
</File>
<File
RelativePath=".\..\src\map.h"
>
@@ -1087,6 +1103,10 @@
RelativePath=".\..\src\signs.h"
>
</File>
<File
RelativePath=".\..\src\signal_func.h"
>
</File>
<File
RelativePath=".\..\src\slope.h"
>
@@ -1107,6 +1127,10 @@
RelativePath=".\..\src\station.h"
>
</File>
<File
RelativePath=".\..\src\station_gui.h"
>
</File>
<File
RelativePath=".\..\src\stdafx.h"
>
@@ -1187,6 +1211,18 @@
RelativePath=".\..\src\window.h"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown.h"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown_type.h"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown_func.h"
>
</File>
<File
RelativePath=".\..\src\zoom.hpp"
>
@@ -1395,6 +1431,10 @@
RelativePath=".\..\src\station_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\terraform_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\timetable_cmd.cpp"
>
@@ -1795,6 +1835,10 @@
RelativePath=".\..\src\tunnel_map.h"
>
</File>
<File
RelativePath=".\..\src\tunnelbridge_map.h"
>
</File>
<File
RelativePath=".\..\src\unmovable_map.h"
>

View File

@@ -61,7 +61,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -272,7 +272,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"

View File

@@ -62,7 +62,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -270,7 +270,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -492,6 +492,14 @@
RelativePath=".\..\src\console_cmds.cpp"
>
</File>
<File
RelativePath=".\..\src\core\bitmath_func.cpp"
>
</File>
<File
RelativePath=".\..\src\core\random_func.cpp"
>
</File>
<File
RelativePath=".\..\src\currency.cpp"
>
@@ -572,10 +580,6 @@
RelativePath=".\..\src\md5.cpp"
>
</File>
<File
RelativePath=".\..\src\mersenne.cpp"
>
</File>
<File
RelativePath=".\..\src\minilzo.cpp"
>
@@ -684,6 +688,10 @@
RelativePath=".\..\src\settings.cpp"
>
</File>
<File
RelativePath=".\..\src\signal.cpp"
>
</File>
<File
RelativePath=".\..\src\signs.cpp"
>
@@ -721,7 +729,7 @@
>
</File>
<File
RelativePath=".\..\src\tile.cpp"
RelativePath=".\..\src\tile_map.cpp"
>
</File>
<File
@@ -740,6 +748,10 @@
RelativePath=".\..\src\widget.cpp"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown.cpp"
>
</File>
<File
RelativePath=".\..\src\win32.cpp"
>
@@ -796,6 +808,18 @@
RelativePath=".\..\src\console.h"
>
</File>
<File
RelativePath=".\..\src\core\bitmath_func.hpp"
>
</File>
<File
RelativePath=".\..\src\core\math_func.hpp"
>
</File>
<File
RelativePath=".\..\src\core\random_func.hpp"
>
</File>
<File
RelativePath=".\..\src\currency.h"
>
@@ -876,10 +900,6 @@
RelativePath=".\..\src\heightmap.h"
>
</File>
<File
RelativePath=".\..\src\helpers.hpp"
>
</File>
<File
RelativePath=".\..\src\industry.h"
>
@@ -892,10 +912,6 @@
RelativePath=".\..\src\livery.h"
>
</File>
<File
RelativePath=".\..\src\macros.h"
>
</File>
<File
RelativePath=".\..\src\map.h"
>
@@ -1084,6 +1100,10 @@
RelativePath=".\..\src\signs.h"
>
</File>
<File
RelativePath=".\..\src\signal_func.h"
>
</File>
<File
RelativePath=".\..\src\slope.h"
>
@@ -1104,6 +1124,10 @@
RelativePath=".\..\src\station.h"
>
</File>
<File
RelativePath=".\..\src\station_gui.h"
>
</File>
<File
RelativePath=".\..\src\stdafx.h"
>
@@ -1184,6 +1208,18 @@
RelativePath=".\..\src\window.h"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown.h"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown_type.h"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown_func.h"
>
</File>
<File
RelativePath=".\..\src\zoom.hpp"
>
@@ -1392,6 +1428,10 @@
RelativePath=".\..\src\station_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\terraform_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\timetable_cmd.cpp"
>
@@ -1792,6 +1832,10 @@
RelativePath=".\..\src\tunnel_map.h"
>
</File>
<File
RelativePath=".\..\src\tunnelbridge_map.h"
>
</File>
<File
RelativePath=".\..\src\unmovable_map.h"
>

View File

@@ -62,7 +62,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -270,7 +270,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"

View File

@@ -1,6 +1,6 @@
OpenTTD README
Last updated: 2007-11-18
Release version: 0.6.0-beta1
Last updated: 2008-01-16
Release version: 0.6.0-beta3
------------------------------------------------------------------------
@@ -281,30 +281,35 @@ put them in the data/ folder and you're set to go.
X.X) Credits:
---- --------
The OpenTTD team (in alphabetical order):
Jean-Francois Claeys (Belugas) - In training, not yet specialized
Bjarni Corfitzen (Bjarni) - Mac OS X port, coder
Matthijs Kooijman (blathijs) - Pathfinder-guru
Victor Fischer (Celestar) - Programming everywhere you need him to
Tamás Faragó (Darkvater) - Lead programmer
Loïc Guilloux (glx) - In training, not yet specialized
Jean-Francois Claeys (Belugas) - GUI, newindustries and more
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles
Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework
Loïc Guilloux (glx) - General coding
Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)
Kerekes Miham (MiHaMiX) - Maintainer of translator service, and host of nightlies
Owen Rudge (orudge) - Contributor, forum host, OS/2 port
Peter Nelson (peter1138) - Spiritual descendant from newgrf gods
Remko Bijker (Rubidium) - THE desync hunter
Jonathan Coome (Maedhros) - High priest of the newGRF Temple
Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host
Owen Rudge (orudge) - Forum host, OS/2 port
Peter Nelson (peter1138) - Spiritual descendant from newGRF gods
Remko Bijker (Rubidium) - Lead coder and way more
Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker
Zdenek Sojka (SmatZ) - Bug finder and fixer
Inactive Developers:
Victor Fischer (Celestar) - Programming everywhere you need him to
Tamás Faragó (Darkvater) - Ex-Lead coder
Christoph Mallon (Tron) - Programmer, code correctness police
Retired Developers:
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)
Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)
Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)
Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)
Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)
Thanks to:
Josef Drexler - For his great work on TTDPatch.
Marcin Grzegorczyk - For his TTDPatch work and documentation of TTD internals and graphics (signals and track foundations)
Petr Baudis (pasky) - Many patches, newgrf support, etc.
Simon Sasburg (HackyKid) - For the many bugfixes he has blessed us with (and future PBS)
Simon Sasburg (HackyKid) - For the many bugfixes he has blessed us with
Stefan Meißner (sign_de) - For his work on the console
Mike Ragsdale - OpenTTD installer
Cian Duffy (MYOB) - BeOS port / manual writing

View File

@@ -10,6 +10,8 @@ cargotype.cpp
command.cpp
console.cpp
console_cmds.cpp
core/bitmath_func.cpp
core/random_func.cpp
currency.cpp
date.cpp
debug.cpp
@@ -30,7 +32,6 @@ helpers.cpp
landscape.cpp
map.cpp
md5.cpp
mersenne.cpp
minilzo.cpp
misc.cpp
mixer.cpp
@@ -65,6 +66,7 @@ screenshot.cpp
sdl.cpp
#end
settings.cpp
signal.cpp
signs.cpp
sound.cpp
spritecache.cpp
@@ -74,7 +76,7 @@ strings.cpp
texteff.cpp
tgp.cpp
thread.cpp
tile.cpp
tile_map.cpp
#if WIN32
#else
#if WINCE
@@ -91,6 +93,7 @@ vehicle.cpp
viewport.cpp
waypoint.cpp
widget.cpp
widgets/dropdown.cpp
#if WIN32
win32.cpp
#end
@@ -108,6 +111,9 @@ cargopacket.h
cargotype.h
command.h
console.h
core/bitmath_func.hpp
core/math_func.hpp
core/random_func.hpp
currency.h
date.h
debug.h
@@ -128,11 +134,9 @@ gfxinit.h
group.h
gui.h
heightmap.h
helpers.hpp
industry.h
landscape.h
livery.h
macros.h
map.h
md5.h
mixer.h
@@ -180,11 +184,13 @@ sound/sdl_s.h
video/sdl_v.h
settings.h
signs.h
signal_func.h
slope.h
sound.h
sprite.h
spritecache.h
station.h
station_gui.h
stdafx.h
string.h
texteff.hpp
@@ -205,6 +211,9 @@ music/win32_m.h
sound/win32_s.h
video/win32_v.h
window.h
widgets/dropdown.h
widgets/dropdown_type.h
widgets/dropdown_func.h
zoom.hpp
# GUI Source Code
@@ -259,6 +268,7 @@ road_cmd.cpp
roadveh_cmd.cpp
ship_cmd.cpp
station_cmd.cpp
terraform_cmd.cpp
timetable_cmd.cpp
town_cmd.cpp
train_cmd.cpp
@@ -368,6 +378,7 @@ town_map.h
tree_map.h
tunnel_map.cpp
tunnel_map.h
tunnelbridge_map.h
unmovable_map.h
void_map.h
water_map.h
@@ -477,7 +488,11 @@ sound/null_s.cpp
#end
#if COCOA
video/cocoa_v.mm
video/cocoa/cocoa_v.mm
video/cocoa/event.mm
video/cocoa/fullscreen.mm
video/cocoa/wnd_quartz.mm
video/cocoa/wnd_quickdraw.mm
sound/cocoa_s.cpp
os/macosx/splash.cpp
#end

View File

@@ -3,12 +3,17 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../variables.h"
#include "../command.h"
#include "../command_func.h"
#include "../network/network.h"
#include "../helpers.hpp"
#include "../core/alloc_func.hpp"
#include "../player_func.h"
#include "../player_base.h"
#include "ai.h"
#include "default/default.h"
AIStruct _ai;
AIPlayer _ai_player[MAX_PLAYERS];
/**
* Dequeues commands put in the queue via AI_PutCommandInQueue.
*/
@@ -45,7 +50,7 @@ static void AI_DequeueCommands(PlayerID player)
* Needed for SP; we need to delay DoCommand with 1 tick, because else events
* will make infinite loops (AIScript).
*/
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCallback* callback)
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
{
AICommand *com;
@@ -81,7 +86,7 @@ static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uin
/**
* Executes a raw DoCommand for the AI.
*/
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc, CommandCallback* callback)
{
PlayerID old_lp;
CommandCost res;
@@ -104,10 +109,6 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
/* Restore _cmd_text */
_cmd_text = tmp_cmdtext;
/* If we did a DC_EXEC, and the command did not return an error, execute it
* over the network */
if (flags & DC_NO_WATER) procc |= CMD_NO_WATER;
/* NetworkSend_Command needs _local_player to be set correctly, so
* adjust it, and put it back right after the function */
old_lp = _local_player;
@@ -134,7 +135,7 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
}
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
{
return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL);
}

View File

@@ -1,10 +1,12 @@
/* $Id$ */
#ifndef AI_H
#define AI_H
#include "../functions.h"
#include "../network/network.h"
#include "../player.h"
#include "../command.h"
#include "../command_type.h"
#include "../core/random_func.hpp"
#include "../settings_type.h"
/* How DoCommands look like for an AI */
struct AICommand {
@@ -12,7 +14,7 @@ struct AICommand {
uint32 p1;
uint32 p2;
uint32 procc;
CommandCallback* callback;
CommandCallback *callback;
char *text;
uint uid;
@@ -34,8 +36,8 @@ struct AIStruct {
uint tick; ///< The current tick (something like _frame_counter, only for AIs)
};
VARDEF AIStruct _ai;
VARDEF AIPlayer _ai_player[MAX_PLAYERS];
extern AIStruct _ai;
extern AIPlayer _ai_player[MAX_PLAYERS];
// ai.c
void AI_StartNewAI(PlayerID player);

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,66 @@
#ifndef DEFAULT_H
#define DEFAULT_H
#include "../../direction_type.h"
#include "../../vehicle_type.h"
#include "../../rail_type.h"
void AiDoGameLoop(Player*);
void SaveLoad_AI(PlayerID id);
struct AiBuildRec {
TileIndex spec_tile;
TileIndex use_tile;
byte rand_rng;
byte cur_building_rule;
byte unk6;
byte unk7;
byte buildcmd_a;
byte buildcmd_b;
byte direction;
CargoID cargo;
};
struct PlayerAI {
byte state;
byte tick; ///< Used to determine how often to move
uint32 state_counter; ///< Can hold tile index!
uint16 timeout_counter;
byte state_mode;
byte banned_tile_count;
RailTypeByte railtype_to_use;
CargoID cargo_type;
byte num_wagons;
byte build_kind;
byte num_build_rec;
byte num_loco_to_build;
byte num_want_fullload;
byte route_type_mask;
TileIndex start_tile_a;
TileIndex cur_tile_a;
DiagDirectionByte cur_dir_a;
DiagDirectionByte start_dir_a;
TileIndex start_tile_b;
TileIndex cur_tile_b;
DiagDirectionByte cur_dir_b;
DiagDirectionByte start_dir_b;
Vehicle *cur_veh; ///< only used by some states
AiBuildRec src, dst, mid1, mid2;
VehicleID wagon_list[9];
byte order_list_blocks[20];
TileIndex banned_tiles[16];
byte banned_val[16];
};
extern PlayerAI _players_ai[MAX_PLAYERS];
#endif

View File

@@ -3,17 +3,17 @@
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
#include "../../road_map.h"
#include "../../tile.h"
#include "../../vehicle.h"
#include "../../command.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../engine.h"
#include "../../station.h"
#include "../../variables.h"
#include "../../bridge.h"
#include "../../vehicle_func.h"
#include "../../vehicle_base.h"
#include "../../player_base.h"
#include "../../player_func.h"
#include "../ai.h"
// Build HQ
@@ -72,7 +72,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
if (type2 == 0 && type != 0) type2 = type;
// Now, simply, build the bridge!
if (p->ainew.tbt == AI_TRAIN) {
if (_players_ainew[p->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile_a, tile_b, (0x00 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
} else {
return AI_DoCommand(tile_a, tile_b, ((0x80 | ROADTYPES_ROAD) << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
@@ -146,7 +146,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
res = AI_DoCommand(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(res)) {
// Problem.. let's just abort it all!
p->ainew.state = AI_STATE_NOTHING;
_players_ainew[p->index].state = AI_STATE_NOTHING;
return CommandCost();
}
cost.AddCost(res);
@@ -202,7 +202,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicleOnGround(route[part])) {
// Problem.. let's just abort it all!
DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]);
p->ainew.state = AI_STATE_NOTHING;
_players_ainew[p->index].state = AI_STATE_NOTHING;
return CommandCost();
}
@@ -228,7 +228,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
// It returns INVALID_ENGINE if not suitable engine is found
EngineID AiNew_PickVehicle(Player *p)
{
if (p->ainew.tbt == AI_TRAIN) {
if (_players_ainew[p->index].tbt == AI_TRAIN) {
// Not supported yet
return INVALID_ENGINE;
} else {
@@ -246,11 +246,11 @@ EngineID AiNew_PickVehicle(Player *p)
CommandCost ret;
/* Skip vehicles which can't take our cargo type */
if (rvi->cargo_type != p->ainew.cargo && !CanRefitTo(i, p->ainew.cargo)) continue;
if (rvi->cargo_type != _players_ainew[p->index].cargo && !CanRefitTo(i, _players_ainew[p->index].cargo)) continue;
// Is it availiable?
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
if (!HASBIT(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
if (!HasBit(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
/* Rate and compare the engine by speed & capacity */
rating = rvi->max_speed * rvi->capacity;
@@ -274,20 +274,20 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
Player* p = GetPlayer(_current_player);
if (success) {
p->ainew.state = AI_STATE_GIVE_ORDERS;
p->ainew.veh_id = _new_vehicle_id;
_players_ainew[p->index].state = AI_STATE_GIVE_ORDERS;
_players_ainew[p->index].veh_id = _new_vehicle_id;
if (GetVehicle(p->ainew.veh_id)->cargo_type != p->ainew.cargo) {
if (GetVehicle(_players_ainew[p->index].veh_id)->cargo_type != _players_ainew[p->index].cargo) {
/* Cargo type doesn't match, so refit it */
if (CmdFailed(DoCommand(tile, p->ainew.veh_id, p->ainew.cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
if (CmdFailed(DoCommand(tile, _players_ainew[p->index].veh_id, _players_ainew[p->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
/* Refit failed, so sell the vehicle */
DoCommand(tile, p->ainew.veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
p->ainew.state = AI_STATE_NOTHING;
DoCommand(tile, _players_ainew[p->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
_players_ainew[p->index].state = AI_STATE_NOTHING;
}
}
} else {
/* XXX this should be handled more gracefully */
p->ainew.state = AI_STATE_NOTHING;
_players_ainew[p->index].state = AI_STATE_NOTHING;
}
}
@@ -298,7 +298,7 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
EngineID i = AiNew_PickVehicle(p);
if (i == INVALID_ENGINE) return CMD_ERROR;
if (p->ainew.tbt == AI_TRAIN) return CMD_ERROR;
if (_players_ainew[p->index].tbt == AI_TRAIN) return CMD_ERROR;
if (flag & DC_EXEC) {
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
@@ -310,7 +310,7 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
{
CommandCost ret, ret2;
if (p->ainew.tbt == AI_TRAIN) {
if (_players_ainew[p->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
} else {
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);

View File

@@ -4,15 +4,17 @@
#include "../../openttd.h"
#include "../../bridge_map.h"
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
#include "../../tile.h"
#include "../../command.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../depot.h"
#include "../../tunnel_map.h"
#include "../../bridge.h"
#include "../../tunnelbridge_map.h"
#include "../ai.h"
#include "../../variables.h"
#include "../../player_base.h"
#include "../../player_func.h"
#define TEST_STATION_NO_DIR 0xFF
@@ -27,14 +29,14 @@ static bool TestCanBuildStationHere(TileIndex tile, byte dir)
// TODO: currently we only allow spots that can be access from al 4 directions...
// should be fixed!!!
for (dir = 0; dir < 4; dir++) {
ret = AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST);
ret = AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST);
if (CmdSucceeded(ret)) return true;
}
return false;
}
// return true if command succeeded, so the inverse of CmdFailed()
return CmdSucceeded(AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST));
return CmdSucceeded(AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST));
}
@@ -43,10 +45,7 @@ static bool IsRoad(TileIndex tile)
return
// MP_ROAD, but not a road depot?
(IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
(IsTileType(tile, MP_TUNNELBRIDGE) && (
(IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) ||
(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD)
));
(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
}
@@ -234,11 +233,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
// If the next step is a bridge, we have to enter it the right way
if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
if (IsTileType(atile, MP_TUNNELBRIDGE)) {
if (IsTunnel(atile)) {
if (GetTunnelDirection(atile) != i) continue;
} else {
if (GetBridgeRampDirection(atile) != i) continue;
}
if (GetTunnelBridgeDirection(atile) != i) continue;
}
}
@@ -411,7 +406,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
if (PathFinderInfo->rail_or_road) {
Foundation f = GetRailFoundation(parent_tileh, (TrackBits)(1 << AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile)));
// Maybe is BRIDGE_NO_FOUNDATION a bit strange here, but it contains just the right information..
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HASBIT(BRIDGE_NO_FOUNDATION, parent_tileh))) {
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HasBit(BRIDGE_NO_FOUNDATION, parent_tileh))) {
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
} else {
res += AI_PATHFINDER_FOUNDATION_PENALTY;
@@ -419,7 +414,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
} else {
if (!IsRoad(parent->path.node.tile) || !IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE)) {
Foundation f = GetRoadFoundation(parent_tileh, (RoadBits)AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HASBIT(BRIDGE_NO_FOUNDATION, parent_tileh))) {
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HasBit(BRIDGE_NO_FOUNDATION, parent_tileh))) {
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
} else {
res += AI_PATHFINDER_FOUNDATION_PENALTY;
@@ -444,13 +439,13 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
res += AI_PATHFINDER_BRIDGE_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
// Check if we are going up or down, first for the starting point
// In user_data[0] is at the 8th bit the direction
if (!HASBIT(BRIDGE_NO_FOUNDATION, parent_tileh)) {
if (!HasBit(BRIDGE_NO_FOUNDATION, parent_tileh)) {
if (IsLeveledFoundation(GetBridgeFoundation(parent_tileh, (Axis)((current->user_data[0] >> 8) & 1)))) {
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
}
}
// Second for the end point
if (!HASBIT(BRIDGE_NO_FOUNDATION, tileh)) {
if (!HasBit(BRIDGE_NO_FOUNDATION, tileh)) {
if (IsLeveledFoundation(GetBridgeFoundation(tileh, (Axis)((current->user_data[0] >> 8) & 1)))) {
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
}

View File

@@ -3,9 +3,10 @@
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../debug.h"
#include "../../map.h"
#include "../../map_func.h"
#include "../../vehicle_base.h"
#include "../../player_base.h"
#include "trolly.h"
#include "../../vehicle.h"
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
{
@@ -80,8 +81,8 @@ uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
uint i;
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
if (p->ainew.special_vehicles[i].veh_id == v->index) {
return p->ainew.special_vehicles[i].flag;
if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
return _players_ainew[p->index].special_vehicles[i].flag;
}
}
@@ -96,13 +97,13 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
uint i;
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
if (p->ainew.special_vehicles[i].veh_id == v->index) {
p->ainew.special_vehicles[i].flag |= flag;
if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
_players_ainew[p->index].special_vehicles[i].flag |= flag;
return true;
}
if (new_id == -1 &&
p->ainew.special_vehicles[i].veh_id == 0 &&
p->ainew.special_vehicles[i].flag == 0) {
_players_ainew[p->index].special_vehicles[i].veh_id == 0 &&
_players_ainew[p->index].special_vehicles[i].flag == 0) {
new_id = i;
}
}
@@ -112,7 +113,7 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
DEBUG(ai, 1, "special_vehicles list is too small");
return false;
}
p->ainew.special_vehicles[new_id].veh_id = v->index;
p->ainew.special_vehicles[new_id].flag = flag;
_players_ainew[p->index].special_vehicles[new_id].veh_id = v->index;
_players_ainew[p->index].special_vehicles[new_id].flag = flag;
return true;
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,9 @@
#define AI_TROLLY_H
#include "../../aystar.h"
#include "../../player.h"
#include "../../player_type.h"
#include "../../vehicle_type.h"
#include "../../date_type.h"
/*
* These defines can be altered to change the behavoir of the AI
@@ -239,6 +241,22 @@ typedef void AiNew_StateFunction(Player *p);
// ai_new.c
void AiNewDoGameLoop(Player *p);
struct Ai_PathFinderInfo {
TileIndex start_tile_tl; ///< tl = top-left
TileIndex start_tile_br; ///< br = bottom-right
TileIndex end_tile_tl; ///< tl = top-left
TileIndex end_tile_br; ///< br = bottom-right
DiagDirection start_direction; ///< 0 to 3 or AI_PATHFINDER_NO_DIRECTION
DiagDirection end_direction; ///< 0 to 3 or AI_PATHFINDER_NO_DIRECTION
TileIndex route[500];
byte route_extra[500]; ///< Some extra information about the route like bridge/tunnel
int route_length;
int position; ///< Current position in the build-path, needed to build the path
bool rail_or_road; ///< true = rail, false = road
};
// ai_pathfinder.c
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo);
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo);
@@ -259,4 +277,64 @@ EngineID AiNew_PickVehicle(Player *p);
CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
/* The amount of memory reserved for the AI-special-vehicles */
#define AI_MAX_SPECIAL_VEHICLES 100
struct Ai_SpecialVehicle {
VehicleID veh_id;
uint32 flag;
};
struct PlayerAiNew {
uint8 state;
uint tick;
uint idle;
int temp; ///< A value used in more than one function, but it just temporary
///< The use is pretty simple: with this we can 'think' about stuff
///< in more than one tick, and more than one AI. A static will not
///< do, because they are not saved. This way, the AI is almost human ;)
int counter; ///< For the same reason as temp, we have counter. It can count how
///< long we are trying something, and just abort if it takes too long
/* Pathfinder stuff */
Ai_PathFinderInfo path_info;
AyStar *pathfinder;
/* Route stuff */
CargoID cargo;
byte tbt; ///< train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
Money new_cost;
byte action;
int last_id; ///< here is stored the last id of the searched city/industry
Date last_vehiclecheck_date; // Used in CheckVehicle
Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; ///< Some vehicles have some special flags
TileIndex from_tile;
TileIndex to_tile;
DiagDirectionByte from_direction;
DiagDirectionByte to_direction;
bool from_deliver; ///< True if this is the station that GIVES cargo
bool to_deliver;
TileIndex depot_tile;
DiagDirectionByte depot_direction;
byte amount_veh; ///< How many vehicles we are going to build in this route
byte cur_veh; ///< How many vehicles did we bought?
VehicleID veh_id; ///< Used when bought a vehicle
VehicleID veh_main_id; ///< The ID of the first vehicle, for shared copy
int from_ic; ///< ic = industry/city. This is the ID of them
byte from_type; ///< AI_NO_TYPE/AI_CITY/AI_INDUSTRY
int to_ic;
byte to_type;
};
extern PlayerAiNew _players_ainew[MAX_PLAYERS];
#endif /* AI_TROLLY_H */

View File

@@ -6,9 +6,8 @@
#define AIRCRAFT_H
#include "station_map.h"
#include "vehicle.h"
#include "vehicle_base.h"
#include "engine.h"
#include "variables.h"
/** An aircraft can be one ot those types */
enum AircraftSubType {

View File

@@ -7,33 +7,38 @@
#include "openttd.h"
#include "aircraft.h"
#include "debug.h"
#include "functions.h"
#include "landscape.h"
#include "station_map.h"
#include "strings.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"
#include "vehicle.h"
#include "timetable.h"
#include "depot.h"
#include "engine.h"
#include "command.h"
#include "station.h"
#include "news.h"
#include "sound.h"
#include "player.h"
#include "aircraft.h"
#include "airport.h"
#include "vehicle_gui.h"
#include "table/sprites.h"
#include "newgrf_engine.h"
#include "newgrf_callbacks.h"
#include "newgrf_text.h"
#include "newgrf_sound.h"
#include "date.h"
#include "spritecache.h"
#include "cargotype.h"
#include "strings_func.h"
#include "command_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "functions.h"
#include "variables.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
#include "gfx_func.h"
#include "player_func.h"
#include "settings_type.h"
#include "table/strings.h"
#include "table/sprites.h"
void Aircraft::UpdateDeltaXY(Direction direction)
{
@@ -162,7 +167,7 @@ int Aircraft::GetImage(Direction direction) const
int sprite = GetCustomVehicleSprite(this, direction);
if (sprite != 0) return sprite;
spritenum = orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index;
spritenum = _orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index;
}
return direction + _aircraft_sprite[spritenum];
}
@@ -190,7 +195,7 @@ void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal)
if (is_custom_sprite(spritenum)) {
sprite = GetCustomVehicleIcon(engine, DIR_W);
if (sprite == 0) {
spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
sprite = (6 + _aircraft_sprite[spritenum]);
}
}
@@ -218,7 +223,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
if (is_custom_sprite(spritenum)) {
sprite = GetCustomVehicleIcon(engine, DIR_W);
if (sprite == 0) {
spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
sprite = (6 + _aircraft_sprite[spritenum]);
}
}
@@ -231,7 +236,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
{
return CommandCost(GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
}
@@ -279,8 +284,6 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
/* Prevent building aircraft types at places which can't handle them */
if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
@@ -291,7 +294,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
UnitID unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
if (unit_num > _patches.max_aircraft)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -334,7 +337,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->cargo_subtype = 0;
v->string_id = STR_SV_AIRCRAFT_NAME;
v->name = NULL;
// v->next_order_param = v->next_order = 0;
// v->load_unload_time_rem = 0;
@@ -364,7 +367,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->cargo_type = cargo;
if (HASBIT(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
if (HasBit(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
}
@@ -418,7 +421,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
u->random_bits = VehicleRandomBits();
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
UpdateAircraftCache(v);
@@ -489,9 +492,7 @@ CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
CommandCost ret(-v->value);
CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
if (flags & DC_EXEC) {
// Invalidate depot
@@ -568,13 +569,13 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner) || v->IsInDepot()) return CMD_ERROR;
if (v->current_order.type == OT_GOTO_DEPOT && !(p2 & DEPOT_LOCATE_HANGAR)) {
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
if (!!(p2 & DEPOT_SERVICE) == HasBit(v->current_order.flags, OF_HALT_IN_DEPOT)) {
/* We called with a different DEPOT_SERVICE setting.
* Now we change the setting to apply the new one and let the vehicle head for the same hangar.
* Note: the if is (true for requesting service == true for ordered to stop in hangar) */
if (flags & DC_EXEC) {
CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
ClrBit(v->current_order.flags, OF_PART_OF_ORDERS);
ToggleBit(v->current_order.flags, OF_HALT_IN_DEPOT);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
return CommandCost();
@@ -582,7 +583,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
if (flags & DC_EXEC) {
if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
if (v->current_order.flags & OFB_UNLOAD) v->cur_order_index++;
v->current_order.type = OT_DUMMY;
v->current_order.flags = 0;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@@ -605,8 +606,8 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
if (v->current_order.type == OT_LOADING) v->LeaveStation();
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
v->current_order.flags = OFB_NON_STOP;
if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OF_HALT_IN_DEPOT);
v->current_order.refit_cargo = CT_INVALID;
v->current_order.dest = next_airport_index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@@ -641,16 +642,15 @@ CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
/* Check cargo */
CargoID new_cid = GB(p2, 0, 8);
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
/* Check the refit capacity callback */
uint16 callback = CALLBACK_FAILED;
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
/* Back up the existing cargo type */
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;
@@ -714,7 +714,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
// printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
// v->u.air.targetairport = st->index;
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
v->current_order.flags = OFB_NON_STOP;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} else if (v->current_order.type == OT_GOTO_DEPOT) {
v->current_order.type = OT_DUMMY;
@@ -737,11 +737,10 @@ void OnNewDay_Aircraft(Vehicle *v)
if (v->vehstatus & VS_STOPPED) return;
CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
CommandCost cost = CommandCost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
v->profit_this_year -= cost.GetCost() >> 8;
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
SubtractMoneyFromPlayerFract(v->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
@@ -833,12 +832,12 @@ static void SetAircraftPosition(Vehicle *v, int x, int y, int z)
Vehicle *u = v->Next();
int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
u->x_pos = x;
u->y_pos = y - ((v->z_pos-GetSlopeZ(safe_x, safe_y)) >> 3);;
safe_y = clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
u->z_pos = GetSlopeZ(safe_x, safe_y);
u->cur_image = v->cur_image;
@@ -1042,7 +1041,17 @@ static bool AircraftController(Vehicle *v)
tile = st->xy;
/* Jump into our "holding pattern" state machine if possible */
if (v->u.air.pos >= afc->nofelements) v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
if (v->u.air.pos >= afc->nofelements) {
v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
} else if (v->u.air.targetairport != v->current_order.dest) {
/* If not possible, just get out of here fast */
v->u.air.state = FLYING;
UpdateAircraftCache(v);
AircraftNextAirportPos_and_Order(v);
/* get aircraft back on running altitude */
SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlyingAltitude(v));
return false;
}
}
/* get airport moving data */
@@ -1112,7 +1121,7 @@ static bool AircraftController(Vehicle *v)
}
/* Get distance from destination pos to current pos. */
uint dist = myabs(x + amd->x - v->x_pos) + myabs(y + amd->y - v->y_pos);
uint dist = abs(x + amd->x - v->x_pos) + abs(y + amd->y - v->y_pos);
/* Need exact position? */
if (!(amd->flag & AMED_EXACTPOS) && dist <= (amd->flag & AMED_SLOWTURN ? 8U : 4U)) return true;
@@ -1255,7 +1264,7 @@ static void HandleCrashedAircraft(Vehicle *v)
if (v->u.air.crashed_counter < 650) {
uint32 r;
if (CHANCE16R(1,32,r)) {
if (Chance16R(1,32,r)) {
static const DirDiff delta[] = {
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
};
@@ -1338,8 +1347,8 @@ static void ProcessAircraftOrder(Vehicle *v)
{
switch (v->current_order.type) {
case OT_GOTO_DEPOT:
if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
if (!(v->current_order.flags & OFB_PART_OF_ORDERS)) return;
if (v->current_order.flags & OFB_SERVICE_IF_NEEDED &&
!VehicleNeedsService(v)) {
UpdateVehicleTimetable(v, true);
v->cur_order_index++;
@@ -1680,7 +1689,7 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
if (v->owner == _local_player && (
EngineHasReplacementForPlayer(p, v->engine_type, v->group_id) ||
((p->engine_renew && v->age - v->max_age > p->engine_renew_months * 30) &&
HASBIT(GetEngine(v->engine_type)->player_avail, _local_player))
HasBit(GetEngine(v->engine_type)->player_avail, _local_player))
)) {
_current_player = _local_player;
DoCommandP(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
@@ -1957,10 +1966,10 @@ static bool FreeTerminal(Vehicle *v, byte i, byte last_terminal)
{
Station *st = GetStation(v->u.air.targetairport);
for (; i < last_terminal; i++) {
if (!HASBIT(st->airport_flags, _airport_terminal_flag[i])) {
if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
/* TERMINAL# HELIPAD# */
v->u.air.state = _airport_terminal_state[i]; // start moving to that terminal/helipad
SETBIT(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
SetBit(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
return true;
}
}

View File

@@ -6,22 +6,17 @@
#include "openttd.h"
#include "aircraft.h"
#include "debug.h"
#include "functions.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "strings.h"
#include "map.h"
#include "window.h"
#include "gui.h"
#include "vehicle.h"
#include "gfx.h"
#include "command.h"
#include "engine.h"
#include "viewport.h"
#include "player.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"
#include "vehicle_func.h"
#include "gfx_func.h"
#include "table/sprites.h"
#include "table/strings.h"
/**
* Draw the details for the given vehicle at the position (x,y)

View File

@@ -5,13 +5,12 @@
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "map.h"
#include "airport.h"
#include "macros.h"
#include "variables.h"
#include "airport_movement.h"
#include "date.h"
#include "helpers.hpp"
#include "core/bitmath_func.hpp"
#include "core/alloc_func.hpp"
#include "date_func.h"
#include "settings_type.h"
/* Uncomment this to print out a full report of the airport-structure
* You should either use
@@ -431,18 +430,6 @@ static const char* const _airport_heading_strings[] = {
"DUMMY" // extra heading for 255
};
static uint AirportBlockToString(uint32 block)
{
uint i = 0;
if (block & 0xffff0000) { block >>= 16; i += 16; }
if (block & 0x0000ff00) { block >>= 8; i += 8; }
if (block & 0x000000f0) { block >>= 4; i += 4; }
if (block & 0x0000000c) { block >>= 2; i += 2; }
if (block & 0x00000002) { i += 1; }
return i;
}
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report)
{
if (!full_report) printf("(P = Current Position; NP = Next Position)\n");
@@ -453,7 +440,7 @@ static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool ful
byte heading = (current->heading == 255) ? MAX_HEADINGS + 1 : current->heading;
printf("\tPos:%2d NPos:%2d Heading:%15s Block:%2d\n", current->position,
current->next_position, _airport_heading_strings[heading],
AirportBlockToString(current->block));
FindLastBit(current->block));
} else {
printf("P:%2d NP:%2d", current->position, current->next_position);
}
@@ -488,14 +475,14 @@ uint32 GetValidAirports()
{
uint32 mask = 0;
if (_cur_year < 1960 || _patches.always_small_airport) SETBIT(mask, 0); // small airport
if (_cur_year >= 1955) SETBIT(mask, 1); // city airport
if (_cur_year >= 1963) SETBIT(mask, 2); // heliport
if (_cur_year >= 1980) SETBIT(mask, 3); // metropolitan airport
if (_cur_year >= 1990) SETBIT(mask, 4); // international airport
if (_cur_year >= 1983) SETBIT(mask, 5); // commuter airport
if (_cur_year >= 1976) SETBIT(mask, 6); // helidepot
if (_cur_year >= 2002) SETBIT(mask, 7); // intercontinental airport
if (_cur_year >= 1980) SETBIT(mask, 8); // helistation
if (_cur_year < 1960 || _patches.always_small_airport) SetBit(mask, 0); // small airport
if (_cur_year >= 1955) SetBit(mask, 1); // city airport
if (_cur_year >= 1963) SetBit(mask, 2); // heliport
if (_cur_year >= 1980) SetBit(mask, 3); // metropolitan airport
if (_cur_year >= 1990) SetBit(mask, 4); // international airport
if (_cur_year >= 1983) SetBit(mask, 5); // commuter airport
if (_cur_year >= 1976) SetBit(mask, 6); // helidepot
if (_cur_year >= 2002) SetBit(mask, 7); // intercontinental airport
if (_cur_year >= 1980) SetBit(mask, 8); // helistation
return mask;
}

View File

@@ -5,7 +5,8 @@
#ifndef AIRPORT_H
#define AIRPORT_H
#include "direction.h"
#include "direction_type.h"
#include "map_type.h"
enum {MAX_TERMINALS = 10};
enum {MAX_HELIPADS = 4};

View File

@@ -4,20 +4,23 @@
#include "stdafx.h"
#include "openttd.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "map.h"
#include "window.h"
#include "window_gui.h"
#include "gui.h"
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "vehicle.h"
#include "station_gui.h"
#include "terraform_gui.h"
#include "command_func.h"
#include "station.h"
#include "airport.h"
#include "depot.h"
#include "sound_func.h"
#include "window_func.h"
#include "settings_type.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "player_func.h"
#include "table/sprites.h"
#include "table/strings.h"
static byte _selected_airport_type;
@@ -101,7 +104,7 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
break;
case WE_ABORT_PLACE_OBJ:
RaiseWindowButtons(w);
w->RaiseButtons();
w = FindWindowById(WC_BUILD_STATION, 0);
if (w != 0)
@@ -145,9 +148,9 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_CREATE:
SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
LowerWindowWidget(w, _selected_airport_type + 7);
w->SetWidgetLoweredState(16, !_station_show_coverage);
w->SetWidgetLoweredState(17, _station_show_coverage);
w->LowerWidget(_selected_airport_type + 7);
break;
case WE_PAINT: {
@@ -159,10 +162,10 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
avail_airports = GetValidAirports();
RaiseWindowWidget(w, _selected_airport_type + 7);
if (!HASBIT(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
if (!HASBIT(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
LowerWindowWidget(w, _selected_airport_type + 7);
w->RaiseWidget(_selected_airport_type + 7);
if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
w->LowerWidget(_selected_airport_type + 7);
/* 'Country Airport' starts at widget 7, and if its bit is set, it is
* available, so take its opposite value to set the disabled state.
@@ -170,7 +173,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
* XXX TODO : all airports should be held in arrays, with all relevant data.
* This should be part of newgrf-airports, i suppose
*/
for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i));
for (i = 0; i < 9; i++) w->SetWidgetDisabledState(i + 7, !HasBit(avail_airports, i));
// select default the coverage area to 'Off' (16)
airport = GetAirport(_selected_airport_type);
@@ -190,16 +193,16 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
case WE_CLICK: {
switch (e->we.click.widget) {
case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
RaiseWindowWidget(w, _selected_airport_type + 7);
w->RaiseWidget(_selected_airport_type + 7);
_selected_airport_type = e->we.click.widget - 7;
LowerWindowWidget(w, _selected_airport_type + 7);
w->LowerWidget(_selected_airport_type + 7);
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
case 16: case 17:
_station_show_coverage = (e->we.click.widget != 16);
SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
w->SetWidgetLoweredState(16, !_station_show_coverage);
w->SetWidgetLoweredState(17, _station_show_coverage);
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;

View File

@@ -4,20 +4,18 @@
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "command.h"
#include "vehicle.h"
#include "articulated_vehicles.h"
#include "engine.h"
#include "train.h"
#include "roadveh.h"
#include "newgrf_callbacks.h"
#include "newgrf_engine.h"
#include "vehicle_func.h"
uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
{
if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
if (!HasBit(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
Vehicle *v = NULL;;
if (!purchase_window) {
@@ -41,7 +39,7 @@ void AddArticulatedParts(Vehicle **vl, VehicleType type)
const Vehicle *v = vl[0];
Vehicle *u = vl[0];
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return;
if (!HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return;
for (uint i = 1; i < MAX_UVALUE(EngineID); i++) {
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, v->engine_type, v);
@@ -56,7 +54,7 @@ void AddArticulatedParts(Vehicle **vl, VehicleType type)
u = u->Next();
EngineID engine_type = GetFirstEngineOfType(type) + GB(callback, 0, 7);
bool flip_image = HASBIT(callback, 7);
bool flip_image = HasBit(callback, 7);
/* get common values from first engine */
u->direction = v->direction;

View File

@@ -5,6 +5,8 @@
#ifndef ARTICULATED_VEHICLES_H
#define ARTICULATED_VEHICLES_H
#include "vehicle_type.h"
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
void AddArticulatedParts(Vehicle **vl, VehicleType type);

38
src/autoreplace_base.h Normal file
View File

@@ -0,0 +1,38 @@
/* $Id$ */
/** @file autoreplace_base.h Base class for autoreplaces/autorenews. */
#ifndef AUTOREPLACE_BASE_H
#define AUTOREPLACE_BASE_H
#include "oldpool.h"
#include "autoreplace_type.h"
/**
* Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
* placed here so the only exception to this rule, the saveload code, can use
* it.
*/
DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000)
/**
* Struct to store engine replacements. DO NOT USE outside of engine.c. Is
* placed here so the only exception to this rule, the saveload code, can use
* it.
*/
struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
EngineID from;
EngineID to;
EngineRenew *next;
GroupID group_id;
EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {}
~EngineRenew() { this->from = INVALID_ENGINE; }
inline bool IsValid() const { return this->from != INVALID_ENGINE; }
};
#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
#endif /* AUTOREPLACE_BASE_H */

View File

@@ -4,11 +4,8 @@
#include "openttd.h"
#include "roadveh.h"
#include "ship.h"
#include "table/strings.h"
#include "functions.h"
#include "news.h"
#include "command.h"
#include "player.h"
#include "player_func.h"
#include "engine.h"
#include "debug.h"
#include "vehicle_gui.h"
@@ -17,8 +14,15 @@
#include "aircraft.h"
#include "cargotype.h"
#include "group.h"
#include "strings.h"
#include "order.h"
#include "strings_func.h"
#include "command_func.h"
#include "vehicle_func.h"
#include "functions.h"
#include "variables.h"
#include "autoreplace_func.h"
#include "table/strings.h"
/*
* move the cargo from one engine to another if possible
@@ -131,7 +135,7 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
const UnitID cached_unitnumber = old_v->unitnumber;
bool new_front = false;
Vehicle *new_v = NULL;
char vehicle_name[32];
char *vehicle_name = NULL;
CargoID replacement_cargo_type;
/* If the vehicle belongs to a group, check if the group is protected from the global autoreplace.
@@ -158,12 +162,10 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
/* We give the player a loan of the same amount as the sell value.
* This is needed in case he needs the income from the sale to build the new vehicle.
* We take it back if building fails or when we really sell the old engine */
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
SubtractMoneyFromPlayer(sell_value);
cost = DoCommand(old_v->tile, new_engine_type, 3, flags, GetCmdBuildVeh(old_v));
if (CmdFailed(cost)) {
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
/* Take back the money we just gave the player */
sell_value.MultiplyCost(-1);
SubtractMoneyFromPlayer(sell_value);
@@ -189,9 +191,9 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
}
}
if (new_v->type == VEH_TRAIN && HASBIT(old_v->u.rail.flags, VRF_REVERSE_DIRECTION) && !IsMultiheaded(new_v) && !(new_v->Next() != NULL && IsArticulatedPart(new_v->Next()))) {
if (new_v->type == VEH_TRAIN && HasBit(old_v->u.rail.flags, VRF_REVERSE_DIRECTION) && !IsMultiheaded(new_v) && !(new_v->Next() != NULL && IsArticulatedPart(new_v->Next()))) {
// we are autorenewing to a single engine, so we will turn it as the old one was turned as well
SETBIT(new_v->u.rail.flags, VRF_REVERSE_DIRECTION);
SetBit(new_v->u.rail.flags, VRF_REVERSE_DIRECTION);
}
if (old_v->type == VEH_TRAIN && !IsFrontEngine(old_v)) {
@@ -239,12 +241,7 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
MoveVehicleCargo(new_v->type == VEH_TRAIN ? new_v->First() : new_v, old_v);
// Get the name of the old vehicle if it has a custom name.
if (!IsCustomName(old_v->string_id)) {
vehicle_name[0] = '\0';
} else {
SetDParam(0, old_v->index);
GetString(vehicle_name, STR_VEHICLE_NAME, lastof(vehicle_name));
}
if (old_v->name != NULL) vehicle_name = strdup(old_v->name);
} else { // flags & DC_EXEC not set
CommandCost tmp_move;
@@ -263,7 +260,6 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
/* Ensure that the player will not end up having negative money while autoreplacing
* This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */
if (CmdFailed(tmp_move) || p->player_money < (cost.GetCost() + total_cost)) {
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
/* Pay back the loan */
sell_value.MultiplyCost(-1);
SubtractMoneyFromPlayer(sell_value);
@@ -273,7 +269,6 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
/* Take back the money we just gave the player just before building the vehicle
* The player will get the same amount now that the sale actually takes place */
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
sell_value.MultiplyCost(-1);
SubtractMoneyFromPlayer(sell_value);
@@ -286,9 +281,10 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
}
/* Transfer the name of the old vehicle */
if ((flags & DC_EXEC) && vehicle_name[0] != '\0') {
if ((flags & DC_EXEC) && vehicle_name != NULL) {
_cmd_text = vehicle_name;
DoCommand(0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE);
free(vehicle_name);
}
return cost;
@@ -333,7 +329,7 @@ CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
v->leave_depot_instantly = false;
for (;;) {
cost = CommandCost();
cost = CommandCost(EXPENSES_NEW_VEHICLES);
w = v;
do {
if (w->type == VEH_TRAIN && IsRearDualheaded(w)) {

103
src/autoreplace_func.h Normal file
View File

@@ -0,0 +1,103 @@
/* $Id$ */
/** @file autoreplace_func.h Functions related to autoreplacing. */
#ifndef AUTOREPLACE_FUNC_H
#define AUTOREPLACE_FUNC_H
#include "autoreplace_type.h"
#include "player_base.h"
/**
* Remove all engine replacement settings for the player.
* @param erl The renewlist for a given player.
* @return The new renewlist for the player.
*/
void RemoveAllEngineReplacement(EngineRenewList *erl);
/**
* Retrieve the engine replacement in a given renewlist for an original engine type.
* @param erl The renewlist to search in.
* @param engine Engine type to be replaced.
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
/**
* Add an engine replacement to the given renewlist.
* @param erl The renewlist to add to.
* @param old_engine The original engine type.
* @param new_engine The replacement engine type.
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
/**
* Remove an engine replacement from a given renewlist.
* @param erl The renewlist from which to remove the replacement
* @param engine The original engine type.
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
/**
* Remove all engine replacement settings for the given player.
* @param p Player.
*/
static inline void RemoveAllEngineReplacementForPlayer(Player *p)
{
RemoveAllEngineReplacement(&p->engine_renew_list);
}
/**
* Retrieve the engine replacement for the given player and original engine type.
* @param p Player.
* @param engine Engine type.
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
{
return EngineReplacement(p->engine_renew_list, engine, group);
}
/**
* Check if a player has a replacement set up for the given engine.
* @param p Player.
* @param engine Engine type to be replaced.
* @return true if a replacement was set up, false otherwise.
*/
static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
{
return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE;
}
/**
* Add an engine replacement for the player.
* @param p Player.
* @param old_engine The original engine type.
* @param new_engine The replacement engine type.
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
{
return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags);
}
/**
* Remove an engine replacement for the player.
* @param p Player.
* @param engine The original engine type.
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags)
{
return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags);
}
#endif /* AUTOREPLACE_FUNC_H */

View File

@@ -5,18 +5,23 @@
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "functions.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "strings.h"
#include "window.h"
#include "gui.h"
#include "command.h"
#include "command_func.h"
#include "variables.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "group.h"
#include "rail.h"
#include "strings_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_func.h"
#include "gfx_func.h"
#include "player_func.h"
#include "widgets/dropdown_func.h"
#include "table/sprites.h"
#include "table/strings.h"
static RailType _railtype_selected_in_replace_gui;
@@ -31,6 +36,15 @@ static const StringID _rail_types_list[] = {
INVALID_STRING_ID
};
static int CDECL TrainEngineNumberSorter(const void *a, const void *b)
{
const EngineID va = *(const EngineID*)a;
const EngineID vb = *(const EngineID*)b;
int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb);
return r;
}
/* General Vehicle GUI based procedures that are independent of vehicle types */
void InitializeVehiclesGuiList()
{
@@ -164,7 +178,7 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
/* Road vehicles can't be replaced by trams and vice-versa */
if (type == VEH_ROAD && HASBIT(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HASBIT(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
if (type == VEH_ROAD && HasBit(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
}
@@ -172,6 +186,7 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
}
WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter);
}
/** Generate the lists
@@ -240,7 +255,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
Player *p = GetPlayer(_local_player);
EngineID selected_id[2];
const GroupID selected_group = WP(w,replaceveh_d).sel_group;
const GroupID selected_group = WP(w, replaceveh_d).sel_group;
selected_id[0] = WP(w, replaceveh_d).sel_engine[0];
selected_id[1] = WP(w, replaceveh_d).sel_engine[1];
@@ -249,7 +264,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
* Either list is empty
* or The selected replacement engine has a replacement (to prevent loops)
* or The right list (new replacement) has the existing replacement vehicle selected */
SetWindowWidgetDisabledState(w, 4,
w->SetWidgetDisabledState(4,
selected_id[0] == INVALID_ENGINE ||
selected_id[1] == INVALID_ENGINE ||
EngineReplacementForPlayer(p, selected_id[1], selected_group) != INVALID_ENGINE ||
@@ -258,7 +273,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
/* Disable the "Stop Replacing" button if:
* The left list (existing vehicle) is empty
* or The selected vehicle has no replacement set up */
SetWindowWidgetDisabledState(w, 6,
w->SetWidgetDisabledState(6,
selected_id[0] == INVALID_ENGINE ||
!EngineHasReplacementForPlayer(p, selected_id[0], selected_group));

19
src/autoreplace_gui.h Normal file
View File

@@ -0,0 +1,19 @@
/* $Id$ */
/** @file autoreplace_gui.h Functions related to the autoreplace GUIs*/
#ifndef AUTOREPLACE_GUI_H
#define AUTOREPLACE_GUI_H
#include "vehicle_type.h"
/**
* When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
* @param type The type of engine
*/
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type);
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
void ShowReplaceVehicleWindow(VehicleType vehicletype);
void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh);
#endif /* AUTOREPLACE_GUI_H */

15
src/autoreplace_type.h Normal file
View File

@@ -0,0 +1,15 @@
/* $Id$ */
/** @file autoreplace_type.h Types related to autoreplacing. */
#ifndef AUTOREPLACE_TYPE_H
#define AUTOREPLACE_TYPE_H
struct EngineRenew;
/**
* A list to group EngineRenew directives together (such as per-player).
*/
typedef EngineRenew* EngineRenewList;
#endif /* AUTOREPLACE_TYPE_H */

View File

@@ -6,6 +6,8 @@
#define AUTOSLOPE_H
#include "depot.h"
#include "settings_type.h"
#include "player_func.h"
/**
* Autoslope check for tiles with an entrance on an edge.

View File

@@ -21,7 +21,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "aystar.h"
#include "helpers.hpp"
#include "core/alloc_func.hpp"
int _aystar_stats_open_size;
int _aystar_stats_closed_size;

View File

@@ -12,6 +12,7 @@
#define AYSTAR_H
#include "queue.h"
#include "tile_type.h"
//#define AYSTAR_DEBUG
enum {

View File

@@ -1,16 +1,20 @@
/* $Id$ */
#include "../stdafx.h"
#include "../zoom.hpp"
#include "../gfx.h"
#include "../core/alloc_func.hpp"
#include "../gfx_func.h"
#include "../zoom_func.h"
#include "../debug.h"
#include "../table/sprites.h"
#include "../video/video_driver.hpp"
#include "32bpp_anim.hpp"
#include "../table/sprites.h"
static FBlitter_32bppAnim iFBlitter_32bppAnim;
void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
if (bp->dst < _screen.dst_ptr || bp->dst > (uint32 *)_screen.dst_ptr + _screen.width * _screen.height) {
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
Blitter_32bppOptimized::Draw(bp, mode, zoom);
return;
@@ -95,6 +99,12 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
{
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColorMappingRect() */
Blitter_32bppOptimized::DrawColorMappingRect(dst, width, height, pal);
return;
}
uint32 *udst = (uint32 *)dst;
uint8 *anim;
@@ -133,7 +143,9 @@ void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, i
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
{
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
/* Set the color in the anim-buffer too */
/* Set the color in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
}
@@ -142,13 +154,20 @@ void Blitter_32bppAnim::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
if (*dst == 0) {
*dst = LookupColourInPalette(color);
/* Set the color in the anim-buffer too */
/* Set the color in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
}
}
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color)
{
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
Blitter_32bppOptimized::DrawRect(video, width, height, color);
return;
}
uint32 color32 = LookupColourInPalette(color);
uint8 *anim_line;
@@ -172,6 +191,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *dst = (uint32 *)video;
uint32 *usrc = (uint32 *)src;
@@ -195,6 +215,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *udst = (uint32 *)dst;
uint32 *src = (uint32 *)video;
@@ -217,6 +238,8 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint8 *dst, *src;
/* We need to scroll the anim-buffer too */
@@ -265,6 +288,7 @@ int Blitter_32bppAnim::BufferSize(int width, int height)
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
{
assert(!_screen_disable_anim);
uint8 *anim = this->anim_buf;
/* Never repaint the transparency pixel */

View File

@@ -1,5 +1,7 @@
/* $Id$ */
#include "../stdafx.h"
#include "../gfx.h"
#include "../gfx_func.h"
#include "32bpp_base.hpp"
void *Blitter_32bppBase::MoveTo(const void *video, int x, int y)

View File

@@ -6,6 +6,7 @@
#define BLITTER_32BPP_BASE_HPP
#include "base.hpp"
#include "../core/bitmath_func.hpp"
class Blitter_32bppBase : public Blitter {
public:

View File

@@ -1,8 +1,9 @@
/* $Id$ */
#include "../stdafx.h"
#include "../zoom.hpp"
#include "../gfx.h"
#include "../zoom_func.h"
#include "../gfx_func.h"
#include "../debug.h"
#include "../table/sprites.h"
#include "32bpp_optimized.hpp"
static FBlitter_32bppOptimized iFBlitter_32bppOptimized;

View File

@@ -1,10 +1,13 @@
/* $Id$ */
#include "../stdafx.h"
#include "../zoom.hpp"
#include "../gfx.h"
#include "../gfx_func.h"
#include "../zoom_func.h"
#include "../debug.h"
#include "../table/sprites.h"
#include "32bpp_simple.hpp"
#include "../table/sprites.h"
static FBlitter_32bppSimple iFBlitter_32bppSimple;
void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)

View File

@@ -1,5 +1,7 @@
/* $Id$ */
#include "../stdafx.h"
#include "../gfx.h"
#include "../gfx_func.h"
#include "8bpp_base.hpp"
void Blitter_8bppBase::DrawColorMappingRect(void *dst, int width, int height, int pal)

View File

@@ -3,9 +3,8 @@
/** @file 8bpp_debug.cpp */
#include "../stdafx.h"
#include "../zoom.hpp"
#include "../gfx.h"
#include "../functions.h"
#include "../zoom_func.h"
#include "../core/random_func.hpp"
#include "8bpp_debug.hpp"
static FBlitter_8bppDebug iFBlitter_8bppDebug;

View File

@@ -3,9 +3,9 @@
/** @file 8bpp_optimized.cpp */
#include "../stdafx.h"
#include "../zoom.hpp"
#include "../gfx.h"
#include "../zoom_func.h"
#include "../debug.h"
#include "../core/alloc_func.hpp"
#include "8bpp_optimized.hpp"
static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
@@ -17,7 +17,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
uint offset = 0;
/* Find the offset of this zoom-level */
offset = ((const uint8 *)bp->sprite)[(int)zoom * 2] | ((const byte *)bp->sprite)[(int)zoom * 2 + 1] << 8;
offset = ((const uint8 *)bp->sprite)[(int)(zoom - ZOOM_LVL_BEGIN) * 2] | ((const byte *)bp->sprite)[(int)(zoom - ZOOM_LVL_BEGIN) * 2 + 1] << 8;
/* Find where to start reading in the source sprite */
src = (const uint8 *)bp->sprite + offset;
@@ -110,9 +110,9 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::All
uint index = 0;
/* Make memory for all zoom-levels */
memory += (int)ZOOM_LVL_END * sizeof(uint16);
for (int i = 0; i < (int)ZOOM_LVL_END; i++) {
memory += UnScaleByZoom(sprite->height, (ZoomLevel)i) * UnScaleByZoom(sprite->width, (ZoomLevel)i);
memory += (int)(ZOOM_LVL_END - ZOOM_LVL_BEGIN) * sizeof(uint16);
for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) {
memory += UnScaleByZoom(sprite->height, i) * UnScaleByZoom(sprite->width, i);
index += 2;
}
@@ -121,7 +121,7 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::All
temp_dst = MallocT<byte>(memory);
/* Make the sprites per zoom-level */
for (int i = 0; i < (int)ZOOM_LVL_END; i++) {
for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) {
/* Store the scaled image */
const SpriteLoader::CommonPixel *src;
@@ -131,19 +131,19 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::All
byte *dst = &temp_dst[index];
for (int y = 0; y < UnScaleByZoom(sprite->height, (ZoomLevel)i); y++) {
for (int y = 0; y < UnScaleByZoom(sprite->height, i); y++) {
uint trans = 0;
uint pixels = 0;
uint last_color = 0;
uint count_index = 0;
uint rx = 0;
src = &sprite->data[ScaleByZoom(y, (ZoomLevel)i) * sprite->width];
src = &sprite->data[ScaleByZoom(y, i) * sprite->width];
for (int x = 0; x < UnScaleByZoom(sprite->width, (ZoomLevel)i); x++) {
for (int x = 0; x < UnScaleByZoom(sprite->width, i); x++) {
uint color = 0;
/* Get the color keeping in mind the zoom-level */
for (int j = 0; j < ScaleByZoom(1, (ZoomLevel)i); j++) {
for (int j = 0; j < ScaleByZoom(1, i); j++) {
if (src->m != 0) color = src->m;
src++;
rx++;

View File

@@ -3,8 +3,7 @@
/** @file 8bpp_simple.cpp */
#include "../stdafx.h"
#include "../zoom.hpp"
#include "../gfx.h"
#include "../zoom_func.h"
#include "8bpp_simple.hpp"
static FBlitter_8bppSimple iFBlitter_8bppSimple;

View File

@@ -5,6 +5,7 @@
#include "../spritecache.h"
#include "../spriteloader/spriteloader.hpp"
#include "../zoom_type.h"
enum BlitterMode {
BM_NORMAL,

View File

@@ -4,8 +4,8 @@
#define BLITTER_FACTORY_HPP
#include "base.hpp"
#include "../string.h"
#include "../debug.h"
#include "../string_func.h"
#include <string>
#include <map>
@@ -41,7 +41,7 @@ protected:
if (name == NULL) return;
this->name = strdup(name);
#if !defined(NDEBUG)
#if !defined(NDEBUG) || defined(WITH_ASSERT)
/* NDEBUG disables asserts and gives a warning: unused variable 'P' */
std::pair<Blitters::iterator, bool> P =
#endif /* !NDEBUG */
@@ -130,4 +130,6 @@ public:
const char *GetName();
};
extern char _ini_blitter[32];
#endif /* BLITTER_FACTORY_HPP */

View File

@@ -1,5 +1,8 @@
/* $Id$ */
/** @file null.cpp A blitter that doesn't blit. */
#include "../stdafx.h"
#include "../variables.h"
#include "null.hpp"
static FBlitter_Null iFBlitter_Null;

View File

@@ -3,11 +3,9 @@
/** @file bmp.cpp */
#include "stdafx.h"
#include "openttd.h"
#include "gfx.h"
#include "bmp.h"
#include "macros.h"
#include "helpers.hpp"
#include "core/bitmath_func.hpp"
#include "core/alloc_func.hpp"
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
{
@@ -354,7 +352,7 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{
assert(info != NULL && data != NULL);
data->bitmap = (byte*)calloc(info->width * info->height, ((info->bpp == 24) ? 3 : 1) * sizeof(byte));
data->bitmap = CallocT<byte>(info->width * info->height * ((info->bpp == 24) ? 3 : 1));
if (data->bitmap == NULL) return false;
/* Load image */

View File

@@ -5,6 +5,8 @@
#ifndef BMP_H
#define BMP_H
#include "gfx_type.h"
struct BmpInfo {
uint32 offset; ///< offset of bitmap data from .bmp file begining
uint32 width; ///< bitmap width

View File

@@ -5,6 +5,10 @@
#ifndef BRIDGE_H
#define BRIDGE_H
#include "gfx_type.h"
#include "direction_type.h"
#include "tile_cmd.h"
enum {
MAX_BRIDGES = 13
};
@@ -37,4 +41,8 @@ static inline const Bridge *GetBridge(uint i)
void DrawBridgeMiddle(const TileInfo *ti);
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
int CalcBridgeLenCostFactor(int x);
#endif /* BRIDGE_H */

View File

@@ -4,26 +4,34 @@
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
#include "strings.h"
#include "functions.h"
#include "map.h"
#include "window.h"
#include "gui.h"
#include "viewport.h"
#include "gfx.h"
#include "command.h"
#include "sound.h"
#include "window_gui.h"
#include "command_func.h"
#include "economy_func.h"
#include "variables.h"
#include "bridge.h"
#include "strings_func.h"
#include "window_func.h"
#include "sound_func.h"
#include "map_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "table/strings.h"
static struct BridgeData {
uint8 last_size;
uint count;
TileIndex start_tile;
TileIndex end_tile;
byte type;
byte indexes[MAX_BRIDGES];
uint8 type;
uint8 indexes[MAX_BRIDGES];
Money costs[MAX_BRIDGES];
BridgeData()
: last_size(4)
, count(0)
{};
} _bridgedata;
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
@@ -39,26 +47,52 @@ static void BuildBridge(Window *w, int i)
CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
}
/* Names of the build bridge selection window */
enum BuildBridgeSelectionWidgets {
BBSW_CLOSEBOX = 0,
BBSW_CAPTION,
BBSW_BRIDGE_LIST,
BBSW_SCROLLBAR,
BBSW_RESIZEBOX
};
static void BuildBridgeWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT:
case WE_CREATE:
w->resize.step_height = 22;
w->vscroll.count = _bridgedata.count;
if (_bridgedata.last_size <= 4) {
w->vscroll.cap = 4;
} else {
/* Resize the bridge selection window if we used a bigger one the last time */
w->vscroll.cap = (w->vscroll.count > _bridgedata.last_size) ? _bridgedata.last_size : w->vscroll.count;
ResizeWindow(w, 0, (w->vscroll.cap - 4) * w->resize.step_height);
w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
}
break;
case WE_PAINT: {
DrawWindowWidgets(w);
for (uint i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) {
uint y = 15;
for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) {
const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]];
SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
SetDParam(1, b->speed * 10 / 16);
SetDParam(0, b->material);
DrawSprite(b->sprite, b->pal, 3, 15 + i * 22);
DrawString(44, 15 + i * 22 , STR_500D, TC_FROMSTRING);
DrawSprite(b->sprite, b->pal, 3, y);
DrawString(44, y, STR_500D, TC_FROMSTRING);
y += w->resize.step_height;
}
break;
}
case WE_KEYPRESS: {
uint i = e->we.keypress.keycode - '1';
const uint8 i = e->we.keypress.keycode - '1';
if (i < 9 && i < _bridgedata.count) {
e->we.keypress.cont = false;
BuildBridge(w, i);
@@ -68,44 +102,61 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e)
}
case WE_CLICK:
if (e->we.click.widget == 2) {
uint ind = ((int)e->we.click.pt.y - 14) / 22;
if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count)
BuildBridge(w, ind);
if (e->we.click.widget == BBSW_BRIDGE_LIST) {
uint ind = ((int)e->we.click.pt.y - 14) / w->resize.step_height;
if (ind < w->vscroll.cap) {
ind += w->vscroll.pos;
if (ind < _bridgedata.count) {
BuildBridge(w, ind);
}
}
}
break;
case WE_RESIZE:
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
SetVScrollCount(w, _bridgedata.count);
_bridgedata.last_size = w->vscroll.cap;
break;
}
}
/* Widget definition for the rail bridge selection window */
static const Widget _build_bridge_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BBSW_CLOSEBOX
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BBSW_CAPTION
{ WWT_MATRIX, RESIZE_BOTTOM, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK}, // BBSW_BRIDGE_LIST
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 7, 188, 199, 14, 89, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
{ WWT_RESIZEBOX, RESIZE_TB, 7, 188, 199, 90, 101, 0x0, STR_RESIZE_BUTTON}, // BBSW_RESIZEBOX
{ WIDGETS_END},
};
/* Window definition for the rail bridge selection window */
static const WindowDesc _build_bridge_desc = {
WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
_build_bridge_widgets,
BuildBridgeWndProc
};
/* Widget definition for the road bridge selection window */
static const Widget _build_road_bridge_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BBSW_CLOSEBOX
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BBSW_CAPTION
{ WWT_MATRIX, RESIZE_BOTTOM, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK}, // BBSW_BRIDGE_LIST
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 7, 188, 199, 14, 89, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
{ WWT_RESIZEBOX, RESIZE_TB, 7, 188, 199, 90, 101, 0x0, STR_RESIZE_BUTTON}, // BBSW_RESIZEBOX
{ WIDGETS_END},
};
/* Window definition for the road bridge selection window */
static const WindowDesc _build_road_bridge_desc = {
WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
_build_road_bridge_widgets,
BuildBridgeWndProc
};
@@ -113,52 +164,46 @@ static const WindowDesc _build_road_bridge_desc = {
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
{
uint j = 0;
CommandCost ret;
StringID errmsg;
DeleteWindowById(WC_BUILD_BRIDGE, 0);
_bridgedata.type = bridge_type;
_bridgedata.start_tile = start;
_bridgedata.end_tile = end;
errmsg = INVALID_STRING_ID;
// only query bridge building possibility once, result is the same for all bridges!
// returns CMD_ERROR on failure, and price on success
ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
/* only query bridge building possibility once, result is the same for all bridges!
* returns CMD_ERROR on failure, and price on success */
StringID errmsg = INVALID_STRING_ID;
CommandCost ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
uint8 j = 0;
if (CmdFailed(ret)) {
errmsg = _error_message;
} else {
// check which bridges can be built
// get absolute bridge length
// length of the middle parts of the bridge
int bridge_len = GetBridgeLength(start, end);
// total length of bridge
int tot_bridgedata_len = bridge_len + 2;
/* check which bridges can be built
* get absolute bridge length
* length of the middle parts of the bridge */
const uint bridge_len = GetBridgeLength(start, end);
/* total length of bridge */
const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes
/* loop for all bridgetypes */
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) {
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
/* bridge is accepted, add to list */
const Bridge *b = &_bridge[bridge_type];
// bridge is accepted, add to list
// add to terraforming & bulldozing costs the cost of the bridge itself (not computed with DC_QUERY_COST)
/* Add to terraforming & bulldozing costs the cost of the
* bridge itself (not computed with DC_QUERY_COST) */
_bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
_bridgedata.indexes[j] = bridge_type;
j++;
}
}
_bridgedata.count = j;
}
_bridgedata.count = j;
if (j != 0) {
Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
w->vscroll.cap = 4;
w->vscroll.count = (byte)j;
AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
} else {
ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
}

View File

@@ -8,6 +8,7 @@
#include "bridge.h"
#include "variables.h"
#include "landscape.h"
#include "tunnelbridge_map.h"
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
@@ -17,7 +18,7 @@ TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
dir = ReverseDiagDir(dir);
do {
tile += delta;
} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir);
} while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
return tile;
}
@@ -38,14 +39,14 @@ TileIndex GetSouthernBridgeEnd(TileIndex t)
TileIndex GetOtherBridgeEnd(TileIndex tile)
{
assert(IsBridgeTile(tile));
return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
}
uint GetBridgeHeight(TileIndex t)
{
uint h;
Slope tileh = GetTileSlope(t, &h);
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
/* one height level extra for the ramp */
return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);

View File

@@ -5,12 +5,9 @@
#ifndef BRIDGE_MAP_H
#define BRIDGE_MAP_H
#include "direction.h"
#include "macros.h"
#include "map.h"
#include "rail.h"
#include "direction_func.h"
#include "rail_type.h"
#include "road_map.h"
#include "tile.h"
/**
@@ -22,7 +19,7 @@
static inline bool IsBridge(TileIndex t)
{
assert(IsTileType(t, MP_TUNNELBRIDGE));
return HASBIT(_m[t].m5, 7);
return HasBit(_m[t].m5, 7);
}
/**
@@ -64,7 +61,6 @@ static inline bool IsBridgeAbove(TileIndex t)
return GB(_m[t].m6, 6, 2) != 0;
}
/**
* Determines the type of bridge on a tile
* @param t The tile to analyze
@@ -77,20 +73,6 @@ static inline uint GetBridgeType(TileIndex t)
return GB(_m[t].m2, 4, 4);
}
/**
* Get the direction pointing onto the bridge
* @param t The tile to analyze
* @pre IsBridgeTile(t)
* @return the above mentionned direction
*/
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
{
assert(IsBridgeTile(t));
return (DiagDirection)GB(_m[t].m5, 0, 2);
}
/**
* Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
* @param t The tile to analyze
@@ -103,45 +85,6 @@ static inline Axis GetBridgeAxis(TileIndex t)
return (Axis)(GB(_m[t].m6, 6, 2) - 1);
}
/**
* Get the transport type of the bridge's ramp.
* @param t The ramp tile to analyze
* @pre IsBridgeTile(t)
* @return the transport type of the bridge
*/
static inline TransportType GetBridgeTransportType(TileIndex t)
{
assert(IsBridgeTile(t));
return (TransportType)GB(_m[t].m5, 2, 2);
}
/**
* Does the bridge ramp lie in a snow or desert area?
* @param t The ramp tile to analyze
* @pre IsBridgeTile(t)
* @return true if and only if in a snow or desert area
*/
static inline bool HasBridgeSnowOrDesert(TileIndex t)
{
assert(IsBridgeTile(t));
return HASBIT(_m[t].m4, 7);
}
/**
* Sets whether the bridge ramp lies in a snow or desert area.
* @param t The ramp tile to set (un)make a snow/desert area
* @param snow_or_desert Make (true) or unmake the tile a snow/desert area
* @pre IsBridgeTile(t)
*/
static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
{
assert(IsBridgeTile(t));
SB(_m[t].m4, 7, 1, snow_or_desert);
}
/**
* Finds the end of a bridge in the specified direction starting at a middle tile
* @param t the bridge tile to find the bridge ramp for
@@ -184,10 +127,9 @@ uint GetBridgeHeight(TileIndex tile);
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
{
assert(MayHaveBridgeAbove(t));
CLRBIT(_m[t].m6, 6 + a);
ClrBit(_m[t].m6, 6 + a);
}
/**
* Removes bridges from the given, that is bridges along the X and Y axis.
* @param t the tile to remove the bridge from
@@ -208,7 +150,7 @@ static inline void ClearBridgeMiddle(TileIndex t)
static inline void SetBridgeMiddle(TileIndex t, Axis a)
{
assert(MayHaveBridgeAbove(t));
SETBIT(_m[t].m6, 6 + a);
SetBit(_m[t].m6, 6 + a);
}
/**

View File

@@ -9,28 +9,47 @@
#include "ship.h"
#include "aircraft.h"
#include "debug.h"
#include "functions.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "window.h"
#include "gui.h"
#include "vehicle.h"
#include "articulated_vehicles.h"
#include "gfx.h"
#include "textbuf_gui.h"
#include "station.h"
#include "command.h"
#include "command_func.h"
#include "engine.h"
#include "player.h"
#include "player_func.h"
#include "depot.h"
#include "airport.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "date.h"
#include "strings.h"
#include "cargotype.h"
#include "group.h"
#include "road_map.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "settings_type.h"
#include "gfx_func.h"
#include "widgets/dropdown_func.h"
#include "table/sprites.h"
#include "table/strings.h"
struct buildvehicle_d {
VehicleType vehicle_type;
union {
RailTypeByte railtype;
AirportFTAClass::Flags flags;
RoadTypes roadtypes;
} filter;
byte sel_index; ///< deprecated value, used for 'unified' ship and road
bool descending_sort_order;
byte sort_criteria;
bool regenerate_list;
EngineID sel_engine;
EngineID rename_engine;
EngineList eng_list;
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
enum BuildVehicleWidgets {
BUILD_VEHICLE_WIDGET_CLOSEBOX = 0,
@@ -269,6 +288,38 @@ static int CDECL TrainEnginesThenWagonsSorter(const void *a, const void *b)
return _internal_sort_order ? -r : r;
}
/* Road vehicle sorting functions */
static int CDECL RoadVehEngineCostSorter(const void *a, const void *b)
{
int va = RoadVehInfo(*(const EngineID*)a)->base_cost;
int vb = RoadVehInfo(*(const EngineID*)b)->base_cost;
int r = va - vb;
return _internal_sort_order ? -r : r;
}
static int CDECL RoadVehEngineSpeedSorter(const void *a, const void *b)
{
int va = RoadVehInfo(*(const EngineID*)a)->max_speed;
int vb = RoadVehInfo(*(const EngineID*)b)->max_speed;
int r = va - vb;
return _internal_sort_order ? -r : r;
}
static int CDECL RoadVehEngineRunningCostSorter(const void *a, const void *b)
{
const int va = RoadVehInfo(*(const EngineID*)a)->running_cost;
const int vb = RoadVehInfo(*(const EngineID*)b)->running_cost;
const int r = va - vb;
if (r == 0) {
/* Use EngineID to sort instead since we want consistent sorting */
return EngineNumberSorter(a, b);
}
return _internal_sort_order ? -r : r;
}
static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b)
{
int va = RoadVehInfo(*(const EngineID*)a)->capacity;
@@ -282,6 +333,38 @@ static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b)
return _internal_sort_order ? -r : r;
}
/* Road vehicle sorting functions */
static int CDECL ShipEngineCostSorter(const void *a, const void *b)
{
int va = ShipVehInfo(*(const EngineID*)a)->base_cost;
int vb = ShipVehInfo(*(const EngineID*)b)->base_cost;
int r = va - vb;
return _internal_sort_order ? -r : r;
}
static int CDECL ShipEngineSpeedSorter(const void *a, const void *b)
{
int va = ShipVehInfo(*(const EngineID*)a)->max_speed;
int vb = ShipVehInfo(*(const EngineID*)b)->max_speed;
int r = va - vb;
return _internal_sort_order ? -r : r;
}
static int CDECL ShipEngineRunningCostSorter(const void *a, const void *b)
{
const int va = ShipVehInfo(*(const EngineID*)a)->running_cost;
const int vb = ShipVehInfo(*(const EngineID*)b)->running_cost;
const int r = va - vb;
if (r == 0) {
/* Use EngineID to sort instead since we want consistent sorting */
return EngineNumberSorter(a, b);
}
return _internal_sort_order ? -r : r;
}
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
{
int va = ShipVehInfo(*(const EngineID*)a)->capacity;
@@ -367,15 +450,21 @@ static EngList_SortTypeFunction * const _sorter[][10] = {{
}, {
/* Road vehicles */
&EngineNumberSorter,
&RoadVehEngineCostSorter,
&RoadVehEngineSpeedSorter,
&EngineIntroDateSorter,
&EngineNameSorter,
&RoadVehEngineRunningCostSorter,
&EngineReliabilitySorter,
&RoadVehEngineCapacitySorter,
}, {
/* Ships */
&EngineNumberSorter,
&ShipEngineCostSorter,
&ShipEngineSpeedSorter,
&EngineIntroDateSorter,
&EngineNameSorter,
&ShipEngineRunningCostSorter,
&EngineReliabilitySorter,
&ShipEngineCapacitySorter,
}, {
@@ -406,16 +495,22 @@ static const StringID _sort_listing[][11] = {{
}, {
/* Road vehicles */
STR_ENGINE_SORT_ENGINE_ID,
STR_ENGINE_SORT_COST,
STR_SORT_BY_MAX_SPEED,
STR_ENGINE_SORT_INTRO_DATE,
STR_SORT_BY_DROPDOWN_NAME,
STR_ENGINE_SORT_RUNNING_COST,
STR_SORT_BY_RELIABILITY,
STR_ENGINE_SORT_CARGO_CAPACITY,
INVALID_STRING_ID
}, {
/* Ships */
STR_ENGINE_SORT_ENGINE_ID,
STR_ENGINE_SORT_COST,
STR_SORT_BY_MAX_SPEED,
STR_ENGINE_SORT_INTRO_DATE,
STR_SORT_BY_DROPDOWN_NAME,
STR_ENGINE_SORT_RUNNING_COST,
STR_SORT_BY_RELIABILITY,
STR_ENGINE_SORT_CARGO_CAPACITY,
INVALID_STRING_ID
@@ -667,7 +762,7 @@ int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
/* Figure out what train EngineIDs to put in the list */
static void GenerateBuildTrainList(Window *w)
{
EngineID eid, sel_id;
EngineID sel_id = INVALID_ENGINE;
int num_engines = 0;
int num_wagons = 0;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -680,7 +775,7 @@ static void GenerateBuildTrainList(Window *w)
* Also check to see if the previously selected engine is still available,
* and if not, reset selection to INVALID_ENGINE. This could be the case
* when engines become obsolete and are removed */
for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
for (EngineID eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
const RailVehicleInfo *rvi = RailVehInfo(eid);
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue;
@@ -713,16 +808,14 @@ static void GenerateBuildTrainList(Window *w)
/* Figure out what road vehicle EngineIDs to put in the list */
static void GenerateBuildRoadVehList(Window *w)
{
EngineID eid, sel_id;
EngineID sel_id = INVALID_ENGINE;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
EngList_RemoveAll(&bv->eng_list);
sel_id = INVALID_ENGINE;
for (eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
for (EngineID eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
if (!HASBIT(bv->filter.roadtypes, HASBIT(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
if (!HasBit(bv->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
EngList_Add(&bv->eng_list, eid);
if (eid == bv->sel_engine) sel_id = eid;
@@ -733,14 +826,12 @@ static void GenerateBuildRoadVehList(Window *w)
/* Figure out what ship EngineIDs to put in the list */
static void GenerateBuildShipList(Window *w)
{
EngineID eid, sel_id;
EngineID sel_id = INVALID_ENGINE;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
EngList_RemoveAll(&bv->eng_list);
sel_id = INVALID_ENGINE;
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
for (EngineID eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
EngList_Add(&bv->eng_list, eid);
@@ -752,7 +843,7 @@ static void GenerateBuildShipList(Window *w)
/* Figure out what aircraft EngineIDs to put in the list */
static void GenerateBuildAircraftList(Window *w)
{
EngineID eid, sel_id;
EngineID sel_id = INVALID_ENGINE;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
EngList_RemoveAll(&bv->eng_list);
@@ -761,8 +852,7 @@ static void GenerateBuildAircraftList(Window *w)
* Also check to see if the previously selected plane is still available,
* and if not, reset selection to INVALID_ENGINE. This could be the case
* when planes become obsolete and are removed */
sel_id = INVALID_ENGINE;
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
for (EngineID eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
if (w->window_number > VEH_END && !CanAircraftUseStation(eid, w->window_number)) continue;
@@ -888,7 +978,7 @@ static void DrawBuildVehicleWindow(Window *w)
const buildvehicle_d *bv = &WP(w, buildvehicle_d);
uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
w->SetWidgetDisabledState(BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
SetVScrollCount(w, EngList_Count(&bv->eng_list));
SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles

View File

@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "callback_table.h"
#include "functions.h"
/* If you add a callback for DoCommandP, also add the callback in here
* see below for the full list!

View File

@@ -5,7 +5,7 @@
#ifndef CALLBACK_TABLE_H
#define CALLBACK_TABLE_H
#include "command.h"
#include "command_type.h"
extern CommandCallback *_callback_table[];
extern const int _callback_table_count;

59
src/cargo_type.h Normal file
View File

@@ -0,0 +1,59 @@
/* $Id$ */
/** @file cargo_type.h Types related to cargos... */
#ifndef CARGO_TYPE_H
#define CARGO_TYPE_H
typedef byte CargoID;
enum {
// Temperate
CT_PASSENGERS = 0,
CT_COAL = 1,
CT_MAIL = 2,
CT_OIL = 3,
CT_LIVESTOCK = 4,
CT_GOODS = 5,
CT_GRAIN = 6,
CT_WOOD = 7,
CT_IRON_ORE = 8,
CT_STEEL = 9,
CT_VALUABLES = 10,
// Arctic
CT_WHEAT = 6,
CT_HILLY_UNUSED = 8,
CT_PAPER = 9,
CT_GOLD = 10,
CT_FOOD = 11,
// Tropic
CT_RUBBER = 1,
CT_FRUIT = 4,
CT_MAIZE = 6,
CT_COPPER_ORE = 8,
CT_WATER = 9,
CT_DIAMONDS = 10,
// Toyland
CT_SUGAR = 1,
CT_TOYS = 3,
CT_BATTERIES = 4,
CT_CANDY = 5,
CT_TOFFEE = 6,
CT_COLA = 7,
CT_COTTON_CANDY = 8,
CT_BUBBLES = 9,
CT_PLASTIC = 10,
CT_FIZZY_DRINKS = 11,
NUM_CARGO = 32,
CT_NO_REFIT = 0xFE,
CT_INVALID = 0xFF
};
typedef uint AcceptedCargo[NUM_CARGO];
#endif /* OPENTTD_H */

View File

@@ -5,6 +5,8 @@
#ifndef CARGOPACKET_H
#define CARGOPACKET_H
#include "economy_type.h"
#include "tile_type.h"
#include <list>
typedef uint32 CargoPacketID;

View File

@@ -4,12 +4,12 @@
#include "stdafx.h"
#include "openttd.h"
#include "macros.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "newgrf_cargo.h"
#include "cargotype.h"
#include "core/bitmath_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
#include "table/cargo_const.h"
CargoSpec _cargo[NUM_CARGO];
@@ -37,7 +37,7 @@ void SetupCargoForClimate(LandscapeID l)
if (cl < lengthof(_default_cargo)) {
/* Copy the indexed cargo */
_cargo[i] = _default_cargo[cl];
SETBIT(_cargo_mask, i);
if (_cargo[i].bitnum != INVALID_CARGO) SetBit(_cargo_mask, i);
continue;
}
@@ -48,7 +48,7 @@ void SetupCargoForClimate(LandscapeID l)
_cargo[i] = _default_cargo[j];
/* Populate the available cargo mask */
SETBIT(_cargo_mask, i);
SetBit(_cargo_mask, i);
break;
}
}

View File

@@ -5,6 +5,9 @@
#ifndef CARGOTYPE_H
#define CARGOTYPE_H
#include "cargo_type.h"
#include "gfx_type.h"
#include "newgrf_string_type.h"
typedef uint32 CargoLabel;
@@ -33,11 +36,11 @@ struct CargoSpec {
uint16 multipliertowngrowth;
uint8 callback_mask;
StringID name;
StringID name_single;
StringID units_volume;
StringID quantifier;
StringID abbrev;
GRFMappedStringID name;
GRFMappedStringID name_single;
GRFMappedStringID units_volume;
GRFMappedStringID quantifier;
GRFMappedStringID abbrev;
SpriteID sprite;

View File

@@ -5,455 +5,35 @@
#include "stdafx.h"
#include "openttd.h"
#include "clear_map.h"
#include "rail_map.h"
#include "table/strings.h"
#include "functions.h"
#include "map.h"
#include "player.h"
#include "tile.h"
#include "viewport.h"
#include "command.h"
#include "tunnel_map.h"
#include "bridge_map.h"
#include "command_func.h"
#include "bridge.h"
#include "landscape.h"
#include "variables.h"
#include "table/sprites.h"
#include "unmovable_map.h"
#include "genworld.h"
#include "industry.h"
#include "water_map.h"
/*
* In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player).
* The maximal amount of height modifications is archieved when raising a complete flat land from sea level to MAX_TILE_HEIGHT or vice versa.
* This affects all corners with a manhatten distance smaller than MAX_TILE_HEIGHT to one of the initial 4 corners.
* Their maximal amount is computed to 4 * \sum_{i=1}^{h_max} i = 2 * h_max * (h_max + 1).
*/
static const int TERRAFORMER_MODHEIGHT_SIZE = 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 1);
/*
* The maximal amount of affected tiles (i.e. the tiles that incident with one of the corners above, is computed similiar to
* 1 + 4 * \sum_{i=1}^{h_max} (i+1) = 1 + 2 * h_max + (h_max + 3).
*/
static const int TERRAFORMER_TILE_TABLE_SIZE = 1 + 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 3);
struct TerraformerHeightMod {
TileIndex tile; ///< Referenced tile.
byte height; ///< New TileHeight (height of north corner) of the tile.
};
struct TerraformerState {
int modheight_count; ///< amount of entries in "modheight".
int tile_table_count; ///< amount of entries in "tile_table".
/**
* Dirty tiles, i.e.\ at least one corner changed.
*
* This array contains the tiles which are or will be marked as dirty.
*
* @ingroup dirty
*/
TileIndex tile_table[TERRAFORMER_TILE_TABLE_SIZE];
TerraformerHeightMod modheight[TERRAFORMER_MODHEIGHT_SIZE]; ///< Height modifications.
};
/**
* Gets the TileHeight (height of north corner) of a tile as of current terraforming progress.
*
* @param ts TerraformerState.
* @param tile Tile.
* @return TileHeight.
*/
static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
{
TerraformerHeightMod *mod = ts->modheight;
int count;
for (count = ts->modheight_count; count != 0; count--, mod++) {
if (mod->tile == tile) return mod->height;
}
/* TileHeight unchanged so far, read value from map. */
return TileHeight(tile);
}
/**
* Stores the TileHeight (height of north corner) of a tile in a TerraformerState.
*
* @param ts TerraformerState.
* @param tile Tile.
* @param height New TileHeight.
*/
static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height)
{
/* Find tile in the "modheight" table.
* Note: In a normal user-terraform command the tile will not be found in the "modheight" table.
* But during house- or industry-construction multiple corners can be terraformed at once. */
TerraformerHeightMod *mod = ts->modheight;
int count = ts->modheight_count;
while ((count > 0) && (mod->tile != tile)) {
mod++;
count--;
}
/* New entry? */
if (count == 0) {
assert(ts->modheight_count < TERRAFORMER_MODHEIGHT_SIZE);
ts->modheight_count++;
}
/* Finally store the new value */
mod->tile = tile;
mod->height = (byte)height;
}
/**
* Adds a tile to the "tile_table" in a TerraformerState.
*
* @param ts TerraformerState.
* @param tile Tile.
* @ingroup dirty
*/
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
{
int count;
TileIndex *t;
count = ts->tile_table_count;
for (t = ts->tile_table; count != 0; count--, t++) {
if (*t == tile) return;
}
assert(ts->tile_table_count < TERRAFORMER_TILE_TABLE_SIZE);
ts->tile_table[ts->tile_table_count++] = tile;
}
/**
* Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState.
*
* @param ts TerraformerState.
* @param tile Tile.
* @ingroup dirty
*/
static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
{
TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, 0));
TerraformAddDirtyTile(ts, tile);
}
/**
* Terraform the north corner of a tile to a specific height.
*
* @param ts TerraformerState.
* @param tile Tile.
* @param height Aimed height.
* @param return Error code or cost.
*/
static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
{
CommandCost total_cost = CommandCost();
assert(tile < MapSize());
/* Check range of destination height */
if (height < 0) return_cmd_error(STR_1003_ALREADY_AT_SEA_LEVEL);
if (height > MAX_TILE_HEIGHT) return_cmd_error(STR_1004_TOO_HIGH);
/*
* Check if the terraforming has any effect.
* This can only be true, if multiple corners of the start-tile are terraformed (i.e. the terraforming is done by towns/industries etc.).
* In this case the terraforming should fail. (Don't know why.)
*/
if (height == TerraformGetHeightOfTile(ts, tile)) return CMD_ERROR;
/* Check "too close to edge of map" */
uint x = TileX(tile);
uint y = TileY(tile);
if ((x <= 1) || (y <= 1) || (x >= MapMaxX() - 1) || (y >= MapMaxY() - 1)) {
/*
* Determine a sensible error tile
* Note: If x and y are both zero this will disable the error tile. (Tile 0 cannot be highlighted :( )
*/
if ((x == 1) && (y != 0)) x = 0;
if ((y == 1) && (x != 0)) y = 0;
_terraform_err_tile = TileXY(x, y);
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
}
/* Mark incident tiles, that are involved in the terraforming */
TerraformAddDirtyTileAround(ts, tile);
/* Store the height modification */
TerraformSetHeightOfTile(ts, tile, height);
/* Increment cost */
total_cost.AddCost(_price.terraform);
/* Recurse to neighboured corners if height difference is larger than 1 */
{
const TileIndexDiffC *ttm;
static const TileIndexDiffC _terraform_tilepos[] = {
{ 1, 0}, // move to tile in SE
{-2, 0}, // undo last move, and move to tile in NW
{ 1, 1}, // undo last move, and move to tile in SW
{ 0, -2} // undo last move, and move to tile in NE
};
for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
tile += ToTileIndexDiff(*ttm);
/* Get TileHeight of neighboured tile as of current terraform progress */
int r = TerraformGetHeightOfTile(ts, tile);
int height_diff = height - r;
/* Is the height difference to the neighboured corner greater than 1? */
if (abs(height_diff) > 1) {
/* Terraform the neighboured corner. The resulting height difference should be 1. */
height_diff += (height_diff < 0 ? 1 : -1);
CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
if (CmdFailed(cost)) return cost;
total_cost.AddCost(cost);
}
}
}
return total_cost;
}
/** Terraform land
* @param tile tile to terraform
* @param flags for this command type
* @param p1 corners to terraform (SLOPE_xxx)
* @param p2 direction; eg up (non-zero) or down (zero)
* @return error or cost of terraforming
*/
CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
TerraformerState ts;
CommandCost total_cost = CommandCost();
int direction = (p2 != 0 ? 1 : -1);
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
_terraform_err_tile = 0;
ts.modheight_count = ts.tile_table_count = 0;
/* Make an extra check for map-bounds cause we add tiles to the originating tile */
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
/* Compute the costs and the terraforming result in a model of the landscape */
if ((p1 & SLOPE_W) != 0) {
TileIndex t = tile + TileDiffXY(1, 0);
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
if (CmdFailed(cost)) return cost;
total_cost.AddCost(cost);
}
if ((p1 & SLOPE_S) != 0) {
TileIndex t = tile + TileDiffXY(1, 1);
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
if (CmdFailed(cost)) return cost;
total_cost.AddCost(cost);
}
if ((p1 & SLOPE_E) != 0) {
TileIndex t = tile + TileDiffXY(0, 1);
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
if (CmdFailed(cost)) return cost;
total_cost.AddCost(cost);
}
if ((p1 & SLOPE_N) != 0) {
TileIndex t = tile + TileDiffXY(0, 0);
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
if (CmdFailed(cost)) return cost;
total_cost.AddCost(cost);
}
/* Check if the terraforming is valid wrt. tunnels, bridges and objects on the surface */
{
int count;
TileIndex *ti = ts.tile_table;
for (count = ts.tile_table_count; count != 0; count--, ti++) {
TileIndex tile = *ti;
/* Find new heights of tile corners */
uint z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
uint z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
uint z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
uint z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
/* Find min and max height of tile */
uint z_min = min(min(z_N, z_W), min(z_S, z_E));
uint z_max = max(max(z_N, z_W), max(z_S, z_E));
/* Compute tile slope */
uint tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT);
if (z_W > z_min) tileh += SLOPE_W;
if (z_S > z_min) tileh += SLOPE_S;
if (z_E > z_min) tileh += SLOPE_E;
if (z_N > z_min) tileh += SLOPE_N;
/* Check if bridge would take damage */
if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) &&
GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) {
_terraform_err_tile = tile; // highlight the tile under the bridge
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
}
/* Check if tunnel would take damage */
if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
_terraform_err_tile = tile; // highlight the tile above the tunnel
return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
}
/* Check tiletype-specific things, and add extra-cost */
CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, (Slope) tileh);
if (CmdFailed(cost)) {
_terraform_err_tile = tile;
return cost;
}
total_cost.AddCost(cost);
}
}
if (flags & DC_EXEC) {
/* change the height */
{
int count;
TerraformerHeightMod *mod;
mod = ts.modheight;
for (count = ts.modheight_count; count != 0; count--, mod++) {
TileIndex til = mod->tile;
SetTileHeight(til, mod->height);
}
}
/* finally mark the dirty tiles dirty */
{
int count;
TileIndex *ti = ts.tile_table;
for (count = ts.tile_table_count; count != 0; count--, ti++) {
MarkTileDirtyByTile(*ti);
}
}
}
return total_cost;
}
/** Levels a selected (rectangle) area of land
* @param tile end tile of area-drag
* @param flags for this command type
* @param p1 start tile of area drag
* @param p2 unused
* @return error or cost of terraforming
*/
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int size_x, size_y;
int ex;
int ey;
int sx, sy;
uint h, curh;
CommandCost money;
CommandCost ret;
CommandCost cost;
if (p1 >= MapSize()) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
/* remember level height */
h = TileHeight(p1);
/* make sure sx,sy are smaller than ex,ey */
ex = TileX(tile);
ey = TileY(tile);
sx = TileX(p1);
sy = TileY(p1);
if (ex < sx) Swap(ex, sx);
if (ey < sy) Swap(ey, sy);
tile = TileXY(sx, sy);
size_x = ex - sx + 1;
size_y = ey - sy + 1;
money.AddCost(GetAvailableMoneyForCommand());
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
curh = TileHeight(tile2);
while (curh != h) {
ret = DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
if (CmdFailed(ret)) break;
if (flags & DC_EXEC) {
money.AddCost(-ret.GetCost());
if (money.GetCost() < 0) {
_additional_cash_required = ret.GetCost();
return cost;
}
DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
}
cost.AddCost(ret);
curh += (curh > h) ? -1 : 1;
}
} END_TILE_LOOP(tile2, size_x, size_y, tile)
return (cost.GetCost() == 0) ? CMD_ERROR : cost;
}
/** Purchase a land area. Actually you only purchase one tile, so
* the name is a bit confusing ;p
* @param tile the tile the player is purchasing
* @param flags for this command type
* @param p1 unused
* @param p2 unused
* @return error of cost of operation
*/
CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
CommandCost cost;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
}
cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
if (flags & DC_EXEC) {
MakeOwnedLand(tile, _current_player);
MarkTileDirtyByTile(tile);
}
return cost.AddCost(_price.purchase_land * 10);
}
#include "tile_cmd.h"
#include "functions.h"
#include "economy_func.h"
#include "viewport_func.h"
#include "settings_type.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "table/clear_land.h"
static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
{
static const Money* clear_price_table[] = {
&_price.clear_1,
&_price.purchase_land,
&_price.clear_2,
&_price.clear_3,
&_price.purchase_land,
&_price.purchase_land,
&_price.clear_2, // XXX unused?
&_price.clear_grass,
&_price.clear_roughland,
&_price.clear_rocks,
&_price.clear_fields,
&_price.clear_roughland,
&_price.clear_roughland,
};
CommandCost price;
CommandCost price(EXPENSES_CONSTRUCTION);
if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) {
price.AddCost(*clear_price_table[GetClearGround(tile)]);
@@ -464,33 +44,6 @@ static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
return price;
}
/** Sell a land area. Actually you only sell one tile, so
* the name is a bit confusing ;p
* @param tile the tile the player is selling
* @param flags for this command type
* @param p1 unused
* @param p2 unused
* @return error or cost of operation
*/
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (flags & DC_EXEC) DoClearSquare(tile);
return CommandCost(- _price.purchase_land * 2);
}
#include "table/clear_land.h"
void DrawClearLandTile(const TileInfo *ti, byte set)
{
DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19, PAL_NONE);

View File

@@ -5,9 +5,8 @@
#ifndef CLEAR_MAP_H
#define CLEAR_MAP_H
#include "macros.h"
#include "tile.h"
#include "bridge_map.h"
#include "industry_type.h"
/**
* Ground types. Valid densities in comments after the enum.

View File

@@ -3,13 +3,12 @@
#ifndef CMD_HELPER_H
#define CMD_HELPER_H
#include "direction.h"
#include "macros.h"
#include "road.h"
#include "direction_type.h"
#include "road_type.h"
template<uint N> static inline void ExtractValid();
template<> static inline void ExtractValid<1>() {}
template<> inline void ExtractValid<1>() {}
template<typename T> struct ExtractBits;

View File

@@ -4,20 +4,27 @@
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
#include "strings.h"
#include "functions.h"
#include "landscape.h"
#include "map.h"
#include "tile_map.h"
#include "gui.h"
#include "command.h"
#include "player.h"
#include "command_func.h"
#include "network/network.h"
#include "variables.h"
#include "genworld.h"
#include "newgrf_storage.h"
#include "strings_func.h"
#include "gfx_func.h"
#include "functions.h"
#include "town.h"
#include "date_func.h"
#include "debug.h"
#include "player_func.h"
#include "player_base.h"
#include "table/strings.h"
const char *_cmd_text = NULL;
StringID _error_message;
/**
* Helper macro to define the header of all command handler macros.
@@ -387,7 +394,7 @@ byte GetCommandFlags(uint cmd)
return _command_proc_table[cmd & 0xFF].flags;
}
static int _docommand_recursive;
static int _docommand_recursive = 0;
/*!
* This function executes a given command with the parameters from the #CommandProc parameter list.
@@ -400,7 +407,7 @@ static int _docommand_recursive;
* @param procc The command-id to execute (a value of the CMD_* enums)
* @see CommandProc
*/
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
{
CommandCost res;
CommandProc *proc;
@@ -419,7 +426,9 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint p
/* only execute the test call if it's toplevel, or we're not execing. */
if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
SetTownRatingTestMode(true);
res = proc(tile, flags & ~DC_EXEC, p1, p2);
SetTownRatingTestMode(false);
if (CmdFailed(res)) {
res.SetGlobalErrorMessage();
goto error;
@@ -440,7 +449,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint p
}
/* Execute the command here. All cost-relevant functions set the expenses type
* themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
* themselves to the cost object at some point */
res = proc(tile, flags, p1, p2);
if (CmdFailed(res)) {
res.SetGlobalErrorMessage();
@@ -539,7 +548,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
* e.g.: if you demolish a whole town, the dryrun would say okay.
* but by really destroying, your rating drops and at a certain point
* it will fail. so res and res2 are different
* CMD_REMOVE_ROAD: This command has special local authority
* CMD_REMOVE_LONG_ROAD: This command has special local authority
* restrictions which may cause the test run to fail (the previous
* road fragments still stay there and the town won't let you
* disconnect the road system), but the exec will succeed and this
@@ -549,9 +558,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
* estimate the cost of cloning a vehicle. */
notest =
(cmd & 0xFF) == CMD_CLEAR_AREA ||
(cmd & 0xFF) == CMD_CONVERT_RAIL ||
(cmd & 0xFF) == CMD_LEVEL_LAND ||
(cmd & 0xFF) == CMD_REMOVE_ROAD ||
(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD ||
(cmd & 0xFF) == CMD_CLONE_VEHICLE;
@@ -581,7 +588,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
/* first test if the command can be executed. */
SetTownRatingTestMode(true);
res = proc(tile, flags, p1, p2);
SetTownRatingTestMode(false);
if (CmdFailed(res)) {
res.SetGlobalErrorMessage();
goto show_error;
@@ -609,6 +618,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
return true;
}
#endif /* ENABLE_NETWORK */
DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
/* update last build coordinate of player. */
if (tile != 0 && IsValidPlayer(_current_player)) {
@@ -617,7 +627,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/* Actually try and execute the command. If no cost-type is given
* use the construction one */
_yearly_expenses_type = EXPENSES_CONSTRUCTION;
res2 = proc(tile, flags | DC_EXEC, p1, p2);
/* If notest is on, it means the result of the test can be different than
@@ -692,6 +701,11 @@ Money CommandCost::GetCost() const
return this->cost;
}
ExpensesType CommandCost::GetExpensesType() const
{
return this->expense_type;
}
void CommandCost::SetGlobalErrorMessage() const
{
extern StringID _error_message;

95
src/command_func.h Normal file
View File

@@ -0,0 +1,95 @@
/* $Id$ */
/** @file command_func.h Functions related to commands. */
#ifndef COMMAND_FUNC_H
#define COMMAND_FUNC_H
#include "command_type.h"
/**
* Checks if a command failes.
*
* As you see the parameter is not a command but the return value of a command,
* the CommandCost class. This function checks if the command executed by
* the CommandProc function failed and returns true if it does.
*
* @param cost The return value of a CommandProc call
* @return true if the command failes
* @see CmdSucceded
*/
static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
/**
* Checks if a command succeeded.
*
* As #CmdFailed this function checks if a command succeeded
*
* @param cost The return value of a CommandProc call
* @return true if the command succeeded
* @see CmdSucceeded
*/
static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
/**
* Define a default return value for a failed command.
*
* This variable contains a CommandCost object with is declared as "failed".
* Other functions just need to return this error if there is an error,
* which doesn't need to specific by a StringID.
*/
static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
/**
* Returns from a function with a specific StringID as error.
*
* This macro is used to return from a function. The parameter contains the
* StringID which will be returned.
*
* @param errcode The StringID to return
*/
#define return_cmd_error(errcode) return CommandCost(errcode);
/**
* Execute a command
*/
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc);
/**
* Execute a network safe DoCommand function
*/
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
#ifdef ENABLE_NETWORK
/**
* Send a command over the network
*/
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
#endif /* ENABLE_NETWORK */
/**
* Text, which gets sent with a command
*
* This variable contains a string (be specific a pointer of the first
* char of this string) which will be send with a command. This is
* used for user input data like names or chat messages.
*/
extern const char *_cmd_text;
extern Money _additional_cash_required;
extern StringID _error_message;
/**
* Checks if a integer value belongs to a command.
*/
bool IsValidCommand(uint32 cmd);
/**
* Returns the flags from a given command.
*/
byte GetCommandFlags(uint32 cmd);
/**
* Returns the current money available which can be used for a command.
*/
Money GetAvailableMoneyForCommand();
#endif /* COMMAND_FUNC_H */

View File

@@ -1,9 +1,99 @@
/* $Id$ */
/** @file command.h */
/** @file command_type.h Types related to commands. */
#ifndef COMMAND_H
#define COMMAND_H
#ifndef COMMAND_TYPE_H
#define COMMAND_TYPE_H
#include "economy_type.h"
#include "strings_type.h"
#include "tile_type.h"
/**
* Common return value for all commands. Wraps the cost and
* a possible error message/state together.
*/
class CommandCost {
ExpensesType expense_type; ///< the type of expence as shown on the finances view
Money cost; ///< The cost of this action
StringID message; ///< Warning message for when success is unset
bool success; ///< Whether the comment went fine up to this moment
public:
/**
* Creates a command cost return with no cost and no error
*/
CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {}
/**
* Creates a command return value the is failed with the given message
*/
CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {}
/**
* Creates a command cost with given expense type and start cost of 0
* @param ex_t the expense type
*/
CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {}
/**
* Creates a command return value with the given start cost and expense type
* @param ex_t the expense type
* @param cst the initial cost of this command
*/
CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
/**
* Adds the cost of the given command return value to this cost.
* Also takes a possible error message when it is set.
* @param ret the command to add the cost of.
* @return this class.
*/
CommandCost AddCost(CommandCost ret);
/**
* Adds the given cost to the cost of the command.
* @param cost the cost to add
* @return this class.
*/
CommandCost AddCost(Money cost);
/**
* Multiplies the cost of the command by the given factor.
* @param cost factor to multiply the costs with
* @return this class
*/
CommandCost MultiplyCost(int factor);
/**
* The costs as made up to this moment
* @return the costs
*/
Money GetCost() const;
/**
* The expense type of the cost
* @return the expense type
*/
ExpensesType GetExpensesType() const;
/**
* Sets the global error message *if* this class has one.
*/
void SetGlobalErrorMessage() const;
/**
* Did this command succeed?
* @return true if and only if it succeeded
*/
bool Succeeded() const;
/**
* Did this command fail?
* @return true if and only if it failed
*/
bool Failed() const;
};
/**
* List of commands.
@@ -248,50 +338,6 @@ struct Command {
byte flags;
};
/**
* Checks if a command failes.
*
* As you see the parameter is not a command but the return value of a command,
* the CommandCost class. This function checks if the command executed by
* the CommandProc function failed and returns true if it does.
*
* @param cost The return value of a CommandProc call
* @return true if the command failes
* @see CmdSucceded
*/
static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
/**
* Checks if a command succeeded.
*
* As #CmdFailed this function checks if a command succeeded
*
* @param cost The return value of a CommandProc call
* @return true if the command succeeded
* @see CmdSucceeded
*/
static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
/**
* Define a default return value for a failed command.
*
* This variable contains a CommandCost object with is declared as "failed".
* Other functions just need to return this error if there is an error,
* which doesn't need to specific by a StringID.
*/
static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
/**
* Returns from a function with a specific StringID as error.
*
* This macro is used to return from a function. The parameter contains the
* StringID which will be returned.
*
* @param errcode The StringID to return
*/
#define return_cmd_error(errcode) return CommandCost(errcode);
/* command.cpp */
/**
* Define a callback function for the client, after the command is finished.
*
@@ -307,44 +353,4 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
*/
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
/**
* Execute a command
*/
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
/**
* Execute a network safe DoCommand function
*/
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
#ifdef ENABLE_NETWORK
/**
* Send a command over the network
*/
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
#endif /* ENABLE_NETWORK */
/**
* Text, which gets sent with a command
*
* This variable contains a string (be specific a pointer of the first
* char of this string) which will be send with a command. This is
* used for user input data like names or chat messages.
*/
extern const char *_cmd_text;
/**
* Checks if a integer value belongs to a command.
*/
bool IsValidCommand(uint cmd);
/**
* Returns the flags from a given command.
*/
byte GetCommandFlags(uint cmd);
/**
* Returns the current money available which can be used for a command.
*/
Money GetAvailableMoneyForCommand();
#endif /* COMMAND_H */
#endif /* COMMAND_TYPE_H */

View File

@@ -4,21 +4,22 @@
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
#include "functions.h"
#include "window.h"
#include "gui.h"
#include "gfx.h"
#include "player.h"
#include "textbuf_gui.h"
#include "window_gui.h"
#include "variables.h"
#include "string.h"
#include <stdarg.h>
#include <string.h>
#include "console.h"
#include "helpers.hpp"
#include "network/network.h"
#include "network/network_data.h"
#include "network/network_server.h"
#include "core/alloc_func.hpp"
#include "window_func.h"
#include "string_func.h"
#include "gfx_func.h"
#include "table/strings.h"
#define ICON_BUFFER 79
#define ICON_HISTORY_SIZE 20
@@ -28,6 +29,19 @@
#define ICON_MAX_ALIAS_LINES 40
#define ICON_TOKEN_COUNT 20
/* console parser */
IConsoleCmd *_iconsole_cmds; ///< list of registred commands
IConsoleVar *_iconsole_vars; ///< list of registred vars
IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
/* console colors/modes */
byte _icolour_def;
byte _icolour_err;
byte _icolour_warn;
byte _icolour_dbg;
byte _icolour_cmd;
IConsoleModes _iconsole_mode;
/* ** main console ** */
static char *_iconsole_buffer[ICON_BUFFER + 1];
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
@@ -305,12 +319,12 @@ void IConsoleSwitch()
w->height = _screen.height / 3;
w->width = _screen.width;
_iconsole_mode = ICONSOLE_OPENED;
SETBIT(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
} break;
case ICONSOLE_OPENED: case ICONSOLE_FULL:
DeleteWindowById(WC_CONSOLE, 0);
_iconsole_mode = ICONSOLE_CLOSED;
CLRBIT(_no_scroll, SCROLL_CON);
ClrBit(_no_scroll, SCROLL_CON);
break;
}
@@ -356,7 +370,7 @@ static void IConsoleHistoryNavigate(int direction)
_iconsole_historypos = i;
IConsoleClearCommand();
/* copy history to 'command prompt / bash' */
assert(_iconsole_history[i] != NULL && IS_INT_INSIDE(i, 0, ICON_HISTORY_SIZE));
assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
UpdateTextBufferSize(&_iconsole_cmdline);
}

View File

@@ -5,6 +5,8 @@
#ifndef CONSOLE_H
#define CONSOLE_H
#include "window_type.h"
/* maximum length of a typed in command */
#define ICON_CMDLN_SIZE 255
/* maximum length of a totally expanded command */
@@ -101,17 +103,17 @@ struct IConsoleAlias {
};
/* console parser */
VARDEF IConsoleCmd *_iconsole_cmds; ///< list of registred commands
VARDEF IConsoleVar *_iconsole_vars; ///< list of registred vars
VARDEF IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
extern IConsoleCmd *_iconsole_cmds; ///< list of registred commands
extern IConsoleVar *_iconsole_vars; ///< list of registred vars
extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
/* console colors/modes */
VARDEF byte _icolour_def;
VARDEF byte _icolour_err;
VARDEF byte _icolour_warn;
VARDEF byte _icolour_dbg;
VARDEF byte _icolour_cmd;
VARDEF IConsoleModes _iconsole_mode;
extern byte _icolour_def;
extern byte _icolour_err;
extern byte _icolour_warn;
extern byte _icolour_dbg;
extern byte _icolour_cmd;
extern IConsoleModes _iconsole_mode;
/* console functions */
void IConsoleInit();

View File

@@ -7,26 +7,36 @@
#include "console.h"
#include "debug.h"
#include "engine.h"
#include "functions.h"
#include "landscape.h"
#include "saveload.h"
#include "string.h"
#include "variables.h"
#include "network/network_data.h"
#include "network/network_client.h"
#include "network/network_server.h"
#include "network/network_udp.h"
#include "command.h"
#include "settings.h"
#include "command_func.h"
#include "settings_func.h"
#include "fios.h"
#include "fileio.h"
#include "vehicle.h"
#include "station.h"
#include "strings.h"
#include "screenshot.h"
#include "genworld.h"
#include "date.h"
#include "network/network.h"
#include "strings_func.h"
#include "viewport_func.h"
#include "window_func.h"
#include "functions.h"
#include "map_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "string_func.h"
#include "player_func.h"
#include "player_base.h"
#include "settings_type.h"
#ifdef ENABLE_NETWORK
#include "table/strings.h"
#endif /* ENABLE_NETWORK */
// ** scriptfile handling ** //
static FILE *_script_file;
@@ -134,19 +144,12 @@ DEF_CONSOLE_CMD(ConResetTile)
DEF_CONSOLE_CMD(ConStopAllVehicles)
{
Vehicle* v;
if (argc == 0) {
IConsoleHelp("Stops all vehicles in the game. For debugging only! Use at your own risk... Usage: 'stopall'");
return true;
}
FOR_ALL_VEHICLES(v) {
/* Code ripped from CmdStartStopTrain. Can't call it, because of
* ownership problems, so we'll duplicate some code, for now */
v->vehstatus |= VS_STOPPED;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
StopAllVehicles();
return true;
}
#endif /* _DEBUG */
@@ -233,7 +236,7 @@ static const FiosItem* GetFiosItem(const char* file)
if (file == endptr || *endptr != '\0') i = -1;
}
return IS_INT_INSIDE(i, 0, _fios_num) ? &_fios_list[i] : NULL;
return IsInsideMM(i, 0, _fios_num) ? &_fios_list[i] : NULL;
}
@@ -1226,10 +1229,6 @@ DEF_CONSOLE_CMD(ConSay)
return true;
}
#ifdef ENABLE_NETWORK
#include "table/strings.h"
#endif /* ENABLE_NETWORK */
DEF_CONSOLE_CMD(ConPlayers)
{
Player *p;
@@ -1326,6 +1325,8 @@ DEF_CONSOLE_HOOK(ConHookRconPW)
return true;
}
extern void HashCurrentCompanyPassword();
/* Also use from within player_gui to change the password graphically */
bool NetworkChangeCompanyPassword(byte argc, char *argv[])
{
@@ -1346,8 +1347,11 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password));
if (!_network_server)
if (!_network_server) {
SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
} else {
HashCurrentCompanyPassword();
}
IConsolePrintF(_icolour_warn, "'company_pw' changed to: %s", _network_player_info[_local_player].password);
@@ -1649,6 +1653,8 @@ void IConsoleStdLibRegister()
IConsoleVarRegister("min_players", &_network_min_players, ICONSOLE_VAR_BYTE, "Automatically pause the game when the number of active players passes below the given amount");
IConsoleVarHookAdd("min_players", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
IConsoleVarHookAdd("min_players", ICONSOLE_HOOK_POST_ACTION, ConHookCheckMinPlayers);
IConsoleVarRegister("reload_cfg", &_network_reload_cfg, ICONSOLE_VAR_BOOLEAN, "reload the entire config file between the end of this game, and starting the next new game - dedicated servers");
IConsoleVarHookAdd("reload_cfg", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
#endif /* ENABLE_NETWORK */

84
src/core/alloc_func.hpp Normal file
View File

@@ -0,0 +1,84 @@
/* $Id$ */
/** @file alloc_func.hpp Functions related to the allocation of memory */
#ifndef ALLOC_FUNC_HPP
#define ALLOC_FUNC_HPP
/**
* Simplified allocation function that allocates the specified number of
* elements of the given type. It also explicitly casts it to the requested
* type.
* @note throws an error when there is no memory anymore.
* @note the memory contains garbage data (i.e. possibly non-zero values).
* @param T the type of the variable(s) to allocation.
* @param num_elements the number of elements to allocate of the given type.
* @return NULL when num_elements == 0, non-NULL otherwise.
*/
template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
{
/*
* MorphOS cannot handle 0 elements allocations, or rather that always
* returns NULL. So we do that for *all* allocations, thus causing it
* to behave the same on all OSes.
*/
if (num_elements == 0) return NULL;
T *t_ptr = (T*)malloc(num_elements * sizeof(T));
if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
return t_ptr;
}
/**
* Simplified allocation function that allocates the specified number of
* elements of the given type. It also explicitly casts it to the requested
* type.
* @note throws an error when there is no memory anymore.
* @note the memory contains all zero values.
* @param T the type of the variable(s) to allocation.
* @param num_elements the number of elements to allocate of the given type.
* @return NULL when num_elements == 0, non-NULL otherwise.
*/
template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
{
/*
* MorphOS cannot handle 0 elements allocations, or rather that always
* returns NULL. So we do that for *all* allocations, thus causing it
* to behave the same on all OSes.
*/
if (num_elements == 0) return NULL;
T *t_ptr = (T*)calloc(num_elements, sizeof(T));
if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
return t_ptr;
}
/**
* Simplified reallocation function that allocates the specified number of
* elements of the given type. It also explicitly casts it to the requested
* type. It extends/shrinks the memory allocation given in t_ptr.
* @note throws an error when there is no memory anymore.
* @note the memory contains all zero values.
* @param T the type of the variable(s) to allocation.
* @param t_ptr the previous allocation to extend/shrink.
* @param num_elements the number of elements to allocate of the given type.
* @return NULL when num_elements == 0, non-NULL otherwise.
*/
template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements)
{
/*
* MorphOS cannot handle 0 elements allocations, or rather that always
* returns NULL. So we do that for *all* allocations, thus causing it
* to behave the same on all OSes.
*/
if (num_elements == 0) {
free(t_ptr);
return NULL;
}
t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
if (t_ptr == NULL) error("Out of memory. Cannot reallocate %i bytes", num_elements * sizeof(T));
return t_ptr;
}
#endif /* ALLOC_FUNC_HPP */

72
src/core/bitmath_func.cpp Normal file
View File

@@ -0,0 +1,72 @@
/* $Id$ */
/** @file bitmath_func.cpp */
#include "../stdafx.h"
#include "bitmath_func.hpp"
const uint8 _ffb_64[64] = {
0, 0, 1, 0, 2, 0, 1, 0,
3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0,
3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0,
3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0,
3, 0, 1, 0, 2, 0, 1, 0,
};
/**
* Search the first set bit in a 32 bit variable.
*
* This algorithm is a static implementation of a log
* conguence search algorithm. It checks the first half
* if there is a bit set search there further. And this
* way further. If no bit is set return 0.
*
* @param x The value to search
* @return The position of the first bit set
*/
uint8 FindFirstBit(uint32 x)
{
if (x == 0) return 0;
/* The macro FIND_FIRST_BIT is better to use when your x is
not more than 128. */
uint8 pos = 0;
if ((x & 0x0000ffff) == 0) { x >>= 16; pos += 16; }
if ((x & 0x000000ff) == 0) { x >>= 8; pos += 8; }
if ((x & 0x0000000f) == 0) { x >>= 4; pos += 4; }
if ((x & 0x00000003) == 0) { x >>= 2; pos += 2; }
if ((x & 0x00000001) == 0) { pos += 1; }
return pos;
}
/**
* Search the last set bit in a 64 bit variable.
*
* This algorithm is a static implementation of a log
* conguence search algorithm. It checks the second half
* if there is a bit set search there further. And this
* way further. If no bit is set return 0.
*
* @param x The value to search
* @return The position of the last bit set
*/
uint8 FindLastBit(uint64 x)
{
if (x == 0) return 0;
uint8 pos = 0;
if ((x & 0xffffffff00000000ULL) != 0) { x >>= 32; pos += 32; }
if ((x & 0x00000000ffff0000ULL) != 0) { x >>= 16; pos += 16; }
if ((x & 0x000000000000ff00ULL) != 0) { x >>= 8; pos += 8; }
if ((x & 0x00000000000000f0ULL) != 0) { x >>= 4; pos += 4; }
if ((x & 0x000000000000000cULL) != 0) { x >>= 2; pos += 2; }
if ((x & 0x0000000000000002ULL) != 0) { pos += 1; }
return pos;
}

324
src/core/bitmath_func.hpp Normal file
View File

@@ -0,0 +1,324 @@
/* $Id$ */
/** @file bitmath_func.hpp */
#ifndef BITMATH_FUNC_HPP
#define BITMATH_FUNC_HPP
/**
* Fetch n bits from x, started at bit s.
*
* This function can be used to fetch n bits from the value x. The
* s value set the startposition to read. The startposition is
* count from the LSB and starts at 0. The result starts at a
* LSB, as this isn't just an and-bitmask but also some
* bit-shifting operations. GB(0xFF, 2, 1) will so
* return 0x01 (0000 0001) instead of
* 0x04 (0000 0100).
*
* @param x The value to read some bits.
* @param s The startposition to read some bits.
* @param n The number of bits to read.
* @return The selected bits, aligned to a LSB.
*/
template<typename T> static inline uint GB(const T x, const uint8 s, const uint8 n)
{
return (x >> s) & ((1U << n) - 1);
}
/** Set n bits from x starting at bit s to d
*
* This function sets n bits from x which started as bit s to the value of
* d. The parameters x, s and n works the same as the parameters of
* #GB. The result is saved in x again. Unused bits in the window
* provided by n are set to 0 if the value of b isn't "big" enough.
* This is not a bug, its a feature.
*
* @note Parameter x must be a variable as the result is saved there.
* @note To avoid unexpecting results the value of b should not use more
* space as the provided space of n bits (log2)
* @param x The variable to change some bits
* @param s The startposition for the new bits
* @param n The size/window for the new bits
* @param d The actually new bits to save in the defined position.
* @return The new value of x
*/
template<typename T, typename U> static inline T SB(T& x, const uint8 s, const uint8 n, const U d)
{
x &= (T)(~(((1U << n) - 1) << s));
x |= (T)(d << s);
return x;
}
/** Add i to n bits of x starting at bit s.
*
* This add the value of i on n bits of x starting at bit s. The parameters x,
* s, i are similar to #GB besides x must be a variable as the result are
* saved there. An overflow does not affect the following bits of the given
* bit window and is simply ignored.
*
* @note Parameter x must be a variable as the result is saved there.
* @param x The variable to add some bits at some position
* @param s The startposition of the addition
* @param n The size/window for the addition
* @param i The value to add at the given startposition in the given window.
* @return The new value of x
*/
template<typename T, typename U> static inline T AB(T& x, const uint8 s, const uint8 n, const U i)
{
const T mask = (T)(((1U << n) - 1) << s);
x = (T)((x & ~mask) | ((x + (i << s)) & mask));
return x;
}
/**
* Checks if a bit in a value is set.
*
* This function checks if a bit inside a value is set or not.
* The y value specific the position of the bit, started at the
* LSB and count from 0.
*
* @param x The value to check
* @param y The position of the bit to check, started from the LSB
* @return True if the bit is set, false else.
*/
template<typename T> static inline bool HasBit(const T x, const uint8 y)
{
return (x & ((T)1U << y)) != 0;
}
/**
* Check several bits in a value.
*
* This macro checks if a value contains at least one bit of an other
* value.
*
* @param x The first value
* @param y The second value
* @return True if at least one bit is set in both values, false else.
*/
#define HASBITS(x, y) ((x) & (y))
/**
* Set a bit in a variable.
*
* This function sets a bit in a variable. The variable is changed
* and the value is also returned. Parameter y defines the bit and
* starts at the LSB with 0.
*
* @param x The variable to set a bit
* @param y The bit position to set
* @return The new value of the old value with the bit set
*/
template<typename T> static inline T SetBit(T& x, const uint8 y)
{
return x = (T)(x | (T)(1U << y));
}
/**
* Sets several bits in a variable.
*
* This macro sets several bits in a variable. The bits to set are provided
* by a value. The new value is also returned.
*
* @param x The variable to set some bits
* @param y The value with set bits for setting them in the variable
* @return The new value of x
*/
#define SETBITS(x, y) ((x) |= (y))
/**
* Clears a bit in a variable.
*
* This function clears a bit in a variable. The variable is
* changed and the value is also returned. Parameter y defines the bit
* to clear and starts at the LSB with 0.
*
* @param x The variable to clear the bit
* @param y The bit position to clear
* @return The new value of the old value with the bit cleared
*/
template<typename T> static inline T ClrBit(T& x, const uint8 y)
{
return x = (T)(x & ~((T)1U << y));
}
/**
* Clears several bits in a variable.
*
* This macro clears several bits in a variable. The bits to clear are
* provided by a value. The new value is also returned.
*
* @param x The variable to clear some bits
* @param y The value with set bits for clearing them in the variable
* @return The new value of x
*/
#define CLRBITS(x, y) ((x) &= ~(y))
/**
* Toggles a bit in a variable.
*
* This function toggles a bit in a variable. The variable is
* changed and the value is also returned. Parameter y defines the bit
* to toggle and starts at the LSB with 0.
*
* @param x The varliable to toggle the bit
* @param y The bit position to toggle
* @return The new value of the old value with the bit toggled
*/
template<typename T> static inline T ToggleBit(T& x, const uint8 y)
{
return x = (T)(x ^ (T)(1U << y));
}
/** Lookup table to check which bit is set in a 6 bit variable */
extern const uint8 _ffb_64[64];
/**
* Returns the first occure of a bit in a 6-bit value (from right).
*
* Returns the position of the first bit that is not zero, counted from the
* LSB. Ie, 110100 returns 2, 000001 returns 0, etc. When x == 0 returns
* 0.
*
* @param x The 6-bit value to check the first zero-bit
* @return The first position of a bit started from the LSB or 0 if x is 0.
*/
#define FIND_FIRST_BIT(x) _ffb_64[(x)]
/**
* Finds the position of the first bit in an integer.
*
* This function returns the position of the first bit set in the
* integer. It does only check the bits of the bitmask
* 0x3F3F (0011111100111111) and checks only the
* bits of the bitmask 0x3F00 if and only if the
* lower part 0x00FF is 0. This results the bits at 0x00C0 must
* be also zero to check the bits at 0x3F00.
*
* @param value The value to check the first bits
* @return The position of the first bit which is set
* @see FIND_FIRST_BIT
*/
static inline uint8 FindFirstBit2x64(const int value)
{
if ((value & 0xFF) == 0) {
return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
} else {
return FIND_FIRST_BIT(value & 0x3F);
}
}
uint8 FindFirstBit(uint32 x);
uint8 FindLastBit(uint64 x);
/**
* Clear the first bit in an integer.
*
* This function returns a value where the first bit (from LSB)
* is cleared.
* So, 110100 returns 110000, 000001 returns 000000, etc.
*
* @param value The value to clear the first bit
* @return The new value with the first bit cleared
*/
template<typename T> static inline T KillFirstBit(T value)
{
return value &= (T)(value - 1);
}
/**
* Counts the number of set bits in a variable.
*
* @param value the value to count the number of bits in.
* @return the number of bits.
*/
template<typename T> static inline uint CountBits(T value)
{
uint num;
/* This loop is only called once for every bit set by clearing the lowest
* bit in each loop. The number of bits is therefore equal to the number of
* times the loop was called. It was found at the following website:
* http://graphics.stanford.edu/~seander/bithacks.html */
for (num = 0; value != 0; num++) {
value &= (T)(value - 1);
}
return num;
}
/**
* ROtate x Left by n
*
* @note Assumes a byte has 8 bits
* @param x The value which we want to rotate
* @param n The number how many we waht to rotate
* @return A bit rotated number
*/
template<typename T> static inline T ROL(const T x, const uint8 n)
{
return (T)(x << n | x >> (sizeof(x) * 8 - n));
}
/**
* ROtate x Right by n
*
* @note Assumes a byte has 8 bits
* @param x The value which we want to rotate
* @param n The number how many we waht to rotate
* @return A bit rotated number
*/
template<typename T> static inline T ROR(const T x, const uint8 n)
{
return (T)(x >> n | x << (sizeof(x) * 8 - n));
}
/**
* Do an operation for each set set bit in a value.
*
* This macros is used to do an operation for each set
* bit in a variable. The first variable can be reused
* in the operation due to it's the bit position counter.
* The second variable will be cleared during the usage
*
* @param i The position counter
* @param b The value which we check for set bits
*/
#define FOR_EACH_SET_BIT(i, b) \
for (i = 0; b != 0; i++, b >>= 1) \
if (b & 1)
#if defined(__APPLE__)
/* Make endian swapping use Apple's macros to increase speed
* (since it will use hardware swapping if available).
* Even though they should return uint16 and uint32, we get
* warnings if we don't cast those (why?) */
#define BSWAP32(x) ((uint32)Endian32_Swap(x))
#define BSWAP16(x) ((uint16)Endian16_Swap(x))
#else
/**
* Perform a 32 bits endianness bitswap on x.
* @param x the variable to bitswap
* @return the bitswapped value.
*/
static inline uint32 BSWAP32(uint32 x)
{
return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000);
}
/**
* Perform a 16 bits endianness bitswap on x.
* @param x the variable to bitswap
* @return the bitswapped value.
*/
static inline uint16 BSWAP16(uint16 x)
{
return (x >> 8) | (x << 8);
}
#endif /* __APPLE__ */
#endif /* BITMATH_FUNC_HPP */

65
src/core/endian_func.hpp Normal file
View File

@@ -0,0 +1,65 @@
/* $Id$ */
/** @file endian_func.hpp */
#ifndef ENDIAN_FUNC_H
#define ENDIAN_FUNC_H
#include "bitmath_func.hpp"
#if defined(ARM) || defined(__arm__) || defined(__alpha__)
#define OTTD_ALIGNMENT
#endif
/* Windows has always LITTLE_ENDIAN */
#if defined(WIN32) || defined(__OS2__) || defined(WIN64)
#define TTD_LITTLE_ENDIAN
#elif !defined(TESTING)
/* Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile */
#if defined(STRGEN)
#include "endian_host.h"
#else
#include "endian_target.h"
#endif
#endif /* WIN32 || __OS2__ || WIN64 */
/* Setup alignment and conversion macros */
#if defined(TTD_BIG_ENDIAN)
#define FROM_BE16(x) (x)
#define FROM_BE32(x) (x)
#define TO_BE16(x) (x)
#define TO_BE32(x) (x)
#define TO_BE32X(x) (x)
#define FROM_LE16(x) BSWAP16(x)
#define FROM_LE32(x) BSWAP32(x)
#define TO_LE16(x) BSWAP16(x)
#define TO_LE32(x) BSWAP32(x)
#define TO_LE32X(x) BSWAP32(x)
#else
#define FROM_BE16(x) BSWAP16(x)
#define FROM_BE32(x) BSWAP32(x)
#define TO_BE16(x) BSWAP16(x)
#define TO_BE32(x) BSWAP32(x)
#define TO_BE32X(x) BSWAP32(x)
#define FROM_LE16(x) (x)
#define FROM_LE32(x) (x)
#define TO_LE16(x) (x)
#define TO_LE32(x) (x)
#define TO_LE32X(x) (x)
#endif /* TTD_BIG_ENDIAN */
static inline uint16 ReadLE16Aligned(const void *x)
{
return FROM_LE16(*(const uint16*)x);
}
static inline uint16 ReadLE16Unaligned(const void *x)
{
#ifdef OTTD_ALIGNMENT
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
#else
return FROM_LE16(*(const uint16*)x);
#endif
}
#endif /* ENDIAN_FUNC_HPP */

115
src/core/enum_type.hpp Normal file
View File

@@ -0,0 +1,115 @@
/* $Id$ */
/** @file enum_type.hpp Type (helpers) for enums */
#ifndef ENUM_TYPE_HPP
#define ENUM_TYPE_HPP
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
#define DECLARE_POSTFIX_INCREMENT(type) \
FORCEINLINE type operator ++(type& e, int) \
{ \
type e_org = e; \
e = (type)((int)e + 1); \
return e_org; \
} \
FORCEINLINE type operator --(type& e, int) \
{ \
type e_org = e; \
e = (type)((int)e - 1); \
return e_org; \
}
/** Operators to allow to work with enum as with type safe bit set in C++ */
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
/** Informative template class exposing basic enumeration properties used by several
* other templates below. Here we have only forward declaration. For each enum type
* we will create specialization derived from MakeEnumPropsT<>.
* i.e.:
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
* followed by:
* typedef TinyEnumT<Track> TrackByte;
*/
template <typename Tenum_t> struct EnumPropsT;
/** Helper template class that makes basic properties of given enumeration type visible
* from outsize. It is used as base class of several EnumPropsT specializations each
* dedicated to one of commonly used enumeration types.
* @param Tenum_t enumeration type that you want to describe
* @param Tstorage_t what storage type would be sufficient (i.e. byte)
* @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
* @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
* @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
*/
template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
struct MakeEnumPropsT {
typedef Tenum_t type; ///< enum type (i.e. Trackdir)
typedef Tstorage_t storage; ///< storage type (i.e. byte)
static const Tenum_t begin = Tbegin; ///< lowest valid value (i.e. TRACKDIR_BEGIN)
static const Tenum_t end = Tend; ///< one after the last valid value (i.e. TRACKDIR_END)
static const Tenum_t invalid = Tinvalid; ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
};
/** In some cases we use byte or uint16 to store values that are defined as enum. It is
* necessary in order to control the sizeof() such values. Some compilers make enum
* the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
* compiler type-checking causes errors like:
* 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
* u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
* to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
template <typename Tenum_t> struct TinyEnumT;
/** The general declaration of TinyEnumT<> (above) */
template <typename Tenum_t> struct TinyEnumT
{
typedef Tenum_t enum_type; ///< expose our enumeration type (i.e. Trackdir) to outside
typedef EnumPropsT<Tenum_t> Props; ///< make easier access to our enumeration propeties
typedef typename Props::storage storage_type; ///< small storage type
static const enum_type begin = Props::begin; ///< enum beginning (i.e. TRACKDIR_BEGIN)
static const enum_type end = Props::end; ///< enum end (i.e. TRACKDIR_END)
static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form
/** Cast operator - invoked then the value is assigned to the Tenum_t type */
FORCEINLINE operator enum_type () const
{
return (enum_type)m_val;
}
/** Assignment operator (from Tenum_t type) */
FORCEINLINE TinyEnumT& operator = (enum_type e)
{
m_val = (storage_type)e; return *this;
}
/** postfix ++ operator on tiny type */
FORCEINLINE TinyEnumT operator ++ (int)
{
TinyEnumT org = *this;
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return org;
}
/** prefix ++ operator on tiny type */
FORCEINLINE TinyEnumT& operator ++ ()
{
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return *this;
}
};
#endif /* HELPERS_HPP */

View File

@@ -0,0 +1,49 @@
/* $Id$ */
/** @file geometry_type.hpp All geometry types in OpenTTD. */
#ifndef GEOMETRY_TYPE_HPP
#define GEOMETRY_TYPE_HPP
#if defined(__AMIGA__)
/* AmigaOS already has a Point declared */
#define Point OTTD_Point
#endif /* __AMIGA__ */
#if defined(__APPLE__)
/* Mac OS X already has both Rect and Point declared */
#define Rect OTTD_Rect
#define Point OTTD_Point
#endif /* __APPLE__ */
struct Point {
int x;
int y;
};
struct Dimension {
int width;
int height;
};
struct Rect {
int left;
int top;
int right;
int bottom;
};
struct PointDimension {
int x;
int y;
int width;
int height;
};
struct Pair {
int a;
int b;
};
#endif /* GEOMETRY_TYPE_HPP */

226
src/core/math_func.hpp Normal file
View File

@@ -0,0 +1,226 @@
/* $Id$ */
/** @file math_func.hpp Integer math functions */
#ifndef MATH_FUNC_HPP
#define MATH_FUNC_HPP
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#ifdef abs
#undef abs
#endif
/**
* Returns the maximum of two values.
*
* This function returns the greater value of two given values.
* If they are equal the value of a is returned.
*
* @param a The first value
* @param b The second value
* @return The greater value or a if equals
*/
template<typename T> static inline T max(const T a, const T b)
{
return (a >= b) ? a : b;
}
/**
* Returns the minimum of two values.
*
* This function returns the smaller value of two given values.
* If they are equal the value of b is returned.
*
* @param a The first value
* @param b The second value
* @return The smaller value or b if equals
*/
template<typename T> static inline T min(const T a, const T b)
{
return (a < b) ? a : b;
}
/**
* Returns the minimum of two integer.
*
* This function returns the smaller value of two given integers.
*
* @param a The first integer
* @param b The second integer
* @return The smaller value
*/
static inline int min(const int a, const int b)
{
return (a < b) ? a : b;
}
/**
* Returns the minimum of two unsigned integers.
*
* This function returns the smaller value of two given unsigned integers.
*
* @param a The first unsigned integer
* @param b The second unsigned integer
* @return The smaller value
*/
static inline uint minu(const uint a, const uint b)
{
return (a < b) ? a : b;
}
/**
* Returns the absolute value of (scalar) variable.
*
* @note assumes variable to be signed
* @param a The value we want to unsign
* @return The unsigned value
*/
template <typename T> static inline T abs(const T a)
{
return (a < (T)0) ? -a : a;
}
/**
* Return the smallest multiple of n equal or greater than x
*
* @note n must be a power of 2
* @param x The min value
* @param n The base of the number we are searching
* @return The smallest multiple of n equal or greater than x
*/
template<typename T> static inline T Align(const T x, uint n)
{
n--;
return (T)((x + n) & ~(n));
}
/**
* Clamp an integer between an interval.
*
* This function returns a value which is between the given interval of
* min and max. If the given value is in this interval the value itself
* is returned otherwise the border of the interval is returned, according
* which side of the interval was 'left'.
*
* @note The min value must be less or equal of max or you get some
* unexpected results.
* @param a The value to clamp/truncate.
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
* @see ClampU(uint, uint, uint)
*/
static inline int Clamp(const int a, const int min, const int max)
{
if (a <= min) return min;
if (a >= max) return max;
return a;
}
/**
* Clamp an unsigned integer between an interval.
*
* This function returns a value which is between the given interval of
* min and max. If the given value is in this interval the value itself
* is returned otherwise the border of the interval is returned, according
* which side of the interval was 'left'.
*
* @note The min value must be less or equal of max or you get some
* unexpected results.
* @param a The value to clamp/truncate.
* @param min The minimum of the interval.
* @param max the maximum of the interval.
* @returns A value between min and max which is closest to a.
* @see Clamp(int, int, int)
*/
static inline uint ClampU(const uint a, const uint min, const uint max)
{
if (a <= min) return min;
if (a >= max) return max;
return a;
}
/**
* Reduce a signed 64-bit int to a signed 32-bit one
*
* This function clamps a 64-bit integer to a 32-bit integer.
* If the 64-bit value is smaller than the smallest 32-bit integer
* value 0x80000000 this value is returned (the left one bit is the sign bit).
* If the 64-bit value is greater than the greatest 32-bit integer value 0x7FFFFFFF
* this value is returned. In all other cases the 64-bit value 'fits' in a
* 32-bits integer field and so the value is casted to int32 and returned.
*
* @param a The 64-bit value to clamps
* @return The 64-bit value reduced to a 32-bit value
* @see Clamp(int, int, int)
*/
static inline int32 ClampToI32(const int64 a)
{
if (a <= (int32)0x80000000) return 0x80000000;
if (a >= (int32)0x7FFFFFFF) return 0x7FFFFFFF;
return (int32)a;
}
/**
* Returns the (absolute) difference between two (scalar) variables
*
* @param a The first scalar
* @param b The second scalar
* @return The absolute difference between the given scalars
*/
template <typename T> static inline T Delta(const T a, const T b) {
return (a < b) ? b - a : a - b;
}
/**
* Checks if a value is between a window started at some base point.
*
* This function checks if the value x is between the value of base
* and base+size. If x equals base this returns true. If x equals
* base+size this returns false.
*
* @param x The value to check
* @param base The base value of the interval
* @param size The size of the interval
* @return True if the value is in the interval, false else.
*/
template<typename T> static inline bool IsInsideBS(const T x, const uint base, const uint size)
{
return (uint)(x - base) < size;
}
/**
* Checks if a value is in an interval.
*
* Returns true if a value is in the interval of [min, max).
*
* @param a The value to check
* @param min The minimum of the interval
* @param max The maximum of the interval
* @see IsInsideBS()
*/
template<typename T> static inline bool IsInsideMM(const T x, const uint min, const uint max)
{
return (uint)(x - min) < (max - min);
}
/**
* Type safe swap operation
* @param a variable to swap with b
* @param b variable to swap with a
*/
template<typename T> void Swap(T& a, T& b)
{
T t = a;
a = b;
b = t;
}
#endif /* MATH_FUNC_HPP */

View File

@@ -1,170 +1,11 @@
/* $Id$ */
/** @file helpers.hpp */
/** @file overflowsafe_type.hpp An overflow safe integer-like type. */
#ifndef HELPERS_HPP
#define HELPERS_HPP
#ifndef OVERFLOWSAFE_TYPE_HPP
#define OVERFLOWSAFE_TYPE_HPP
#include "macros.h"
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
{
T *t_ptr = (T*)malloc(num_elements * sizeof(T));
return t_ptr;
}
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
{
T *t_ptr = (T*)calloc(num_elements, sizeof(T));
return t_ptr;
}
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
template <typename T> FORCEINLINE T* ReallocT(T* t_ptr, size_t num_elements)
{
t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
return t_ptr;
}
/** type safe swap operation */
template<typename T> void Swap(T& a, T& b)
{
T t = a;
a = b;
b = t;
}
/** returns the absolute value of (scalar) variable. @note assumes variable to be signed */
template <typename T> static inline T myabs(T a) { return a < (T)0 ? -a : a; }
/** returns the (absolute) difference between two (scalar) variables */
template <typename T> static inline T delta(T a, T b) { return a < b ? b - a : a - b; }
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
#define DECLARE_POSTFIX_INCREMENT(type) \
FORCEINLINE type operator ++(type& e, int) \
{ \
type e_org = e; \
e = (type)((int)e + 1); \
return e_org; \
} \
FORCEINLINE type operator --(type& e, int) \
{ \
type e_org = e; \
e = (type)((int)e - 1); \
return e_org; \
}
/** Operators to allow to work with enum as with type safe bit set in C++ */
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
/** Informative template class exposing basic enumeration properties used by several
* other templates below. Here we have only forward declaration. For each enum type
* we will create specialization derived from MakeEnumPropsT<>.
* i.e.:
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
* followed by:
* typedef TinyEnumT<Track> TrackByte;
*/
template <typename Tenum_t> struct EnumPropsT;
/** Helper template class that makes basic properties of given enumeration type visible
* from outsize. It is used as base class of several EnumPropsT specializations each
* dedicated to one of commonly used enumeration types.
* @param Tenum_t enumeration type that you want to describe
* @param Tstorage_t what storage type would be sufficient (i.e. byte)
* @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
* @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
* @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
*/
template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
struct MakeEnumPropsT {
typedef Tenum_t type; ///< enum type (i.e. Trackdir)
typedef Tstorage_t storage; ///< storage type (i.e. byte)
static const Tenum_t begin = Tbegin; ///< lowest valid value (i.e. TRACKDIR_BEGIN)
static const Tenum_t end = Tend; ///< one after the last valid value (i.e. TRACKDIR_END)
static const Tenum_t invalid = Tinvalid; ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
};
/** In some cases we use byte or uint16 to store values that are defined as enum. It is
* necessary in order to control the sizeof() such values. Some compilers make enum
* the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
* compiler type-checking causes errors like:
* 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
* u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
* to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
template <typename Tenum_t> struct TinyEnumT;
/** The general declaration of TinyEnumT<> (above) */
template <typename Tenum_t> struct TinyEnumT
{
typedef Tenum_t enum_type; ///< expose our enumeration type (i.e. Trackdir) to outside
typedef EnumPropsT<Tenum_t> Props; ///< make easier access to our enumeration propeties
typedef typename Props::storage storage_type; ///< small storage type
static const enum_type begin = Props::begin; ///< enum beginning (i.e. TRACKDIR_BEGIN)
static const enum_type end = Props::end; ///< enum end (i.e. TRACKDIR_END)
static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form
/** Cast operator - invoked then the value is assigned to the Tenum_t type */
FORCEINLINE operator enum_type () const
{
return (enum_type)m_val;
}
/** Assignment operator (from Tenum_t type) */
FORCEINLINE TinyEnumT& operator = (enum_type e)
{
m_val = (storage_type)e; return *this;
}
/** postfix ++ operator on tiny type */
FORCEINLINE TinyEnumT operator ++ (int)
{
TinyEnumT org = *this;
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return org;
}
/** prefix ++ operator on tiny type */
FORCEINLINE TinyEnumT& operator ++ ()
{
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return *this;
}
};
template <typename T> void ClrBitT(T &t, int bit_index)
{
t = (T)(t & ~((T)1 << bit_index));
}
template <typename T> void SetBitT(T &t, int bit_index)
{
t = (T)(t | ((T)1 << bit_index));
}
template <typename T> void ToggleBitT(T &t, int bit_index)
{
t = (T)(t ^ ((T)1 << bit_index));
}
#include "math_func.hpp"
/**
* Overflow safe template for integers, i.e. integers that will never overflow
@@ -198,7 +39,7 @@ public:
*/
FORCEINLINE OverflowSafeInt& operator += (const OverflowSafeInt& other)
{
if ((T_MAX - myabs(other.m_value)) < myabs(this->m_value) &&
if ((T_MAX - abs(other.m_value)) < abs(this->m_value) &&
(this->m_value < 0) == (other.m_value < 0)) {
this->m_value = (this->m_value < 0) ? T_MIN : T_MAX ;
} else {
@@ -229,7 +70,7 @@ public:
*/
FORCEINLINE OverflowSafeInt& operator *= (const int factor)
{
if (factor != 0 && (T_MAX / myabs(factor)) < myabs(this->m_value)) {
if (factor != 0 && (T_MAX / abs(factor)) < abs(this->m_value)) {
this->m_value = ((this->m_value < 0) == (factor < 0)) ? T_MAX : T_MIN ;
} else {
this->m_value *= factor ;
@@ -303,4 +144,6 @@ template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MA
template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
#endif /* HELPERS_HPP */
typedef OverflowSafeInt<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
#endif /* OVERFLOWSAFE_TYPE_HPP */

156
src/core/random_func.cpp Normal file
View File

@@ -0,0 +1,156 @@
/* $Id$ */
/** @file random_func.cpp */
#include "../stdafx.h"
#include "random_func.hpp"
#include "bitmath_func.hpp"
uint32 _random_seeds[2][2];
uint32 InteractiveRandom()
{
const uint32 s = _random_seeds[1][0];
const uint32 t = _random_seeds[1][1];
_random_seeds[1][0] = s + ROR(t ^ 0x1234567F, 7) + 1;
return _random_seeds[1][1] = ROR(s, 3) - 1;
}
uint InteractiveRandomRange(uint max)
{
return GB(InteractiveRandom(), 0, 16) * max >> 16;
}
#ifdef MERSENNE_TWISTER
// Source code for Mersenne Twister.
// A Random number generator with much higher quality random numbers.
#define N (624) // length of _mt_state vector
#define M (397) // a period parameter
#define K (0x9908B0DFU) // a magic constant
#define hiBit(u) ((u) & 0x80000000U) // mask all but highest bit of u
#define loBit(u) ((u) & 0x00000001U) // mask all but lowest bit of u
#define loBits(u) ((u) & 0x7FFFFFFFU) // mask the highest bit of u
#define mixBits(u, v) (hiBit(u)|loBits(v)) // move hi bit of u to hi bit of v
static uint32 _mt_state[N+1]; // _mt_state vector + 1 extra to not violate ANSI C
static uint32 *_mt_next; // _mt_next random value is computed from here
static int _mt_left = -1; // can *_mt_next++ this many times before reloading
void SetRandomSeed(register uint32 seed)
{
register uint32 *s = _mt_state;
_mt_left = 0;
seed |= 1U;
seed &= 0xFFFFFFFFU;
*s = seed;
for (register uint i = N; i != 0; i--) {
seed *= 69069U;
*s++;
*s = seed & 0xFFFFFFFFU;
}
}
static uint32 ReloadRandom()
{
if (_mt_left < -1) SetRandomSeed(4357U);
_mt_left = N - 1;
_mt_next = _mt_state + 1;
register uint32 *p0 = _mt_state;
register uint32 *p2 = _mt_state + 2;
register uint32 *pM = _mt_state + M;
register uint32 s0 = _mt_state[0];
register uint32 s1 = _mt_state[1];
register uint i = 0;
for (i = (N - M + 1); i != 0; i--) {
s0 = s1;
s1 = *p2;
*p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
*p0++;
*p2++;
*pM++;
}
pM = _mt_state;
for (i = M; i != 0; i--) {
s0 = s1;
s1 = *p2;
*p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
*p0++;
*p2++;
*pM++;
}
s1 = _mt_state[0];
*p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9D2C5680U;
s1 ^= (s1 << 15) & 0xEFC60000U;
s1 ^= (s1 >> 18);
return s1;
}
uint32 Random()
{
_mt_left--;
if (_mt_left < 0) return ReloadRandom();
uint32 y = *_mt_next;
*_mt_next++;
y ^= (y >> 11);
y ^= (y << 7) & 0x9D2C5680U;
y ^= (y << 15) & 0xEFC60000U;
y ^= (y >> 18);
return y;
}
#else /* MERSENNE_TWISTER */
void SetRandomSeed(uint32 seed)
{
_random_seeds[0][0] = seed;
_random_seeds[0][1] = seed;
_random_seeds[1][0] = seed * 0x1234567;
_random_seeds[1][1] = _random_seeds[1][0];
}
#ifdef RANDOM_DEBUG
#include "../network/network_data.h"
uint32 DoRandom(int line, const char *file)
{
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server))
printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_player, file, line);
#else /* RANDOM_DEBUG */
uint32 Random()
{
#endif /* RANDOM_DEBUG */
const uint32 s = _random_seeds[0][0];
const uint32 t = _random_seeds[0][1];
_random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7) + 1;
return _random_seeds[0][1] = ROR(s, 3) - 1;
}
#endif /* MERSENNE_TWISTER */
#if defined(RANDOM_DEBUG) && !defined(MERSENNE_TWISTER)
uint DoRandomRange(uint max, int line, const char *file)
{
return GB(DoRandom(line, file), 0, 16) * max >> 16;
}
#else /* RANDOM_DEBUG & !MERSENNE_TWISTER */
uint RandomRange(uint max)
{
return GB(Random(), 0, 16) * max >> 16;
}
#endif /* RANDOM_DEBUG & !MERSENNE_TWISTER */

105
src/core/random_func.hpp Normal file
View File

@@ -0,0 +1,105 @@
/* $Id$ */
/** @file random_func.h */
#ifndef RANDOM_FUNC_HPP
#define RANDOM_FUNC_HPP
#if defined(__APPLE__)
/* Apple already has Random declared */
#define Random OTTD_Random
#endif /* __APPLE__ */
/**************
* Warning: DO NOT enable this unless you understand what it does
*
* If enabled, in a network game all randoms will be dumped to the
* stdout if the first client joins (or if you are a client). This
* is to help finding desync problems.
*
* Warning: DO NOT enable this unless you understand what it does
**************/
//#define RANDOM_DEBUG
// Enable this to produce higher quality random numbers.
// Doesn't work with network yet.
// #define MERSENNE_TWISTER
void SetRandomSeed(uint32 seed);
#ifdef RANDOM_DEBUG
#define Random() DoRandom(__LINE__, __FILE__)
uint32 DoRandom(int line, const char *file);
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
uint DoRandomRange(uint max, int line, const char *file);
#else
uint32 Random();
uint RandomRange(uint max);
#endif
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
uint InteractiveRandomRange(uint max);
/**
* Checks if a given randomize-number is below a given probability.
*
* This function is used to check if the given probability by the fraction of (a/b)
* is greater than low 16 bits of the given randomize-number v.
*
* Do not use this function twice on the same random 16 bits as it will yield
* the same result. One can use a random number for two calls to Chance16I,
* where one call sends the low 16 bits and the other the high 16 bits.
*
* @param a The numerator of the fraction
* @param b The denominator of the fraction, must of course not be null
* @param r The given randomize-number
* @return True if v is less or equals (a/b)
*/
static inline bool Chance16I(const uint a, const uint b, const uint32 r)
{
assert(b != 0);
return (uint16)r < (uint16)((a << 16) / b);
}
/**
* Flips a coin with a given probability.
*
* This macro can be used to get true or false randomized according to a
* given probability. The parameter a and b create a percent value with
* (a/b). The macro returns true in (a/b) percent.
*
* @see Chance16I()
* @param a The numerator of the fraction
* @param b The denominator of the fraction
* @return True in (a/b) percent
*/
static inline bool Chance16(const uint a, const uint b)
{
return Chance16I(a, b, Random());
}
/**
* Flips a coin with a given probability and saves the randomize-number in a variable.
*
* This function uses the same parameters as Chance16. The third parameter
* must be a variable the randomize-number from Random() is saved in.
*
* The low 16 bits of r will already be used and can therefor not be passed to
* Chance16I. One can only send the high 16 bits to Chance16I.
*
* @see Chance16I()
* @param a The numerator of the fraction
* @param b The denominator of the fraction
* @param r The variable to save the randomize-number from Random()
* @return True in (a/b) percent
*/
static inline bool Chance16R(const uint a, const uint b, uint32 &r)
{
r = Random();
return Chance16I(a, b, r);
}
extern uint32 _random_seeds[2][2];
#endif /* RANDOM_FUNC_HPP */

View File

@@ -6,9 +6,10 @@
#include "openttd.h"
#include "currency.h"
#include "news.h"
#include "variables.h"
#include "settings_type.h"
#include "date_func.h"
#include "table/strings.h"
#include "date.h"
// exchange rate prefix symbol_pos
// | separator | postfix |

View File

@@ -5,6 +5,9 @@
#ifndef CURRENCY_H
#define CURRENCY_H
#include "date_type.h"
#include "strings_type.h"
enum {
CF_NOEURO = 0,
CF_ISEURO = 1,

View File

@@ -4,15 +4,17 @@
#include "stdafx.h"
#include "openttd.h"
#include "date.h"
#include "variables.h"
#include "macros.h"
#include "vehicle.h"
#include "settings_type.h"
#include "network/network.h"
#include "network/network_data.h"
#include "network/network_server.h"
#include "functions.h"
#include "currency.h"
#include "window_func.h"
#include "functions.h"
#include "date_func.h"
#include "vehicle_base.h"
#include "debug.h"
#ifdef DEBUG_DUMP_COMMANDS
#include "saveload.h"
#endif
@@ -270,7 +272,7 @@ void IncreaseDate()
char name[MAX_PATH];
snprintf(name, lengthof(name), "dmp_cmds_%d.sav", _date);
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
debug_dump_commands("ddc:save:%s\n", name);
DebugDumpCommands("ddc:save:%s\n", name);
#endif /* DUMP_COMMANDS */
if (_opt.autosave != 0 && (_cur_month % _autosave_months[_opt.autosave]) == 0) {
_do_autosave = true;

19
src/date_func.h Normal file
View File

@@ -0,0 +1,19 @@
/* $Id$ */
/** @file date_func.h Functions related to dates. */
#ifndef DATE_FUNC_H
#define DATE_FUNC_H
#include "date_type.h"
extern Year _cur_year;
extern Month _cur_month;
extern Date _date;
extern DateFract _date_fract;
void SetDate(Date date);
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
Date ConvertYMDToDate(Year year, Month month, Day day);
#endif /* DATE_FUNC_H */

View File

@@ -1,11 +1,9 @@
/* $Id$ */
/** @file date.h */
/** @file date_type.h Types related to the dates in OpenTTD. */
#ifndef DATE_H
#define DATE_H
#include "openttd.h"
#ifndef DATE_TYPE_H
#define DATE_TYPE_H
/**
* 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
@@ -39,10 +37,12 @@
* be encoded in a single 32 bits date, about 2^31 / 366 years. */
#define MAX_YEAR 5000000
/* Year and Date are defined elsewhere */
typedef int32 Date;
typedef uint16 DateFract;
typedef int32 Year;
typedef uint8 Month;
typedef uint8 Day;
typedef uint16 DateFract;
struct YearMonthDay {
Year year;
@@ -50,14 +50,7 @@ struct YearMonthDay {
Day day;
};
extern Year _cur_year;
extern Month _cur_month;
extern Date _date;
extern DateFract _date_fract;
static const Year INVALID_YEAR = -1;
static const Date INVALID_DATE = -1;
void SetDate(Date date);
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
Date ConvertYMDToDate(Year year, Month month, Day day);
#endif /* DATE_H */
#endif /* DATE_TYPE_H */

Some files were not shown because too many files have changed in this diff Show More