Compare commits

..

253 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
peter1138 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
peter1138 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
peter1138 ea6535c864 (svn r11860) -Fix: Test station class validity against number of classes, not abosolute limit. 2008-01-15 11:43:06 +00:00
peter1138 68a3df82b9 (svn r11859) -Codechange: Update newgrf station class dropdown to use new method of generating list. 2008-01-15 10:36:51 +00:00
peter1138 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
peter1138 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
peter1138 ea808b2bfa (svn r11850) -Fix (r11848): forgot to update vc project files 2008-01-14 16:40:31 +00:00
peter1138 bf0a7ae4fb (svn r11849) -Fix (r11848): Incomplete(?) class broke MSVC/mingw compilation 2008-01-14 16:35:49 +00:00
peter1138 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
peter1138 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
peter1138 c7debf7908 (svn r11824) -Fix (r11822): Converting signs from TTD games incomplete 2008-01-12 21:25:04 +00:00
peter1138 e677814a4b (svn r11823) -Fix (r11822): Custom names from old TTD games were not updated. 2008-01-12 21:01:27 +00:00
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 ce2104ed47 (svn r11784) -Codechange: set up initial engine data in one place 2008-01-08 18:25:51 +00:00
peter1138 814f47a3cc (svn r11783) -Codechange: compare engine type with its type property, not by its index 2008-01-08 18:16:26 +00:00
peter1138 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
peter1138 4479c06e2d (svn r11781) -Codechange: variable scope and initialization 2008-01-07 22:38:30 +00:00
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 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
peter1138 a8611311ac (svn r11733) -Fix: Max speed for entering stations overrode the max speed of curves 2008-01-01 14:15:28 +00:00
peter1138 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
peter1138 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
peter1138 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
peter1138 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
432 changed files with 14953 additions and 11584 deletions
-12
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)
+1 -1
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 "----------------"
Binary file not shown.
Binary file not shown.
+46
View File
@@ -1,3 +1,49 @@
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)
------------------------------------------------------------------------
+214 -52
View File
@@ -5,7 +5,7 @@ log() {
}
set_default() {
released_version="0.6.0-beta2"
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() {
@@ -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"
Vendored
+2 -2
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 $?
+4 -7
View File
@@ -11,21 +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
- 1519 Full screen issues in windows
- 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
- 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
- 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
+6
View File
@@ -4,6 +4,12 @@ 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.
+2 -2
View File
@@ -1,9 +1,9 @@
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "0.6.0" ; Define application version
!define INSTALLERVERSION 40 ; 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"
+1 -1
View File
@@ -194,7 +194,7 @@ Function IsCachedVersion(version)
End Function
Dim version
version = "0.6.0-beta2"
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
+13 -13
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
+15 -15
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"
>
+15 -15
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"
>
+25 -7
View File
@@ -344,6 +344,9 @@
<File
RelativePath=".\..\src\settings.cpp">
</File>
<File
RelativePath=".\..\src\signal.cpp">
</File>
<File
RelativePath=".\..\src\signs.cpp">
</File>
@@ -372,7 +375,7 @@
RelativePath=".\..\src\thread.cpp">
</File>
<File
RelativePath=".\..\src\tile.cpp">
RelativePath=".\..\src\tile_map.cpp">
</File>
<File
RelativePath=".\..\src\vehicle.cpp">
@@ -386,6 +389,9 @@
<File
RelativePath=".\..\src\widget.cpp">
</File>
<File
RelativePath=".\..\src\widgets\dropdown.cpp">
</File>
<File
RelativePath=".\..\src\win32.cpp">
</File>
@@ -498,9 +504,6 @@
<File
RelativePath=".\..\src\heightmap.h">
</File>
<File
RelativePath=".\..\src\helpers.hpp">
</File>
<File
RelativePath=".\..\src\industry.h">
</File>
@@ -510,9 +513,6 @@
<File
RelativePath=".\..\src\livery.h">
</File>
<File
RelativePath=".\..\src\macros.h">
</File>
<File
RelativePath=".\..\src\map.h">
</File>
@@ -654,6 +654,9 @@
<File
RelativePath=".\..\src\signs.h">
</File>
<File
RelativePath=".\..\src\signal_func.h">
</File>
<File
RelativePath=".\..\src\slope.h">
</File>
@@ -732,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>
@@ -890,6 +902,9 @@
<File
RelativePath=".\..\src\station_cmd.cpp">
</File>
<File
RelativePath=".\..\src\terraform_cmd.cpp">
</File>
<File
RelativePath=".\..\src\timetable_cmd.cpp">
</File>
@@ -1197,6 +1212,9 @@
<File
RelativePath=".\..\src\tunnel_map.h">
</File>
<File
RelativePath=".\..\src\tunnelbridge_map.h">
</File>
<File
RelativePath=".\..\src\unmovable_map.h">
</File>
+33 -9
View File
@@ -691,6 +691,10 @@
RelativePath=".\..\src\settings.cpp"
>
</File>
<File
RelativePath=".\..\src\signal.cpp"
>
</File>
<File
RelativePath=".\..\src\signs.cpp"
>
@@ -728,7 +732,7 @@
>
</File>
<File
RelativePath=".\..\src\tile.cpp"
RelativePath=".\..\src\tile_map.cpp"
>
</File>
<File
@@ -747,6 +751,10 @@
RelativePath=".\..\src\widget.cpp"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown.cpp"
>
</File>
<File
RelativePath=".\..\src\win32.cpp"
>
@@ -895,10 +903,6 @@
RelativePath=".\..\src\heightmap.h"
>
</File>
<File
RelativePath=".\..\src\helpers.hpp"
>
</File>
<File
RelativePath=".\..\src\industry.h"
>
@@ -911,10 +915,6 @@
RelativePath=".\..\src\livery.h"
>
</File>
<File
RelativePath=".\..\src\macros.h"
>
</File>
<File
RelativePath=".\..\src\map.h"
>
@@ -1103,6 +1103,10 @@
RelativePath=".\..\src\signs.h"
>
</File>
<File
RelativePath=".\..\src\signal_func.h"
>
</File>
<File
RelativePath=".\..\src\slope.h"
>
@@ -1207,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"
>
@@ -1415,6 +1431,10 @@
RelativePath=".\..\src\station_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\terraform_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\timetable_cmd.cpp"
>
@@ -1815,6 +1835,10 @@
RelativePath=".\..\src\tunnel_map.h"
>
</File>
<File
RelativePath=".\..\src\tunnelbridge_map.h"
>
</File>
<File
RelativePath=".\..\src\unmovable_map.h"
>
+33 -9
View File
@@ -688,6 +688,10 @@
RelativePath=".\..\src\settings.cpp"
>
</File>
<File
RelativePath=".\..\src\signal.cpp"
>
</File>
<File
RelativePath=".\..\src\signs.cpp"
>
@@ -725,7 +729,7 @@
>
</File>
<File
RelativePath=".\..\src\tile.cpp"
RelativePath=".\..\src\tile_map.cpp"
>
</File>
<File
@@ -744,6 +748,10 @@
RelativePath=".\..\src\widget.cpp"
>
</File>
<File
RelativePath=".\..\src\widgets\dropdown.cpp"
>
</File>
<File
RelativePath=".\..\src\win32.cpp"
>
@@ -892,10 +900,6 @@
RelativePath=".\..\src\heightmap.h"
>
</File>
<File
RelativePath=".\..\src\helpers.hpp"
>
</File>
<File
RelativePath=".\..\src\industry.h"
>
@@ -908,10 +912,6 @@
RelativePath=".\..\src\livery.h"
>
</File>
<File
RelativePath=".\..\src\macros.h"
>
</File>
<File
RelativePath=".\..\src\map.h"
>
@@ -1100,6 +1100,10 @@
RelativePath=".\..\src\signs.h"
>
</File>
<File
RelativePath=".\..\src\signal_func.h"
>
</File>
<File
RelativePath=".\..\src\slope.h"
>
@@ -1204,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"
>
@@ -1412,6 +1428,10 @@
RelativePath=".\..\src\station_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\terraform_cmd.cpp"
>
</File>
<File
RelativePath=".\..\src\timetable_cmd.cpp"
>
@@ -1812,6 +1832,10 @@
RelativePath=".\..\src\tunnel_map.h"
>
</File>
<File
RelativePath=".\..\src\tunnelbridge_map.h"
>
</File>
<File
RelativePath=".\..\src\unmovable_map.h"
>
+20 -15
View File
@@ -1,6 +1,6 @@
OpenTTD README
Last updated: 2007-12-09
Release version: 0.6.0-beta2
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
+9 -3
View File
@@ -66,6 +66,7 @@ screenshot.cpp
sdl.cpp
#end
settings.cpp
signal.cpp
signs.cpp
sound.cpp
spritecache.cpp
@@ -75,7 +76,7 @@ strings.cpp
texteff.cpp
tgp.cpp
thread.cpp
tile.cpp
tile_map.cpp
#if WIN32
#else
#if WINCE
@@ -92,6 +93,7 @@ vehicle.cpp
viewport.cpp
waypoint.cpp
widget.cpp
widgets/dropdown.cpp
#if WIN32
win32.cpp
#end
@@ -132,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
@@ -184,6 +184,7 @@ sound/sdl_s.h
video/sdl_v.h
settings.h
signs.h
signal_func.h
slope.h
sound.h
sprite.h
@@ -210,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
@@ -264,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
@@ -373,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
+10 -9
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);
}
+8 -6
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);
+768 -694
View File
File diff suppressed because it is too large Load Diff
+60
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
+19 -19
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,7 +246,7 @@ 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
@@ -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);
+10 -15
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;
}
}
+11 -10
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;
}
+320 -316
View File
File diff suppressed because it is too large Load Diff
+79 -1
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 */
+1 -2
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 {
+33 -34
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;
@@ -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;
@@ -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,13 +642,12 @@ 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)) {
@@ -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);
@@ -1348,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++;
+6 -11
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)
+4 -5
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
+2 -1
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};
+13 -10
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;
+1 -3
View File
@@ -4,15 +4,13 @@
#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)
+2
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
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 */
+14 -18
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);
@@ -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
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 */
+22 -7
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()
{
@@ -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];
+19
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
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 */
+2
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.
+1 -1
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;
+1
View File
@@ -12,6 +12,7 @@
#define AYSTAR_H
#include "queue.h"
#include "tile_type.h"
//#define AYSTAR_DEBUG
enum {
+30 -6
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 */
+3 -1
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)
+1
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:
+4 -3
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;
+6 -3
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)
+3 -1
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)
+2 -3
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;
+11 -11
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++;
+1 -2
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;
+1
View File
@@ -5,6 +5,7 @@
#include "../spritecache.h"
#include "../spriteloader/spriteloader.hpp"
#include "../zoom_type.h"
enum BlitterMode {
BM_NORMAL,
+3 -1
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>
@@ -130,4 +130,6 @@ public:
const char *GetName();
};
extern char _ini_blitter[32];
#endif /* BLITTER_FACTORY_HPP */
+4 -1
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;
+2 -4
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)
{
+2
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
+8
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 */
+11 -9
View File
@@ -4,18 +4,20 @@
#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;
+4 -3
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);
+2 -60
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"
/**
@@ -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
@@ -187,7 +130,6 @@ static inline void ClearSingleBridgeMiddle(TileIndex t, Axis 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
+113 -23
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,14 +808,12 @@ 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;
EngList_Add(&bv->eng_list, 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;
-1
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!
+1 -1
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
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 */
+2
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;
+4 -4
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;
}
+8 -5
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;
+11 -457
View File
@@ -5,442 +5,23 @@
#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.clear_roughland * 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)
{
@@ -452,7 +33,7 @@ static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
&_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)]);
@@ -463,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.clear_roughland * 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);
+1 -2
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.
+3 -4
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;
+27 -16
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,9 +618,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
return true;
}
#endif /* ENABLE_NETWORK */
#ifdef DEBUG_DUMP_COMMANDS
debug_dump_commands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
#endif /* DUMP_COMMANDS */
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)) {
@@ -620,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
@@ -695,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
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 */
+94 -88
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 */
+21 -7
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];
+11 -9
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();
+20 -19
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 */
@@ -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;
@@ -1654,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
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 */
+8 -7
View File
@@ -45,7 +45,7 @@ uint8 FindFirstBit(uint32 x)
}
/**
* Search the last set bit in a 32 bit variable.
* 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
@@ -55,17 +55,18 @@ uint8 FindFirstBit(uint32 x)
* @param x The value to search
* @return The position of the last bit set
*/
uint8 FindLastBit(uint32 x)
uint8 FindLastBit(uint64 x)
{
if (x == 0) return 0;
uint8 pos = 0;
if ((x & 0xffff0000) != 0) { x >>= 16; pos += 16; }
if ((x & 0x0000ff00) != 0) { x >>= 8; pos += 8; }
if ((x & 0x000000f0) != 0) { x >>= 4; pos += 4; }
if ((x & 0x0000000c) != 0) { x >>= 2; pos += 2; }
if ((x & 0x00000002) != 0) { pos += 1; }
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;
}
+46 -1
View File
@@ -211,7 +211,7 @@ static inline uint8 FindFirstBit2x64(const int value)
}
uint8 FindFirstBit(uint32 x);
uint8 FindLastBit(uint32 x);
uint8 FindLastBit(uint64 x);
/**
* Clear the first bit in an integer.
@@ -276,4 +276,49 @@ 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
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
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 */
+49
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 */
+14 -2
View File
@@ -1,6 +1,6 @@
/* $Id */
/* $Id$ */
/** @file math_func.hpp */
/** @file math_func.hpp Integer math functions */
#ifndef MATH_FUNC_HPP
#define MATH_FUNC_HPP
@@ -211,4 +211,16 @@ template<typename T> static inline bool IsInsideMM(const T x, const uint min, co
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 */
@@ -1,153 +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));
if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot allocate %i bytes", 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));
if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot allocate %i bytes", 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));
if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot reallocate %i bytes", 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;
}
/** 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;
}
};
#include "math_func.hpp"
/**
* Overflow safe template for integers, i.e. integers that will never overflow
@@ -286,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 */
+4 -3
View File
@@ -3,9 +3,10 @@
/** @file random_func.cpp */
#include "../stdafx.h"
#include "../macros.h"
#include "../variables.h"
#include "random_func.hpp"
#include "bitmath_func.hpp"
uint32 _random_seeds[2][2];
uint32 InteractiveRandom()
{
@@ -125,7 +126,7 @@ void SetRandomSeed(uint32 seed)
}
#ifdef RANDOM_DEBUG
#include "network/network_data.h"
#include "../network/network_data.h"
uint32 DoRandom(int line, const char *file)
{
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server))
+7
View File
@@ -5,6 +5,11 @@
#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
*
@@ -95,4 +100,6 @@ static inline bool Chance16R(const uint a, const uint b, uint32 &r)
return Chance16I(a, b, r);
}
extern uint32 _random_seeds[2][2];
#endif /* RANDOM_FUNC_HPP */
+3 -2
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 |
+3
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,
+7 -5
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
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 */
+10 -17
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 */
+19 -3
View File
@@ -8,8 +8,7 @@
#include "openttd.h"
#include "console.h"
#include "debug.h"
#include "functions.h"
#include "string.h"
#include "string_func.h"
#include "network/core/core.h"
#if defined(ENABLE_NETWORK)
@@ -163,7 +162,7 @@ void SetDebugString(const char *s)
const char *GetDebugString()
{
const DebugLevel *i;
static char dbgstr[100];
static char dbgstr[150];
char dbgval[20];
memset(dbgstr, 0, sizeof(dbgstr));
@@ -177,3 +176,20 @@ const char *GetDebugString()
return dbgstr;
}
#ifdef DEBUG_DUMP_COMMANDS
#include "fileio.h"
void CDECL DebugDumpCommands(const char *s, ...)
{
static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
if (f == NULL) return;
va_list va;
va_start(va, s);
vfprintf(f, s, va);
va_end(va);
fflush(f);
}
#endif /* DEBUG_DUMP_COMMANDS */
+9
View File
@@ -129,4 +129,13 @@ const char *GetDebugString();
}\
}
void ShowInfo(const char *str);
void CDECL ShowInfoF(const char *str, ...);
#ifdef DEBUG_DUMP_COMMANDS
void CDECL DebugDumpCommands(const char *s, ...);
#else /* DEBUG_DUMP_COMMANDS */
static inline void DebugDumpCommands(const char *s, ...) {}
#endif /* DEBUG_DUMP_COMMANDS */
#endif /* DEBUG_H */
+3 -5
View File
@@ -4,15 +4,13 @@
#include "stdafx.h"
#include "openttd.h"
#include "vehicle.h"
#include "depot.h"
#include "functions.h"
#include "landscape.h"
#include "tile.h"
#include "map.h"
#include "table/strings.h"
#include "saveload.h"
#include "order.h"
#include "window_func.h"
#include "table/strings.h"
DEFINE_OLD_POOL_GENERIC(Depot, Depot)
+1 -20
View File
@@ -5,10 +5,8 @@
#ifndef DEPOT_H
#define DEPOT_H
#include "direction.h"
#include "direction_type.h"
#include "oldpool.h"
#include "tile.h"
#include "variables.h"
#include "road_map.h"
#include "rail_map.h"
#include "water_map.h"
@@ -37,23 +35,6 @@ void ShowDepotWindow(TileIndex tile, VehicleType type);
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
#define MIN_SERVINT_PERCENT 5
#define MAX_SERVINT_PERCENT 90
#define MIN_SERVINT_DAYS 30
#define MAX_SERVINT_DAYS 800
/**
* Get the service interval domain.
* Get the new proposed service interval for the vehicle is indeed, clamped
* within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
* @param index proposed service interval
* @return service interval
*/
static inline Date GetServiceIntervalClamped(uint index)
{
return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
/**
* Check if a tile is a depot of the given type.
*/
+15 -12
View File
@@ -4,24 +4,27 @@
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "train.h"
#include "roadveh.h"
#include "ship.h"
#include "aircraft.h"
#include "table/strings.h"
#include "strings.h"
#include "table/sprites.h"
#include "gui.h"
#include "gfx.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "textbuf_gui.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "station_map.h"
#include "newgrf_engine.h"
#include "spritecache.h"
#include "strings_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "player_func.h"
#include "table/strings.h"
#include "table/sprites.h"
/*
* Since all depot window sizes aren't the same, we need to modify sizes a little.
@@ -171,14 +174,14 @@ static void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y)
switch (v->type) {
case VEH_TRAIN:
DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel);
DrawTrainImage(v, x + 21, sprite_y, WP(w, depot_d).sel, w->hscroll.cap + 4, w->hscroll.pos);
/* Number of wagons relative to a standard length wagon (rounded up) */
SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
break;
case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, 1, WP(w, depot_d).sel); break;
case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, WP(w, depot_d).sel, 1); break;
case VEH_SHIP: DrawShipImage( v, x + 19, sprite_y - 1, WP(w, depot_d).sel); break;
case VEH_AIRCRAFT: {
const Sprite *spr = GetSprite(v->GetImage(DIR_W));
@@ -273,7 +276,7 @@ static void DrawDepotWindow(Window *w)
const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count];
const Vehicle *u;
DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel);
DrawTrainImage(v, x + 50, y, WP(w, depot_d).sel, w->hscroll.cap - 29, 0);
DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
/*Draw the train counter */
@@ -429,7 +432,7 @@ static void DepotClick(Window *w, int x, int y)
VehicleID sel = WP(w, depot_d).sel;
if (WP(w, depot_d).type == VEH_TRAIN && sel != INVALID_VEHICLE) {
WP(w,depot_d).sel = INVALID_VEHICLE;
WP(w, depot_d).sel = INVALID_VEHICLE;
TrainDepotMoveVehicle(v, sel, gdvp.head);
} else if (v != NULL) {
int image = v->GetImage(DIR_W);
+4 -112
View File
@@ -1,38 +1,11 @@
/* $Id$ */
/** @file direction.h */
/** @file direction_func.h Different functions related to conversions between directions. */
#ifndef DIRECTION_H
#define DIRECTION_H
#ifndef DIRECTION_FUNC_H
#define DIRECTION_FUNC_H
#include "helpers.hpp"
/**
* Defines the 8 directions on the map.
*
* This enum defines 8 possible directions which are used for
* the vehicles in the game. The directions are aligned straight
* to the viewport, not to the map. So north points to the top of
* your viewport and not rotated by 45 degrees left or right to get
* a "north" used in you games.
*/
enum Direction {
DIR_BEGIN = 0, ///< Used to iterate
DIR_N = 0, ///< North
DIR_NE = 1, ///< Northeast
DIR_E = 2, ///< East
DIR_SE = 3, ///< Southeast
DIR_S = 4, ///< South
DIR_SW = 5, ///< Southwest
DIR_W = 6, ///< West
DIR_NW = 7, ///< Northwest
DIR_END, ///< Used to iterate
INVALID_DIR = 0xFF, ///< Flag for an invalid direction
};
/** Define basic enum properties */
template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR> {};
typedef TinyEnumT<Direction> DirectionByte; //typedefing-enumification of Direction
#include "direction_type.h"
/**
* Return the reverse of a direction
@@ -46,32 +19,6 @@ static inline Direction ReverseDir(Direction d)
}
/**
* Enumeration for the difference between two directions.
*
* This enumeration is used to mark differences between
* two directions. If you get one direction you can align
* a second direction in 8 different ways. This enumeration
* only contains 6 of these 8 differences, but the remaining
* two can be calculated by adding to differences together.
* This also means you can add two differences together and
* get the difference you really want to get. The difference
* of 45 degrees left + the difference of 45 degrees right results in the
* difference of 0 degrees.
*
* @note To get this mentioned addition of direction you must use
* modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
* @see ChangeDirDiff(DirDiff, DirDiff)
*/
enum DirDiff {
DIRDIFF_SAME = 0, ///< Both directions faces to the same direction
DIRDIFF_45RIGHT = 1, ///< Angle of 45 degrees right
DIRDIFF_90RIGHT = 2, ///< Angle of 90 degrees right
DIRDIFF_REVERSE = 4, ///< One direction is the opposit of the other one
DIRDIFF_90LEFT = 6, ///< Angle of 90 degrees left
DIRDIFF_45LEFT = 7 ///< Angle of 45 degrees left
};
/**
* Calculate the difference between to directions
*
@@ -116,27 +63,6 @@ static inline Direction ChangeDir(Direction d, DirDiff delta)
}
/**
* Enumeration for diagonal directions.
*
* This enumeration is used for the 4 direction of the tile-edges.
*/
enum DiagDirection {
DIAGDIR_BEGIN = 0, ///< Used for iterations
DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor
DIAGDIR_SE = 1, ///< Southeast
DIAGDIR_SW = 2, ///< Southwest
DIAGDIR_NW = 3, ///< Northwest
DIAGDIR_END, ///< Used for iterations
INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
};
DECLARE_POSTFIX_INCREMENT(DiagDirection);
/** Define basic enum properties */
template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR> {};
typedef TinyEnumT<DiagDirection> DiagDirectionByte; //typedefing-enumification of DiagDirection
/**
* Returns the reverse direction of the given DiagDirection
*
@@ -148,25 +74,6 @@ static inline DiagDirection ReverseDiagDir(DiagDirection d)
return (DiagDirection)(2 ^ d);
}
/**
* Enumeration for the difference between to DiagDirection.
*
* As the DiagDirection only contains 4 possible directions the
* difference between two of these directions can only be in 4 ways.
* As the DirDiff enumeration the values can be added together and
* you will get the resulting difference (use modulo DIAGDIR_END).
*
* @see DirDiff
*/
enum DiagDirDiff {
DIAGDIRDIFF_SAME = 0, ///< Same directions
DIAGDIRDIFF_90RIGHT = 1, ///< 90 degrees right
DIAGDIRDIFF_REVERSE = 2, ///< Reverse directions
DIAGDIRDIFF_90LEFT = 3 ///< 90 degrees left
};
/** Allow incrementing of DiagDirDiff variables */
DECLARE_POSTFIX_INCREMENT(DiagDirDiff);
/**
* Applies a difference on a DiagDirection
@@ -214,21 +121,6 @@ static inline Direction DiagDirToDir(DiagDirection dir)
}
/**
* Enumeration for the two axis X and Y
*
* This enumeration represente the two axis X and Y in the game.
* The X axis is the one which goes align the north-west edge
* (and south-east edge). The Y axis must be so the one which goes
* align the north-east edge (and south-west) edge.
*/
enum Axis {
AXIS_X = 0, ///< The X axis
AXIS_Y = 1, ///< The y axis
AXIS_END ///< Used for iterations
};
/**
* Select the other axis as provided.
*

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