1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-13 09:39:10 +00:00

Compare commits

..

157 Commits

Author SHA1 Message Date
Darkvater
4d529cc569 (svn r5679) Release 0.4.8-RC2 2006-07-31 16:03:45 +00:00
Darkvater
6f920cee6c (svn r5678) - Prepare 0.4 branch for release. Update readme's, bugs, installers, changelog, etc. to 0.4.8-RC2 2006-07-31 15:49:12 +00:00
Darkvater
bd736e240a (svn r5674) - Backport from trunk (r5664):
Certain combinations of trains crash when moved around inside the depot.
2006-07-31 12:12:14 +00:00
Darkvater
6c3eedee86 (svn r5673) - Backport from trunk (r5655):
Reversed arrow-sign in the multiplayer list column headers on sort by name
2006-07-31 12:11:14 +00:00
Darkvater
9214c5e0a5 (svn r5672) - Backport from trunk (r5652):
Industry production change button doesn't work for oilrig passangers.
2006-07-31 12:10:20 +00:00
Darkvater
6af2e64186 (svn r5671) - Backport from trunk (r5504, r5512):
Added Italian town name generator. While not a fix, it is added along the same lines
  as the turkish town names. Official translation > official townnames (if existing).
2006-07-31 12:08:08 +00:00
Darkvater
58b4fd7683 (svn r5669) - Backport from trunk (r5464, r3641):
Codechange: verify the presence of music files in the gm folder. Slightly altered r5464
  to exclude the addition of music.c and left out the extra functionality. While in essence
  this is not a true fix, several people have reported a rising CPU usage because Dmusic
  kept indefinitely looping the file list. This should solve that.
2006-07-31 11:50:23 +00:00
Darkvater
f3cce610c8 (svn r5668) - Backport from trunk (r5454):
Helicopters stopping in depot after autorenew/autoreplace
2006-07-31 11:29:18 +00:00
Darkvater
5c30032fe5 (svn r5666) - Backport from trunk (Webtranslator2):
Language changes. Galician has 28 untranslated strings.
2006-07-30 23:43:47 +00:00
tron
6708e181eb (svn r5499) Fix a case of an uninitialised variable in r5368 which caused some graphical glitches at foundations (wrong foundation borders, flickering)
This problem only exists in the backport
2006-07-15 09:21:29 +00:00
truelight
d81a7bf904 (svn r5498) -Fix: in r4677, Darkvater ported patch r4508 from trunk wrongly into the 0.4 branch. Because of that stations no longer delivered goods to industries if they were more then 2 tiles away, instead of the allowed station_spread * 2. 2006-07-14 18:45:31 +00:00
truelight
9c95e99871 (svn r5492) -Backport (r5491) -Fix: [#9] MorphOS crashed when you go a level up on root level (tokai) 2006-07-13 18:20:51 +00:00
truelight
8ecd975951 (svn r5490) -Backport (r5489) -Fix: corrected tokai's name and morphos details (tokai) 2006-07-13 17:58:55 +00:00
truelight
955d4393e0 (svn r5488) -Backport (r5487) -Fix: [#8] UDP sockets were used even if network-availability was set to false (tokai) 2006-07-13 17:54:57 +00:00
bjarni
f0ba57ea82 (svn r5440) -Backport: rev 5428 -Fix: [vehicles] sovled crash when trying to build a vehicle type, that is set to max 0 (spotted by roboman) 2006-07-01 10:46:50 +00:00
bjarni
ebae6200c0 (svn r5439) -Backport [OSX] rev 5438 -Code cleanup [OSX] removed UNIVERSAL_BINARY as a phony target since the target is long gone. Also corrected BUILD_OSX_BUNDLE as phony target
also corrected two $(BUILD_OSX_BUNDLE) to BUILD_OSX_BUNDLE, so the bundle will always build
2006-07-01 10:44:32 +00:00
47fc5a070b (svn r5424) - Correct typo in the date of the man file 2006-06-29 05:54:16 +00:00
Darkvater
a22933719b (svn r5414) Also update the readme file to 0.4.8 2006-06-28 23:04:03 +00:00
Darkvater
5fe523dfcd (svn r5410) - Prepare 0.4 branch for release. Update readme's, bugs, installers and makefile, changelog, etc. to 0.4.8 2006-06-28 21:28:58 +00:00
Darkvater
514eee8067 (svn r5408) - Backport from trunk (Webtranslator2):
Language changes. Galician, Icelandic seems to have lazy translators..
2006-06-28 20:09:32 +00:00
Darkvater
3ed386c180 (svn r5407) - Backport from trunk (r5397):
Redraw the screen when switching the signal side
2006-06-28 20:05:02 +00:00
tron
22df8a8d6b (svn r5369) -Backport: 5363, 5364, 5365
-Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
2006-06-26 15:59:58 +00:00
tron
a2fc417d86 (svn r5368) -Backport: 5351, 5352
-Fix: Several graphical glitches at adjacent tiles with foundations. Some borders were missing, some were superfluous
-Fix: Return accurate slope information for tunnels and bridges to fix several foundation graphics glitches
2006-06-26 15:00:23 +00:00
tron
339160760b (svn r5367) -Backport: 5348
-Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
2006-06-26 14:58:41 +00:00
tron
93713354a2 (svn r5356) Move the inclusion of slope.h to reduce diff to trunk 2006-06-25 09:07:49 +00:00
tron
e3e64430d7 (svn r5350) -Backport: r5327
Use DrawFoundation() for houses
-Fix: Some graphical glitches on house tiles with foundations
-Fix: The selection cursor is now aligned with the top of the foundation for house tiles
2006-06-24 09:48:51 +00:00
tron
20b5c17faa (svn r5349) -Backport: r5315
-Fix: Prohibit altering a road tile while road works are in progress
This fixes some glitches like "turning" the excavation by adding/removing road bits or removing the road piece
2006-06-24 09:12:15 +00:00
tron
f0fd9921a2 (svn r5331) -Backport: r5294
-Fix: Plug a memory leak
2006-06-21 19:39:54 +00:00
tron
47a1e50406 (svn r5330) -Backport: r5292, r5293, r5295, r5297
-Fix: When using SIOCGIFCONF to detect network interfaces accomodate for the fact that struct sockaddr doesn't have fixed size in all implementations
-Fix: Not all network interfaces are capable of broadcasting. Don't record those which aren't
-Fix: Not all networks are /24. Generate proper broadcast addresses for non-/24 nets
2006-06-21 19:39:23 +00:00
tron
c96daf6230 (svn r5329) -Backport: r5291
-Fix: '-f' switch is not valid on windows, so don't show it in help
2006-06-21 19:35:50 +00:00
Darkvater
257ba823a0 (svn r5290) - Backport from trunk (r's and lots of it):
Language changes. Galician (29 missing) and Icelandic (20 missing) are bad off.
  Norwegian, Brazilian-Portugese (2 missing) and Slovak (1 missing).
2006-06-16 19:43:39 +00:00
Darkvater
7fd164deba (svn r5289) - Backport from trunk (r5175, r5176):
Autoreplaced trains can leave all wagons in depot under certain circumstances
2006-06-16 18:59:26 +00:00
tron
73dab80259 (svn r5284) -Backport: r5264
-Fix: The wrong IP could get unbanned, e.g. 'unban 1.2.3.42' could result in unbanning 1.2.3.4
2006-06-15 16:47:13 +00:00
tron
91fc18dcdc (svn r5283) -Backport: r5260
-Fix: It was possible to convert the railtype of a bridge while a train was on it
2006-06-15 16:45:29 +00:00
tron
6d4c3f9636 (svn r5282) -Backport: r5226
-Fix: It was possible to rename signs or waypoints with the chat box
2006-06-15 15:25:18 +00:00
tron
d070a97f7a (svn r5281) -Backport: r5124
-Fix: Be more strict what it means for an aircraft to be in a hangar: It's not just being stopped on a hangar tile
2006-06-15 14:45:03 +00:00
tron
a8d2aa157a (svn r5280) -Backport: r5119
-Fix: If a road vehicle is on a road depot tile and stopped doesn't mean it's in the depot. Use the proper test for this
2006-06-15 14:34:31 +00:00
tron
af0354ad24 (svn r5279) -Backport: r4116
-Fix: The AI should send a plane into a hangar if it's not in a hangar _or_ not stopped, not when it's not in a hangar _and_ not stopped
2006-06-15 14:16:57 +00:00
tron
12a68cc7c3 (svn r5115) Move helper functions to where they belong 2006-06-05 08:30:58 +00:00
Darkvater
45ea5388fe (svn r5110) - Backport from trunk (r's and lots of it):
Language changes. Galician (67 missing!) and Icelandic (20 missing) are bad off.
  Spanish, Norwegian, Brazilian-Portugese (2 missing) and Slovak (1 missing).
2006-06-04 22:34:52 +00:00
Darkvater
1be4771689 (svn r5109) - Backport from trunk (r5097):
The trolly AI used information from the wrong industry when calculating the
  amount of to be transported goods
2006-06-04 22:03:58 +00:00
Darkvater
590cd1d07b (svn r5108) - Backport from trunk (r5092):
There was a gross race condition in the AI code which made it pretty random
  if the AI could give a new vehicle its orders
2006-06-04 22:02:51 +00:00
Darkvater
4f27e53d17 (svn r5107) - Backport from trunk (r5085, r5088):
Add parentheses to CHANCE16*() macro parameters
2006-06-04 21:58:48 +00:00
Darkvater
f026c645e3 (svn r5106) - Backport from trunk (r4964):
Fix NTP over bridges: don't check the rail type when on a bridge
2006-06-04 21:40:21 +00:00
Darkvater
00f2b3e713 (svn r5102) - Backport from trunk (r4753):
Truncate text in dropdown lists to stop text overflowing.
2006-06-04 17:25:00 +00:00
ca175e873f (svn r5072) - Backport from trunk (r5071):
- Fix (FS#184): "Erroneous train reversal on waypoints". When processing the next train order, do not even consider reversing the train if the last order was to a waypoint.
2006-06-02 13:23:22 +00:00
Darkvater
86e4f20be8 (svn r4947) - Fix [FS#145]: Starting scenarios did not adhere to local difficulty settings 2006-05-22 16:44:16 +00:00
Darkvater
d24165ea71 (svn r4932) - Codechange: (r4931): move GetTileMaxZ to tile.[ch] instead of lingering it in tunnelbridge_cmd.c. Might be needed some day for some other backport commit (Tron). 2006-05-20 20:56:31 +00:00
Darkvater
c2e9eb7d7b (svn r4931) - Backport from trunk (r4766):
Vehicles on a sloped tile under a bridge were affected by the bridge speed limit
2006-05-20 20:16:08 +00:00
Darkvater
ec9870a611 (svn r4930) - Backport from trunk (r4859):
Fix issue with train pathfinding over level crossings.
2006-05-20 18:43:59 +00:00
Darkvater
1f9a69bc89 (svn r4929) - Backport from trunk (r's and lots of it):
Language changes. It seems no strings are missing, good job translators :D
2006-05-20 18:41:11 +00:00
Darkvater
a707c043fc (svn r4926) - Backport from trunk (r4914):
Aircraft can now serve as feeders
2006-05-20 17:36:06 +00:00
Darkvater
587cedc35b (svn r4925) - Backport from trunk (r4911):
The AI no longer attempts to build signals under bridges.
2006-05-20 17:35:11 +00:00
Darkvater
f5e0e18dca (svn r4924) - Backport from trunk (r4906):
Refresh build vehicle window (if opened) when converting rail depot
2006-05-20 17:33:36 +00:00
Darkvater
5c8bd4b143 (svn r4923) - Backport from trunk (r4892):
Crash when sorting an empty server list.
2006-05-20 17:22:32 +00:00
Darkvater
d1ca343504 (svn r4922) - Backport from trunk (r4827):
The build-tree window button defaulted to a place-push-button on opening where
  no treetype is selected.
2006-05-20 17:14:54 +00:00
Darkvater
a27b563c40 (svn r4921) - Backport from trunk (r4825, r4826, r4829):
Game crashes when cloning/autoreplace reaches train-limit
2006-05-20 17:11:09 +00:00
Darkvater
f6e8773297 (svn r4919) - Backport from trunk (r4812, r4008, r4110):
NTP properly checks for railtypes on non-plain-rail-tiles
2006-05-20 15:54:46 +00:00
Darkvater
0f012198c4 (svn r4894) - Backport from trunk (r4750):
Trains could enter certain sloped rail tiles under bridges with incompatible rail type
2006-05-16 22:11:15 +00:00
Darkvater
d27bedce36 (svn r4893) - Fix (FS#57): Disable NPF totally for ships as it wholly kills performance (blathijs). Only for 0.4/ branch and 0.4.8. 2006-05-16 21:38:41 +00:00
Darkvater
8892c1d1de (svn r4731) - Backport from trunk (r4203):
Fix: compile on older mingw32 versions (3.1.0)
2006-05-03 21:57:09 +00:00
Darkvater
660d991cc1 (svn r4730) - Backport from trunk (r4690):
Fix (r4668, br4301): Editing a too long string in the editbox resulted in improper strings
  Update about box with Mihamix's real name
2006-05-03 21:40:45 +00:00
Darkvater
63a1bc7ee7 (svn r4728) - Backport from trunk (r4689):
Codechange: correct parameter order or calloc, and use the sizeof
  the variable rather than a struct
2006-05-03 21:35:10 +00:00
Darkvater
2aba4c3354 (svn r4727) - Backport from trunk (r4688):
Fix: Ensure the map memory is cleared after it is allocated. This fixes
  random deserts that sometimes occurred.
2006-05-03 21:34:07 +00:00
Darkvater
4021f48c58 (svn r4726) - Backport from trunk (r4373, r4374, r4402):
Fix: Some weird behaviour with tile selection near bridges
2006-05-03 21:28:48 +00:00
Darkvater
ca6ccf035f (svn r4718) - Backport from trunk (r4715):
Fix: Don't allow PF to enter train depot from the back (signal updates)
2006-05-03 20:25:10 +00:00
Darkvater
f2143b3d9b (svn r4717) - Backport from trunk (r4466):
Fix: Game no longer crashes when the last vehicle serving a station has been
  deleted. This is not exactly the same fix as in trunk/ where it might still
  accept types of invalid types but it doesn't crash anymore. The true fix is
  not possible without a savegame bump.
2006-05-03 20:09:28 +00:00
Darkvater
9c97eb32ba (svn r4701) - Backport from trunk (r4520):
Fix: Reset the last built railtype when starting a new game
2006-05-02 21:19:48 +00:00
Darkvater
f9fc273d2a (svn r4695) - Backport language changes from trunk up to r4592. 2006-05-02 19:52:56 +00:00
Darkvater
343fdd71ef (svn r4687) - Backport from trunk (r4674):
Codechange: use correct parameter order for allocating sound file memory
2006-05-02 14:14:04 +00:00
Darkvater
3d8b1c4fec (svn r4686) - Backport from trunk (r4639):
Feature: Turksih town names (Turkish is in the lang/ folder, so
  town names are appropiate)
2006-05-02 14:12:19 +00:00
Darkvater
00c45347fd (svn r4685) - Backport from trunk (r4599):
Fix: Cloned vehicles get the same service interval as the original vehicle
2006-05-02 14:06:15 +00:00
Darkvater
6fc56409e6 (svn r4684) - Backport from trunk (r4591):
Fix: Game no longer errors out when "Many random towns" is selected
  in the scenario editor.
2006-05-02 14:02:23 +00:00
Darkvater
8e4cf4d599 (svn r4683) - Backport from trunk (r4586):
Codechange: Recursive commands that rely on _error_message to handle
  success/failure can fail if a recursive call fails but doesn't set the 
  error message, thus resulting in an old, possibly erroneous being used
2006-05-02 14:00:26 +00:00
Darkvater
52d25fe06f (svn r4682) - Backport from trunk (r4585, r4950):
Fix: Obscure road dragging bug. The road build command did not 
  return the appropiate error message of invalid-slope when building road.
2006-05-02 13:58:43 +00:00
Darkvater
17b691188d (svn r4681) - Backport from trunk (r4576):
Fix : Temperate bank will no longer appear (during game) in
  tropic landscape. This bug is from the original game.
2006-05-02 13:50:30 +00:00
Darkvater
ec18908c82 (svn r4680) - Backport from trunk (r4560):
Fix: Remove VS2005 undefined vsnprintf() as it doesn't exist
  in the windows libraries (only _vsnprintf). This caused the bad
  function to be called that could result in non-properly terminated
  strings
2006-05-02 13:48:33 +00:00
Darkvater
271af9fbfc (svn r4679) - Backport from trunk (r4521):
Fix: be consistent about the size of the player-name in MP. This
  hopefully fixes a crash on lesser OS's (eg Win98)
2006-05-02 13:47:00 +00:00
Darkvater
ba6fcc84c8 (svn r4678) - Backport from trunk (r4518, r4558):
Fix: specify the 'stopall' console command as a debug command.
2006-05-02 13:44:41 +00:00
Darkvater
a8ddd50157 (svn r4677) - Backport from trunk (r4508):
Fix: Fixed a problem that caused DeliverGoodsToIndustry to not work 
  as intended
2006-05-02 13:42:33 +00:00
Darkvater
dcfd3acc8f (svn r4676) - Backport from trunk (r4505):
Fix: Ships can now be used to set up feeders as well.
2006-05-02 13:37:36 +00:00
Darkvater
d5bcaec677 (svn r4675) - Backport from trunk (r4501):
Fix: When, in a train that has multiple engines in front, the _first_
  of those engines is sold, all the orders are copied to the second
  engine (to ensure "seamless" operation). The next_shared/prev_shared
  pointers where not updated correctly during this operation.
2006-05-02 13:36:38 +00:00
Darkvater
a336c7cd0c (svn r4673) - Backport from trunk (r4468):
Correct declaration of NORETURN for gcc
2006-05-02 13:30:13 +00:00
Darkvater
a343d86500 (svn r4672) - Backport from trunk (r4467):
New plantations now cause the correct ".. being planted .." news item
2006-05-02 13:29:06 +00:00
Darkvater
61370f9e14 (svn r4671) - Backport from trunk (r4445):
Danish town names were saved/loaded as Swiss (previous in the list)
2006-05-02 13:27:19 +00:00
Darkvater
f7228e0b3a (svn r4670) - Backport from trunk (r4435):
In CmdRemoveRoad tiletype was not checked for ownership (heavily edited)
2006-05-02 13:25:03 +00:00
Darkvater
eb703a5768 (svn r4669) - Backport from trunk (r4343):
[Autoreplace] Fix drawing of train list for outdated engines.
2006-05-02 13:11:00 +00:00
Darkvater
f0e3fa29e5 (svn r4668) - Backport from trunk (r4301):
Fix: the maxlength parameter of Textbuf is supposed to be the siz
  of the buffer (so length of string + '\0'), but in the code it 
  was a mix of both.
2006-05-02 13:07:23 +00:00
Darkvater
aba21dd563 (svn r4667) - Backport from trunk (r4291):
Fix: validate all received strings for correctness. This fixes
  potential crashes on hacked clients/servers
2006-05-02 13:00:07 +00:00
Darkvater
f8eb72e188 (svn r4666) - Backport from trunk (r4267):
Validate the error number that a client receives from a server, and
  encapsulate this functionality into GetNetworkErrorMsg()
2006-05-02 12:58:13 +00:00
Darkvater
f9a2d113ab (svn r4665) - Backport from trunk (r4241, r4243):
Fix: Perform validation on the error number that a server receives
  from a client. An invalid value may cause the server to terminate.
2006-05-02 12:54:23 +00:00
Darkvater
f26027da17 (svn r4664) - Backport from trunk (r4228):
Fix: [autoreplace] allow replacement of wagons even when the
  engine fails to be replaced
2006-05-02 12:52:09 +00:00
Darkvater
a32fdb390f (svn r4663) - Backport from trunk (r4195):
Codechange: Initialize order variables to avoid a compiler warning.
2006-05-02 12:47:51 +00:00
Darkvater
8bfb955d4b (svn r4662) - Backport from trunk (r4192):
Fix: In the depot, moving wagons from the end of a very long train
  to a short train where the short train was scrolled off the window
  would cause a game crash.
2006-05-02 12:44:55 +00:00
Darkvater
3a3a1da4e7 (svn r4661) - Backport from trunk (r3865-r3867, r3869, r3870, r3873, r3894, r4059, r4064-r4066, r4217):
Add: a fully optional configure script, that is a wrapper
  around makefile.config
2006-05-02 12:42:21 +00:00
Darkvater
ec47441ce4 (svn r4660) - Backport from trunk (r4183, r4197, r4217):
Codechange: [Makefile]: removed MANUAL_CONFIG as it's not used anymore
  This should hopefully fix the issue where WITH_SDL can be defined while
  SDL_CONFIG is not. Added an error if WITH_SDL is defined but SDL_CONFIG
  is not.
  Replace the dash of SDL_CONFIG/LIBPNG_CONFIG with an underscore
2006-05-02 12:28:35 +00:00
Darkvater
39ebb55b9b (svn r4659) - Backport from trunk (r4158):
Fix: [autoreplace] cost for refitting the new vehicle is now
  added to the cost animation. The player always paid for it, but
  it was not displayed until now
2006-05-02 12:17:16 +00:00
bjarni
c59beffe6b (svn r4624) -Backported r4149 from trunk
main reason is that it fixes the load/save issue for OSX 10.3.9, but the other stuff in this commit can't be taken as it's a result of the fix

full commit log entry:
  -Codechange: [OSX] rewrite of how universal binaries are compiled

    Now OSX stores object files in .OSX and instead of making FAT object files, there are one for each architecture
    Each architecture got their own targets to make a non-FAT binary and in the end, lipo will merge them into one binary

    It's now possible to select which architectures you want to support by defining OTTD_PPC, OTTD_PPC970 (G5) and/or OTTD_i386
    All combos are supported. UNIVERSAL_BINARY and TRIPLE_BINARY can still be used even though it's possible to gain the same result by using the new flags
    Making a universal build when you already got part of it compiled (say the PPC part), it will reuse it and only compile the i386 part to save time
    Note: in some cases when you switch flags, you risk that openttd is not updated. Delete it and try again. The Makefile can't solve this except if it forces linking each time

    This fixes: FS#87 universal binary building borked in 0.4.7
    Now universal binaries work on OSX 10.3.9 again

    Building universal binaries no longer needs to store flags in Makefile.config as the new design makes it possible to figure everything out automatically
2006-04-29 14:38:21 +00:00
celestar
2576164325 (svn r4608) -Backported r4413 from trunk:
-Fix: fixed a bug which pushed the client back to the main menu when a
	server is in the mainserver-list which sends out illegal signals. Many
	tnx to 'test' for finding and isolating the problem.
	-Fix: also specify the problem a bit better
2006-04-28 07:53:10 +00:00
celestar
bacbe211e7 (svn r4607) -Backported r4389 from trunk:
-Fix: [NPF] Don't mark tiles when debugging in multiplayer, this will cause desyncs
2006-04-28 07:51:32 +00:00
celestar
0381a100fa (svn r4606) -Backported r4341 from trunk:
-(FS#101) When a player got bankrupt, slots were not cleared, because vehicles got deleted directly by DeleteVehicle
2006-04-28 07:47:55 +00:00
celestar
6573b46ca3 (svn r4605) -Backported revisions 4304, 4309, 4310, 4312, 4313, 4314 from trunk (chatbox-related stuff)
-The chat box' parent window (the main toolbar, wtf?) doesn't care for the WE_ON_EDIT_TEXT_CANCEL event, so don't send one. This code looks like it was mindlessly copy&pasted from the query box
	-The initial string of the chat box is always the empty string, so don't jump through hoops to check if nothing was entered and simplify the code
	-The chat box has no visible window title, therefore remove the string
	-Calculate the maximum pixel width of the entered text in the chat box from the "text box"-widget instead of hardcoding an arbitrary - and wrong - number
	-The parent window of the chat box is always the main toolbar (?!), therefore don't pass this information as parameter
	-a buffer overflow of the chat box introduced in r1263. Don't tell the Textbuf an arbitrary number as size of the string buffer, but the real lengthof() it
2006-04-28 07:45:44 +00:00
orudge
05b541f63a (svn r4207) - Fix: Update OS/2 on 0.4 branch, too 2006-03-31 16:19:16 +00:00
Darkvater
8a74170da0 (svn r4117) - Prepare 0.4 branch for release. Update readme's, bugs, installers and makefile, changelog, etc. to 0.4.7 2006-03-26 18:49:31 +00:00
bjarni
a0bf18c3c9 (svn r4104) -Backported 4102: updated OSX docs about triple binary 2006-03-25 08:54:09 +00:00
bjarni
31b226dc9f (svn r4102) -Backported 3673, 3674, 3675, 3679, 3682, 3882, 3884 [all OSX]
added support for G5 (ppc970) optimised code
	added support for triple binaries (ppc, ppc970, i386)
	updated the makefile to handle building of universal and triple in a more automated way (way less flags to set)
	now it's no longer needed to spent minutes setting up flags when releasing. It works out of the box :)
	note: even though it looks like it's a lot of commits, it really is that there changes were introduced in small pieces in the trunk
2006-03-25 08:45:30 +00:00
bjarni
b320aa40fa (svn r4100) -Backported 4082 and 4099
the cocoa driver no longer crashes when going to fullscreen (this one depended on the resolution)
	teh cocoa driver speedup of around 1000% applies to Intel macs, so the driver is now just as fast as the PPC one
2006-03-25 07:40:02 +00:00
bjarni
37835e9158 (svn r4097) -Backported 4084 properly (included the last line)
also added a header that is needed because we didn't backport the new feature, that includes the header in the trunk
2006-03-24 23:33:30 +00:00
bjarni
749a4f8c7d (svn r4095) -Backport 4060, 4084
made the release target for OSX do more work (less manual work when releasing)
	updated some OSX documentation
2006-03-24 22:55:16 +00:00
e72232dc4c (svn r4094) - Allow unused wagons have their ->first set. This fixes the faulty
cache warning message, and noticably speeds up depot operations in large 
games. Backport of r3576 from trunk
2006-03-24 22:36:54 +00:00
matthijs
45a4c69842 (svn r4072) - Backport from trunk (4071):
- Fix: [NPF] Trains & busses were unable to find a route when leaving a depot or bus stop. Small omission from r4023 (fix by glx)
2006-03-23 17:52:08 +00:00
matthijs
a2c882af6f (svn r4044) Rename 0.4.5 branch to 0.4. Further minor releases will be in the 0.4 range, to prevent enormously long version numbers. 2006-03-22 22:38:29 +00:00
matthijs
bb7c37b515 (svn r4041) [Debian] Change next version number to 0.4.6 instead of 0.4.5.1. 2006-03-22 22:26:16 +00:00
Darkvater
ec54b3ac24 (svn r4040) - Prepare 0.4.5 branch for release. Update readme's, bugs, installers and makefile, changelog, etc. to 0.4.6 2006-03-22 22:25:46 +00:00
bjarni
a9032183df (svn r4038) -backport (3966, 3972 and 4019) -Fix: [OSX 10.3 and newer] [ 1157244 ] Can't save game if name contains german umlauts (loading savegames with certain chars still look a bit odd) 2006-03-22 21:40:26 +00:00
bjarni
90feff4982 (svn r4037) -backported (3676): updated the install readme for OSX 2006-03-22 21:24:26 +00:00
matthijs
e434485dd8 (svn r4036) * Prepare debian release files for 0.4.5.1 release. 2006-03-22 21:18:33 +00:00
matthijs
dcc4ccf4e9 (svn r4035) - Backport from trunk (4033):
- Codechange: [Debian] Update debian packaging files to use debconf for user interaction.
2006-03-22 21:16:31 +00:00
bjarni
ef7e4abf7f (svn r4034) merged 3618:3971 for video/cocoa_v.m (major speedup for PPC fullscreen fix) 2006-03-22 21:11:05 +00:00
matthijs
5d0ed8fab8 (svn r4032) -Backport from trunk (3507):
- Fix: [Makefile] Make sure the ICON_DIR gets created before copying files there.
  - Fix: Fix small syntactic error in the manpage.
2006-03-22 21:04:13 +00:00
Darkvater
ed7df6e2bf (svn r4031) - Backport from trunk (r4030):
- [win32] Change compiler settings to use the multithreaded CRT. This prevents
  certain crashes on multi-threaded machines.
2006-03-22 20:46:07 +00:00
Darkvater
7cf9e0d8ca (svn r4029) - Backport from trunk (r4023):
Fix: [ 1453646 NPF ] Road vehicles planning through the back of depots and stations.
2006-03-22 20:33:30 +00:00
celestar
85141929a8 (svn r4018) -Backport from trunk (4001:4002):
Add length parameter to FiosMakeSavegameName() and use this function for creating the full path instead of home-brewn snprintf.
	Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
2006-03-22 11:26:08 +00:00
celestar
f4d5c1b01b (svn r4017) -Backport from trunk (3999): Change the order of DestroyWindow and ChangeDisplay. On some machines a sizechange messagequeue is handled before sending WM_DISPLAYCHANGE resulting in an improper resolution written to the configuration file when exiting from fullscreen. (Frostregen) 2006-03-22 11:24:27 +00:00
celestar
31d6286cb4 (svn r4016) -Backport from trunk (3998): When removing rail track from a tile where only X and Y pieces exist, explicitly update signals in both directions. 2006-03-22 11:23:22 +00:00
celestar
ca0a0cdbfd (svn r4015) -Backport from trunk: Default the patch-setting 'pause_on_join' to true. 2006-03-22 11:17:21 +00:00
celestar
04572ed7fe (svn r4014) -Backport from trunk: Slope and height information returned for some tile types is wrong 2006-03-22 11:13:20 +00:00
celestar
ebfef9683e (svn r4013) -Fix last commit. CheckTunnelInWay works differently from IsTunnelInWay :S 2006-03-22 11:11:52 +00:00
celestar
c05d3dd558 (svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
Fixes a bug where you could terraform a tunnel (fixed by r3228, but reverted that one)
Fixes a bug introduced by r3228 which allowed steep rail tiles resulting in ... unwanted effects such as display artifacts.
2006-03-22 10:32:07 +00:00
Darkvater
6e029fe97d (svn r3978) - Change all STRING1's back to STRING in french.txt because these {STRINGn} are only applicable to english.txt. Fixup of r3973. Sorry. Backport of r3977 from trunk 2006-03-19 09:03:25 +00:00
belugas
26ed195319 (svn r3975) Update french translation, adding STRING1 where needed, as well as other omissions.
Thanks to Darkvater for this opportunity. 
No typo this time
2006-03-19 01:52:05 +00:00
Darkvater
7170357a10 (svn r3970) - FS#56 - [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font. Backport of r3940 from trunk 2006-03-18 16:03:55 +00:00
Darkvater
e4bbd3b41c (svn r3969) - [ 1439907 ] Increase client list window width so at least most languages fit (wikipedian). Backport of r3933 from trunk 2006-03-18 16:03:04 +00:00
Darkvater
5ed5e6beed (svn r3968) - Update german and finnish languages. Backport of r3932, r3943 from trunk 2006-03-18 16:02:19 +00:00
Darkvater
5de94db9df (svn r3967) - Fix: Properly set back the owner of a crossing/road-under bridge after removing it. For crossings we can always use .m2 because it is already 0 when not owned by a town. Backport of r3876, r3893 from trunk 2006-03-18 16:00:02 +00:00
Darkvater
6b664a3ba0 (svn r3965) - [win32] Remove mapfile generation and generate a pdb file instead. This and the corresponding executable is enough to trace the source of a crash given by crash.txt by using WinDbg for example. Mapfiles are a bit deprecated in the newer VS environments.
- [win32] Show the revision in crash.txt and enable the button to show the crash text in the crash-window 
- Backport of r3871, r3872 from trunk
2006-03-18 15:51:04 +00:00
Darkvater
beee5698f9 (svn r3964) -Fix: [autoreplace]: (FS#67) autoreplacing trains now keep their tile length instead of their pixel length. Backport of r3811 from trunk 2006-03-18 15:49:00 +00:00
Darkvater
a86ec733a0 (svn r3963) Update debian packaging files to the ones used for releasing 0.4.5 (see os/debian/changelog for details).
Fix a small debconf issue which was in the 0.4.5 release. Backport of r3801 from trunk
2006-03-18 15:48:15 +00:00
Darkvater
37c1135d6b (svn r3962) -Fix: Mark the right tile as dirty. It's just a graphical glitch which happend in r1592. Backport of r3792 from trunk 2006-03-18 15:47:16 +00:00
Darkvater
923dee9bec (svn r3961) - Fix crash when resizing news history window. Backport of r3778 from trunk 2006-03-18 15:46:09 +00:00
Darkvater
1856976d8e (svn r3960) -Fix: Correctly implement minimum search, so road vehicles head twoards the closest station, not the last one in the list. Backport of r3751 from trunk 2006-03-18 15:45:23 +00:00
Darkvater
818a5a596f (svn r3959) -Fix: [FS#61] The tooltips for raising and lowering land buttons in the scenario editor are interchanged (Reported and fixed by lc). Backport of r3749 from trunk 2006-03-18 15:32:38 +00:00
Darkvater
2be4b388ec (svn r3958) Change HASBIT() to return 0/1 instead of 0/value of tested bit. Backport of r3747 from trunk 2006-03-18 15:31:34 +00:00
Darkvater
300aba48cc (svn r3957) -Fix: Correctly restore the roadside after roadworks are finished. Backport of r3680 from trunk 2006-03-18 15:29:24 +00:00
Darkvater
f470a87dea (svn r3956) - Fix: [Multistop] Check the status of the destination road stop instead of a station's first road stop. This only has effect with road vehicle queuing disabled. Backport of r3663, r3681 from trunk 2006-03-18 15:28:26 +00:00
Darkvater
4b938510a5 (svn r3955) - Fix: validate the setting of max_companies/spectators through the console. Backport of r3591, r3593 from trunk 2006-03-18 15:25:25 +00:00
Darkvater
7ddae93da8 (svn r3954) - Explicitly update v->first in TrainConsistChanged() if necessary, as this is far faster than brute forcing it later.
- When loading a game, call TrainConsistChanged() for each train head separately before updating images, as v->first is used extensively in GetTrainImage() for custom graphics. This gives a significant speed improvement on loading a game. 
- Rewrite GetFreeUnitNumber() so that only one loop of vehicles is required. Instead a list of used/unused numbers is created and the first unused number is chosen. This significantly improves performance in large games. 
- Improve game-load times. Backport of r3570-3572 from trunk
2006-03-18 15:22:27 +00:00
Darkvater
f75365fcf4 (svn r3953) - Grr, compile before you commit. Wrong merge of 3529/3553 in r3948 2006-03-18 15:19:30 +00:00
Darkvater
e89a98d296 (svn r3952) - Fix: On loading a game, GetPlayerRailtypes() didn't account for the fact that vehicles are introduced a year after their introduction date. This will also relieve possible (rare) network desyncs. Backport of r3565 from trunk 2006-03-18 15:17:57 +00:00
Darkvater
8157969b2b (svn r3951) - Restore plural forms of cargo types for several languages. Backport of r3560 from trunk. 2006-03-18 15:16:12 +00:00
Darkvater
b3ccef7045 (svn r3950) - Add directives to allow Visual Studio 2005 compilation. Backport of r3551 from trunk. 2006-03-18 15:14:34 +00:00
Darkvater
af0fb58264 (svn r3949) - Revert r3467, was total nonesense, my fault. Backport of r3532 from trunk 2006-03-18 15:13:35 +00:00
Darkvater
5f2e2ef32a (svn r3948) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help). Backport of r3529, r3553 from trunk 2006-03-18 15:12:24 +00:00
Darkvater
8353c1260a (svn r3526) - Codechange: Add additional linker information to release builds to help figure out crashes more easily 2006-02-03 17:24:37 +00:00
Darkvater
8de919ce50 (svn r3519) - [0.4.5-Branch] backport changes from abused tags/ (nothing important) 2006-02-01 22:02:47 +00:00
Darkvater
f9cacc9f5c (svn r3518) - Add proper revision numbers for bugfixing branch 2006-02-01 21:53:12 +00:00
Darkvater
af3ac4954a (svn r3517) - Branch: added branch for stable 0.4.5 2006-02-01 21:47:10 +00:00
1953 changed files with 219066 additions and 773846 deletions

View File

@@ -1,16 +0,0 @@
notifications:
global:
irc:
- openttd
- openttd.notice
push:
only:
- master
only-by:
- DorpsGek
commit-comment:
discussion:
pull-request:
issue:
tag-created:

View File

@@ -1,9 +0,0 @@
root = true
[*]
insert_final_newline = true
trim_trailing_whitespace = true
[*.{c,cpp,h,hpp}]
indent_style = tab
charset = utf-8

1
.github/FUNDING.yml vendored
View File

@@ -1 +0,0 @@
custom: https://www.openttd.org/donate.html

View File

@@ -1,41 +0,0 @@
name: Bug Report
description: Found a bug in OpenTTD?
title: "[Bug]: "
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: version
attributes:
label: Version of OpenTTD
description: Fill in below what version of OpenTTD you are using, including your OS.
placeholder: ex. 1.11.2, Windows 10
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected result
description: Describe in a few words what you expected to happen.
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual result
description: Describe in a few words what actually happens.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce
description: As detailed as possible, please tell us how we can reproduce this. Feel free to attach a savegame (zip it first) to make it more clear.
placeholder: |
1. Loaded the attached savegame.
2. Click on the button left of that other icon.
3. The window doesn't open.
validations:
required: true

View File

@@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Suggestions and ideas?
url: https://www.tt-forums.net/viewforum.php?f=32
about: Have a suggestion or an idea for a cool new feature? Post them on our forum!

View File

@@ -1,37 +0,0 @@
name: Crash
description: Did OpenTTD crash?
title: "[Crash]: "
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this crash report!
- type: input
id: version
attributes:
label: Version of OpenTTD
description: Fill in below what version of OpenTTD you are using, including your OS.
placeholder: ex. 1.11.2, Windows 10
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce
description: Please spend a few words if you can reproduce this problem.
placeholder: |
1. Bought a new train.
2. The game crashed.
validations:
required: true
- type: textarea
id: crashlogs
attributes:
label: Upload crash files
description: With the `crash.log`, `crash.dmp`, and `crash.sav` we can analyze the crash in detail; this way you allow us to easier triage and fix the problem.
placeholder: |
1. Zip the `crash.log`, `crash.dmp` and `crash.sav`.
2. Click on this field.
3. Drag and drop the zip file in here.
validations:
required: true

View File

@@ -1,49 +0,0 @@
## Motivation / Problem
<!--
Describe here shortly
* For bug fixes:
* What problem does this solve?
* If there is already an issue, link the issue, otherwise describe the problem here.
* For features or gameplay changes:
* What was the motivation to develop this feature?
* Does this address any problem with the gameplay or interface?
* Which group of players do you think would enjoy this feature?
-->
## Description
<!--
Describe here shortly
* For bug fixes:
* How is the problem solved?
* For features or gameplay changes:
* What does this feature do?
* How does it improve/solve the situation described under 'motivation'.
-->
## Limitations
<!--
Describe here
* Is the problem solved in all scenarios?
* Is this feature complete? Are there things that could be added in the future?
* Are there things that are intentionally left out?
* Do you know of a bug or corner case that does not work?
-->
## Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.
* The bug fix is important enough to be backported? (label: 'backport requested')
* This PR touches english.txt or translations? Check the [guidelines](https://github.com/OpenTTD/OpenTTD/blob/master/docs/eints.md)
* This PR affects the save game format? (label 'savegame upgrade')
* This PR affects the GS/AI API? (label 'needs review: Script API')
* ai_changelog.hpp, gs_changelog.hpp need updating.
* The compatibility wrappers (compat_*.nut) need updating.
* This PR affects the NewGRF API? (label 'needs review: NewGRF')
* newgrf_debug_data.h may need updating.
* [PR must be added to API tracker](https://wiki.openttd.org/en/Development/NewGRF/Specification%20Status)

16
.github/changelog.sh vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
tag=$(git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@')
# If we are a tag, show the part of the changelog till (but excluding) the last stable
if [ -n "$tag" ]; then
grep='^[0-9]\+\.[0-9]\+[^-]'
next=$(cat changelog.txt | grep '^[0-9]' | awk 'BEGIN { show="false" } // { if (show=="true") print $0; if ($1=="'$tag'") show="true"} ' | grep "$grep" | head -n1 | sed 's/ .*//')
cat changelog.txt | awk 'BEGIN { show="false" } /^[0-9]+.[0-9]+/ { if ($1=="'$next'") show="false"; if ($1=="'$tag'") show="true";} // { if (show=="true") print $0 }'
exit 0
fi
# In all other cases, show the git log of the last 7 days
revdate=$(git log -1 --pretty=format:"%ci")
last_week=$(date -d "$revdate -7days" +"%Y-%m-%d %H:%M")
git log --after="${last_week}" --pretty=fuller

View File

@@ -1,221 +0,0 @@
"""
Script to scan the OpenTTD source-tree for STR_ entries that are defined but
no longer used.
This is not completely trivial, as OpenTTD references a lot of strings in
relation to another string. The most obvious example of this is a list. OpenTTD
only references the first entry in the list, and does "+ <var>" to get to the
correct string.
There are other ways OpenTTD does use relative values. This script tries to
account for all of them, to give the best approximation we have for "this
string is unused".
"""
import glob
import os
import re
import subprocess
import sys
from enum import Enum
LENGTH_NAME_LOOKUP = {
"VEHICLE_TYPES": 4,
}
class SkipType(Enum):
NONE = 1
LENGTH = 2
EXTERNAL = 3
ZERO_IS_SPECIAL = 4
EXPECT_NEWLINE = 5
def read_language_file(filename, strings_found, errors):
strings_defined = []
skip = SkipType.NONE
length = 0
common_prefix = ""
last_tiny_string = ""
with open(filename) as fp:
for line in fp.readlines():
if not line.strip():
if skip == SkipType.EXPECT_NEWLINE:
skip = SkipType.NONE
continue
line = line.strip()
if skip == SkipType.EXPECT_NEWLINE:
# The only thing allowed after a list, is this next marker, or a newline.
if line == "###next-name-looks-similar":
# "###next-name-looks-similar"
# Indicates the common prefix of the last list has a very
# similar name to the next entry, but isn't part of the
# list. So do not emit a warning about them looking very
# similar.
if length != 0:
errors.append(f"ERROR: list around {name} is shorted than indicated by ###length")
common_prefix = ""
else:
errors.append(f"ERROR: expected a newline after a list, but didn't find any around {name}. Did you add an entry to the list without increasing the length?")
skip = SkipType.NONE
if line[0] == "#":
if line.startswith("###length "):
# "###length <count>"
# Indicates the next few entries are part of a list. Only
# the first entry is possibly referenced, and the rest are
# indirectly.
if length != 0:
errors.append(f"ERROR: list around {name} is shorted than indicated by ###length")
length = line.split(" ")[1].strip()
if length.isnumeric():
length = int(length)
else:
length = LENGTH_NAME_LOOKUP[length]
skip = SkipType.LENGTH
elif line.startswith("###external "):
# "###external <count>"
# Indicates the next few entries are used outside the
# source and will not be referenced.
if length != 0:
errors.append(f"ERROR: list around {name} is shorted than indicated by ###length")
length = line.split(" ")[1].strip()
length = int(length)
skip = SkipType.EXTERNAL
elif line.startswith("###setting-zero-is-special"):
# "###setting-zero-is-special"
# Indicates the next entry is part of the "zero is special"
# flag of settings. These entries are not referenced
# directly in the code.
if length != 0:
errors.append(f"ERROR: list around {name} is shorted than indicated by ###length")
skip = SkipType.ZERO_IS_SPECIAL
continue
name = line.split(":")[0].strip()
strings_defined.append(name)
# If a string ends on _TINY or _SMALL, it can be the {TINY} variant.
# Check for this by some fuzzy matching.
if name.endswith(("_SMALL", "_TINY")):
last_tiny_string = name
elif last_tiny_string:
matching_name = "_".join(last_tiny_string.split("_")[:-1])
if name == matching_name:
strings_found.add(last_tiny_string)
else:
last_tiny_string = ""
if skip == SkipType.EXTERNAL:
strings_found.add(name)
skip = SkipType.LENGTH
if skip == SkipType.LENGTH:
skip = SkipType.NONE
length -= 1
common_prefix = name
elif skip == SkipType.ZERO_IS_SPECIAL:
strings_found.add(name)
elif length > 0:
strings_found.add(name)
length -= 1
# Find the common prefix of these strings
for i in range(len(common_prefix)):
if common_prefix[0 : i + 1] != name[0 : i + 1]:
common_prefix = common_prefix[0:i]
break
if length == 0:
skip = SkipType.EXPECT_NEWLINE
if len(common_prefix) < 6:
errors.append(f"ERROR: common prefix of block including {name} was reduced to {common_prefix}. This means the names in the list are not consistent.")
elif common_prefix:
if name.startswith(common_prefix):
errors.append(f"ERROR: {name} looks a lot like block above with prefix {common_prefix}. This mostly means that the list length was too short. Use '###next-name-looks-similar' if it is not.")
common_prefix = ""
return strings_defined
def scan_source_files(path, strings_found):
for new_path in glob.glob(f"{path}/*"):
if os.path.isdir(new_path):
scan_source_files(new_path, strings_found)
continue
if not new_path.endswith((".c", ".h", ".cpp", ".hpp", ".ini")):
continue
# Most files we can just open, but some use magic, that requires the
# G++ preprocessor before we can make sense out of it.
if new_path == "src/table/cargo_const.h":
p = subprocess.run(["g++", "-E", new_path], stdout=subprocess.PIPE)
output = p.stdout.decode()
else:
with open(new_path) as fp:
output = fp.read()
# Find all the string references.
matches = re.findall(r"[^A-Z_](STR_[A-Z0-9_]*)", output)
strings_found.update(matches)
def main():
strings_found = set()
errors = []
scan_source_files("src", strings_found)
strings_defined = read_language_file("src/lang/english.txt", strings_found, errors)
# STR_LAST_STRINGID is special, and not really a string.
strings_found.remove("STR_LAST_STRINGID")
# These are mentioned in comments, not really a string.
strings_found.remove("STR_XXX")
strings_found.remove("STR_NEWS")
strings_found.remove("STR_CONTENT_TYPE_")
# This string is added for completion, but never used.
strings_defined.remove("STR_JUST_DATE_SHORT")
strings_defined = sorted(strings_defined)
strings_found = sorted(list(strings_found))
for string in strings_found:
if string not in strings_defined:
errors.append(f"ERROR: {string} found but never defined.")
for string in strings_defined:
if string not in strings_found:
errors.append(f"ERROR: {string} is (possibly) no longer needed.")
if errors:
for error in errors:
print(error)
sys.exit(1)
else:
print("OK")
if __name__ == "__main__":
main()

View File

@@ -1,411 +0,0 @@
name: CI
on:
pull_request:
push:
branches:
- master
env:
CTEST_OUTPUT_ON_FAILURE: 1
jobs:
emscripten:
name: Emscripten
runs-on: ubuntu-20.04
container:
# If you change this version, change the number in the cache step too.
image: emscripten/emsdk:3.1.28
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup cache
uses: actions/cache@v3
with:
path: /emsdk/upstream/emscripten/cache
key: 3.1.28-${{ runner.os }}
- name: Patch Emscripten to support LZMA
run: |
cd /emsdk/upstream/emscripten
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
- name: Build (host tools)
run: |
mkdir build-host
cd build-host
echo "::group::CMake"
cmake .. -DOPTION_TOOLS_ONLY=ON
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(nproc) cores"
cmake --build . -j $(nproc) --target tools
echo "::endgroup::"
- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Build
run: |
mkdir build
cd build
echo "::group::CMake"
emcmake cmake .. -DHOST_BINARY_DIR=../build-host
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(nproc) cores"
cmake --build . -j $(nproc)
echo "::endgroup::"
linux:
name: Linux
strategy:
fail-fast: false
matrix:
include:
- compiler: clang
cxxcompiler: clang++
libsdl: libsdl2-dev
- compiler: gcc
cxxcompiler: g++
libsdl: libsdl2-dev
- compiler: gcc
cxxcompiler: g++
libsdl: libsdl1.2-dev
- compiler: gcc
cxxcompiler: g++
extra-cmake-parameters: -DOPTION_DEDICATED=ON -DCMAKE_CXX_FLAGS_INIT="-DRANDOM_DEBUG"
runs-on: ubuntu-20.04
env:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.cxxcompiler }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
echo "::group::Update apt"
sudo apt-get update
echo "::endgroup::"
echo "::group::Install dependencies"
sudo apt-get install -y --no-install-recommends \
liballegro4-dev \
libfontconfig-dev \
libicu-dev \
liblzma-dev \
liblzo2-dev \
${{ matrix.libsdl }} \
zlib1g-dev \
# EOF
echo "::endgroup::"
env:
DEBIAN_FRONTEND: noninteractive
- name: Get OpenGFX
run: |
mkdir -p ~/.local/share/openttd/baseset
cd ~/.local/share/openttd/baseset
echo "::group::Download OpenGFX"
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
echo "::endgroup::"
echo "::group::Unpack OpenGFX"
unzip opengfx-all.zip
echo "::endgroup::"
rm -f opengfx-all.zip
- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Build
run: |
mkdir build
cd build
echo "::group::CMake"
cmake .. ${{ matrix.extra-cmake-parameters }}
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(nproc) cores"
cmake --build . -j $(nproc)
echo "::endgroup::"
- name: Test
run: |
cd build
ctest -j $(nproc) --timeout 120
macos:
name: Mac OS
strategy:
fail-fast: false
matrix:
include:
- arch: x64
full_arch: x86_64
runs-on: macos-latest
env:
MACOSX_DEPLOYMENT_TARGET: 10.13
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare cache key
id: key
run: |
echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT
- name: Enable vcpkg cache
uses: actions/cache@v3
with:
path: /usr/local/share/vcpkg/installed
key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-0 # Increase the number whenever dependencies are modified
restore-keys: |
${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}
- name: Prepare vcpkg
run: |
vcpkg install --triplet=${{ matrix.arch }}-osx \
liblzma \
libpng \
lzo \
zlib \
# EOF
- name: Install OpenGFX
run: |
mkdir -p ~/Documents/OpenTTD/baseset
cd ~/Documents//OpenTTD/baseset
echo "::group::Download OpenGFX"
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
echo "::endgroup::"
echo "::group::Unpack OpenGFX"
unzip opengfx-all.zip
echo "::endgroup::"
rm -f opengfx-all.zip
- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Build
run: |
mkdir build
cd build
echo "::group::CMake"
cmake ${GITHUB_WORKSPACE} \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.full_arch }} \
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-osx \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \
# EOF
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(sysctl -n hw.logicalcpu) cores"
cmake --build . -j $(sysctl -n hw.logicalcpu)
echo "::endgroup::"
- name: Test
run: |
cd build
ctest -j $(sysctl -n hw.logicalcpu) --timeout 120
windows:
name: Windows
strategy:
fail-fast: false
matrix:
os: [windows-latest, windows-2019]
arch: [x86, x64]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare cache key
id: key
shell: powershell
run: |
# Work around caching failure with GNU tar
New-Item -Type Junction -Path vcpkg -Target c:\vcpkg
Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT
- name: Enable vcpkg cache
uses: actions/cache@v3
with:
path: vcpkg/installed
key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-0 # Increase the number whenever dependencies are modified
restore-keys: |
${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}
- name: Prepare vcpkg
shell: bash
run: |
vcpkg install --triplet=${{ matrix.arch }}-windows-static \
liblzma \
libpng \
lzo \
zlib \
# EOF
- name: Install OpenGFX
shell: bash
run: |
mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
cd "C:/Users/Public/Documents/OpenTTD/baseset"
echo "::group::Download OpenGFX"
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
echo "::endgroup::"
echo "::group::Unpack OpenGFX"
unzip opengfx-all.zip
echo "::endgroup::"
rm -f opengfx-all.zip
- name: Install MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master
- name: Configure developer command prompt for ${{ matrix.arch }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Build
shell: bash
run: |
mkdir build
cd build
echo "::group::CMake"
cmake .. \
-GNinja \
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static \
-DCMAKE_TOOLCHAIN_FILE="c:\vcpkg\scripts\buildsystems\vcpkg.cmake" \
# EOF
echo "::endgroup::"
echo "::group::Build"
cmake --build .
echo "::endgroup::"
- name: Test
shell: bash
run: |
cd ${GITHUB_WORKSPACE}/build
ctest --timeout 120
msys2:
name: msys2
strategy:
fail-fast: false
matrix:
include:
- msystem: MINGW64
arch: x86_64
- msystem: MINGW32
arch: i686
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
release: false
install: >-
git
make
mingw-w64-${{ matrix.arch }}-cmake
mingw-w64-${{ matrix.arch }}-gcc
mingw-w64-${{ matrix.arch }}-lzo2
mingw-w64-${{ matrix.arch }}-libpng
- name: Install OpenGFX
shell: bash
run: |
mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
cd "C:/Users/Public/Documents/OpenTTD/baseset"
echo "::group::Download OpenGFX"
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
echo "::endgroup::"
echo "::group::Unpack OpenGFX"
unzip opengfx-all.zip
echo "::endgroup::"
rm -f opengfx-all.zip
- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Build
shell: msys2 {0}
run: |
mkdir build
cd build
echo "::group::CMake"
cmake .. -G"MSYS Makefiles"
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(nproc) cores"
cmake --build . -j $(nproc)
echo "::endgroup::"
- name: Test
shell: msys2 {0}
run: |
cd build
ctest -j $(nproc) --timeout 120
check_annotations:
name: Check Annotations
needs:
- emscripten
- linux
- macos
- windows
- msys2
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Check annotations
uses: OpenTTD/actions/annotation-check@v3

View File

@@ -1,21 +0,0 @@
name: Commit checker
on:
pull_request:
jobs:
commit-checker:
name: Commit checker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 4
- name: Get pull-request commits
uses: OpenTTD/actions/checkout-pull-request@v2
- name: Check commits
uses: OpenTTD/OpenTTD-git-hooks@main

View File

@@ -1,133 +0,0 @@
name: Preview build
on:
repository_dispatch:
types:
- Preview*
jobs:
preview:
name: Build preview
runs-on: ubuntu-20.04
container:
# If you change this version, change the number in the cache step too.
image: emscripten/emsdk:3.1.28
steps:
- name: Update deployment status to in progress
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
mediaType: |
previews:
- ant-man
- flash
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
deployment_id: ${{ github.event.client_payload.deployment_id }}
state: in_progress
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.sha }}
- name: Name branch
run: |
name=$(echo "${{ github.event.client_payload.folder }}")
git checkout -b ${name}
- name: Setup cache
uses: actions/cache@v3
with:
path: /emsdk/upstream/emscripten/cache
key: 3.1.28-${{ runner.os }}
- name: Patch Emscripten to support LZMA
run: |
cd /emsdk/upstream/emscripten
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
- name: Build (host tools)
run: |
mkdir build-host
cd build-host
echo "::group::CMake"
cmake .. -DOPTION_TOOLS_ONLY=ON
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(nproc) cores"
make -j$(nproc) tools
echo "::endgroup::"
- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Build
run: |
mkdir build
cd build
echo "::group::CMake"
emcmake cmake .. \
-DHOST_BINARY_DIR=../build-host \
-DCMAKE_BUILD_TYPE=Release \
# EOF
echo "::endgroup::"
echo "::group::Build"
echo "Running on $(nproc) cores"
emmake make -j$(nproc)
echo "::endgroup::"
- name: Publish preview
run: |
pip3 install awscli
aws s3 cp --only-show-errors build/openttd.data s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
aws s3 cp --only-show-errors build/openttd.html s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
aws s3 cp --only-show-errors build/openttd.js s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
aws s3 cp --only-show-errors build/openttd.wasm s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
# Invalidate the cache of the CloudFront distribution
aws cloudfront create-invalidation --distribution-id ${{ secrets.PREVIEW_CF_DISTRIBUTION_ID }} --paths "/${{ github.event.client_payload.folder }}/*"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Update deployment status to success
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
mediaType: |
previews:
- ant-man
- flash
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
deployment_id: ${{ github.event.client_payload.deployment_id }}
state: success
environment_url: https://preview.openttd.org/${{ github.event.client_payload.folder }}/
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: failure()
name: Update deployment status to failure
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
mediaType: |
previews:
- ant-man
- flash
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
deployment_id: ${{ github.event.client_payload.deployment_id }}
state: failure
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}

View File

@@ -1,66 +0,0 @@
name: Preview label
on:
pull_request_target:
types:
- labeled
env:
TEAM_CORE_DEVELOPER: core-developers
jobs:
check_preview_label:
name: Check for preview label
if: github.event.action == 'labeled' && github.event.label.name == 'preview'
runs-on: ubuntu-20.04
steps:
- name: Check if label was added by core developer
id: core_developer
continue-on-error: true
uses: octokit/request-action@v2.x
with:
route: GET /orgs/OpenTTD/teams/${{ env.TEAM_CORE_DEVELOPER }}/memberships/${{ github.event.sender.login }}
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: steps.core_developer.outcome == 'failure'
name: Remove preview label if not core developer
uses: octokit/request-action@v2.x
with:
route: DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/preview
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.number }}
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: steps.core_developer.outcome == 'success'
name: Create deployment
id: deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/deployments
mediaType: |
previews:
- ant-man
- flash
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
ref: ${{ github.event.pull_request.head.sha }}
task: deploy:preview
auto_merge: false
required_contexts: "[]"
environment: preview-pr-${{ github.event.number }}
description: "Preview for Pull Request #${{ github.event.number }}"
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: steps.core_developer.outcome == 'success'
name: Trigger 'preview build'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
event-type: "Preview build #${{ github.event.number }}"
client-payload: '{"folder": "pr${{ github.event.number }}", "sha": "${{ github.event.pull_request.head.sha }}", "deployment_id": "${{ fromJson(steps.deployment.outputs.data).id }}"}'

View File

@@ -1,66 +0,0 @@
name: Preview push
on:
pull_request_target:
types:
- synchronize
jobs:
check_new_preview:
name: Check preview needs update
runs-on: ubuntu-20.04
steps:
- name: Check if earlier preview exists
id: earlier_preview
uses: octokit/request-action@v2.x
with:
route: GET /repos/{owner}/{repo}/deployments
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
environment: preview-pr-${{ github.event.number }}
per_page: 1
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: toJson(fromJson(steps.earlier_preview.outputs.data)) != '[]'
name: Check for preview label
id: preview_label
uses: octokit/request-action@v2.x
with:
route: GET /repos/{owner}/{repo}/issues/{issue_number}/labels
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.number }}
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: toJson(fromJson(steps.earlier_preview.outputs.data)) != '[]' && contains(fromJson(steps.preview_label.outputs.data).*.name, 'preview')
name: Create deployment
id: deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/deployments
mediaType: |
previews:
- ant-man
- flash
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
ref: ${{ github.event.pull_request.head.sha }}
task: deploy:preview
auto_merge: false
required_contexts: "[]"
environment: preview-pr-${{ github.event.number }}
description: "Preview for Pull Request #${{ github.event.number }}"
env:
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
- if: toJson(fromJson(steps.earlier_preview.outputs.data)) != '[]' && contains(fromJson(steps.preview_label.outputs.data).*.name, 'preview')
name: Trigger 'preview build'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
event-type: "Preview build #${{ github.event.number }}"
client-payload: '{"folder": "pr${{ github.event.number }}", "sha": "${{ github.event.pull_request.head.sha }}", "deployment_id": "${{ fromJson(steps.deployment.outputs.data).id }}"}'

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +0,0 @@
name: Unused strings
on:
pull_request:
jobs:
unused-strings:
name: Unused strings
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check for unused strings
run: |
set -ex
python3 .github/unused-strings.py

7
.gitignore vendored
View File

@@ -1,7 +0,0 @@
/.vs
/build*
CMakeSettings.json
docs/aidocs/*
docs/gamedocs/*
docs/source/*
/out

View File

@@ -1,385 +0,0 @@
cmake_minimum_required(VERSION 3.9)
if(NOT BINARY_NAME)
set(BINARY_NAME openttd)
endif()
project(${BINARY_NAME}
VERSION 13.0
)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the build directory. You may need to delete \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" first.")
endif()
# Debug mode by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
if (EMSCRIPTEN)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/os/emscripten/cmake")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
# Use GNUInstallDirs to allow customisation
# but set our own default data and bin dir
if(NOT CMAKE_INSTALL_DATADIR)
set(CMAKE_INSTALL_DATADIR "share/games")
endif()
if(NOT CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR "games")
endif()
include(GNUInstallDirs)
include(Options)
set_options()
set_directory_options()
include(Static)
set_static_if_needed()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
# An empty target for the tools
add_custom_target(tools)
include(Endian)
add_endian_definition()
include(CompileFlags)
compile_flags()
if(APPLE OR UNIX)
add_definitions(-DUNIX)
endif()
if(UNIX)
find_package(Doxygen)
endif()
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
if(WIN32)
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
endif()
# Generate a target to determine version, which is execute every 'make' run
add_custom_target(find_version
${CMAKE_COMMAND}
-DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
-DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
-DREV_MAJOR=${PROJECT_VERSION_MAJOR}
-DREV_MINOR=${PROJECT_VERSION_MINOR}
-DWINDOWS=${WIN32}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
BYPRODUCTS ${GENERATED_SOURCE_FILES}
)
# Documentation
if(DOXYGEN_EXECUTABLE)
add_custom_target(docs)
add_custom_target(docs_source
${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating documentation for source"
)
add_dependencies(docs_source
find_version
)
add_dependencies(docs
docs_source
)
endif()
include(AddCustomXXXTimestamp)
if(OPTION_TOOLS_ONLY)
if(HOST_BINARY_DIR)
unset(HOST_BINARY_DIR CACHE)
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
return()
endif()
if(APPLE)
# Avoid searching for headers in Frameworks, and libraries in LIBDIR.
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
# Prefer -pthread over -lpthread, which is often the better option of the two.
set(CMAKE_THREAD_PREFER_PTHREAD YES)
# Make sure we have Threads available.
find_package(Threads REQUIRED)
find_package(ZLIB)
find_package(LibLZMA)
find_package(LZO)
find_package(PNG)
if(NOT OPTION_DEDICATED)
if(NOT WIN32)
find_package(Allegro)
if(NOT APPLE)
find_package(Freetype)
find_package(SDL2)
if(NOT SDL2_FOUND)
find_package(SDL)
endif()
find_package(Fluidsynth)
find_package(Fontconfig)
find_package(ICU OPTIONAL_COMPONENTS i18n lx)
endif()
endif()
endif()
if(APPLE)
find_package(Iconv)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(AUDIOUNIT_LIBRARY AudioUnit)
find_library(COCOA_LIBRARY Cocoa)
find_library(QUARTZCORE_LIBRARY QuartzCore)
endif()
if(NOT EMSCRIPTEN AND NOT OPTION_DEDICATED)
find_package(OpenGL COMPONENTS OpenGL)
endif()
if(MSVC)
find_package(Editbin REQUIRED)
endif()
find_package(SSE)
find_package(Xaudio2)
find_package(Grfcodec)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_FOUND)
show_options()
if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
if(NOT SDL_FOUND AND NOT SDL2_FOUND AND NOT ALLEGRO_FOUND)
message(FATAL_ERROR "SDL, SDL2 or Allegro is required for this platform")
endif()
endif()
if(APPLE)
if(NOT AUDIOTOOLBOX_LIBRARY)
message(FATAL_ERROR "AudioToolbox is required for this platform")
endif()
if(NOT AUDIOUNIT_LIBRARY)
message(FATAL_ERROR "AudioUnit is required for this platform")
endif()
if(NOT COCOA_LIBRARY)
message(FATAL_ERROR "Cocoa is required for this platform")
endif()
if(NOT QUARTZCORE_LIBRARY)
message(FATAL_ERROR "QuartzCore is required for this platform")
endif()
endif()
if(OPTION_PACKAGE_DEPENDENCIES)
if(NOT UNIX)
message(FATAL_ERROR "Can only package dependencies on Linux")
endif()
if(OPTION_INSTALL_FHS)
message(FATAL_ERROR "Cannot install in FHS folders when we are packaging dependencies")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
message(FATAL_ERROR "OPTION_PACKAGE_DEPENDENCIES can only work with CMake 3.16+; you are using ${CMAKE_VERSION}")
endif()
# If we are packaging dependencies, we do two things:
# 1) set the RPATH to include $ORIGIN/lib; $ORIGIN (that literal string)
# is a Linux indicator for "path where application is". In CMake, we
# have to do this before add_executable() is executed.
# 2) copy the libraries that we compile against to the "lib" folder.
# This is done in InstallAndPackage.cmake.
set(CMAKE_INSTALL_RPATH "\$ORIGIN/lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()
include(SourceList)
# Needed by rev.cpp
include_directories(${CMAKE_SOURCE_DIR}/src)
# Needed by everything that uses Squirrel
include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/squirrel/include)
include(MSVCFilters)
add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
# All other files are added via target_sources()
if(MSVC)
# Add DPI manifest to project; other WIN32 targets get this via ottdres.rc
target_sources(openttd PRIVATE "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest")
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/bin)
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/media)
add_dependencies(openttd
find_version)
target_link_libraries(openttd
openttd::languages
openttd::settings
openttd::media
openttd::basesets
openttd::script_api
Threads::Threads
)
if(HAIKU)
target_link_libraries(openttd "be" "network" "midi")
endif()
if(IPO_FOUND)
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True)
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True)
endif()
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
process_compile_flags()
include(LinkPackage)
link_package(PNG TARGET PNG::PNG ENCOURAGED)
link_package(ZLIB TARGET ZLIB::ZLIB ENCOURAGED)
link_package(LIBLZMA TARGET LibLZMA::LibLZMA ENCOURAGED)
link_package(LZO)
if(NOT OPTION_DEDICATED)
link_package(Fluidsynth)
link_package(SDL)
link_package(SDL2 TARGET SDL2::SDL2)
link_package(Allegro)
link_package(FREETYPE TARGET Freetype::Freetype)
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
link_package(ICU_lx)
link_package(ICU_i18n)
if(SDL2_FOUND AND OPENGL_FOUND AND UNIX)
# SDL2 dynamically loads OpenGL if needed, so do not link to OpenGL when
# on Linux. For Windows, we need to link to OpenGL as we also have a win32
# driver using it.
add_definitions(-DWITH_OPENGL)
message(STATUS "OpenGL found -- -DWITH_OPENGL -- (via SDL2)")
else()
link_package(OpenGL TARGET OpenGL::GL)
endif()
endif()
if(APPLE)
link_package(Iconv TARGET Iconv::Iconv)
target_link_libraries(openttd
${AUDIOTOOLBOX_LIBRARY}
${AUDIOUNIT_LIBRARY}
${COCOA_LIBRARY}
${QUARTZCORE_LIBRARY}
)
add_definitions(
-DWITH_COCOA
)
endif()
if(EMSCRIPTEN)
add_library(WASM::WASM INTERFACE IMPORTED)
# Allow heap-growth, and start with a bigger memory size.
target_link_libraries(WASM::WASM INTERFACE "-s ALLOW_MEMORY_GROWTH=1")
target_link_libraries(WASM::WASM INTERFACE "-s INITIAL_MEMORY=33554432")
target_link_libraries(WASM::WASM INTERFACE "-s DISABLE_EXCEPTION_CATCHING=0")
add_definitions(-s DISABLE_EXCEPTION_CATCHING=0)
# Export functions to Javascript.
target_link_libraries(WASM::WASM INTERFACE "-s EXPORTED_FUNCTIONS='[\"_main\", \"_em_openttd_add_server\"]' -s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
# Preload all the files we generate during build.
# As we do not compile with FreeType / FontConfig, we also have no way to
# render several languages (like Chinese, ..), so where do you draw the
# line what languages to include and which not? In the end, especially as
# the more languages you add the slower downloading becomes, we decided to
# only ship the English language.
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_BINARY_DIR}/baseset@/baseset")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_BINARY_DIR}/lang/english.lng@/lang/english.lng")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/bin/ai@/ai")
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/bin/game@/game")
# We use IDBFS for persistent storage.
target_link_libraries(WASM::WASM INTERFACE "-lidbfs.js")
# Use custom pre-js and shell.html.
target_link_libraries(WASM::WASM INTERFACE "--pre-js ${CMAKE_SOURCE_DIR}/os/emscripten/pre.js")
target_link_libraries(WASM::WASM INTERFACE "--shell-file ${CMAKE_SOURCE_DIR}/os/emscripten/shell.html")
# Build the .html (which builds the .js, .wasm, and .data too).
set_target_properties(openttd PROPERTIES SUFFIX ".html")
target_link_libraries(openttd WASM::WASM)
endif()
if(NOT PERSONAL_DIR STREQUAL "(not set)")
add_definitions(
-DWITH_PERSONAL_DIR
-DPERSONAL_DIR="${PERSONAL_DIR}"
)
endif()
if(NOT SHARED_DIR STREQUAL "(not set)")
add_definitions(
-DWITH_SHARED_DIR
-DSHARED_DIR="${SHARED_DIR}"
)
endif()
if(NOT GLOBAL_DIR STREQUAL "(not set)")
add_definitions(
-DGLOBAL_DATA_DIR="${GLOBAL_DIR}"
)
endif()
link_package(SSE)
add_definitions_based_on_options()
if(WIN32)
add_definitions(
-DUNICODE
-D_UNICODE
-DWITH_UNISCRIBE
-DPSAPI_VERSION=1
)
target_link_libraries(openttd
ws2_32
winmm
imm32
usp10
psapi
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DPOINTER_IS_64BIT)
endif()
include(CreateRegression)
create_regression()
if(APPLE OR WIN32)
find_package(Pandoc)
endif()
include(InstallAndPackage)

View File

@@ -1,150 +0,0 @@
# Compiling OpenTTD
## Required/optional libraries
OpenTTD makes use of the following external libraries:
- (encouraged) zlib: (de)compressing of old (0.3.0-1.0.5) savegames, content downloads,
heightmaps
- (encouraged) liblzma: (de)compressing of savegames (1.1.0 and later)
- (encouraged) libpng: making screenshots and loading heightmaps
- (optional) liblzo2: (de)compressing of old (pre 0.3.0) savegames
For Linux, the following additional libraries are used (for non-dedicated only):
- libSDL2: hardware access (video, sound, mouse)
- libfreetype: loading generic fonts and rendering them
- libfontconfig: searching for fonts, resolving font names to actual fonts
- libicu: handling of right-to-left scripts (e.g. Arabic and Persian) and
natural sorting of strings
OpenTTD does not require any of the libraries to be present, but without
liblzma you cannot open most recent savegames and without zlib you cannot
open most older savegames or use the content downloading system.
## Windows
You need Microsoft Visual Studio 2017 or more recent.
You can download the free Visual Studio Community Edition from Microsoft at
https://visualstudio.microsoft.com/vs/community/.
OpenTTD needs the Platform SDK, if it isn't installed already. This can be
done during installing Visual Studio, by selecting
`Visual C++ MFC for x86 and x64` (and possibly
`Visual C++ ATL for x86 and x64` depending on your version). If not, you
can get download it as [MS Windows Platform SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk).
Install the SDK by following the instructions as given.
Dependencies for OpenTTD on Windows are handled via
[vcpkg](https://github.com/Microsoft/vcpkg/). First you need to install vcpkg
by following the `Quick Start` instructions of their
[README](https://github.com/Microsoft/vcpkg/blob/master/README.md).
After this, you can install the dependencies OpenTTD needs. We advise to use
the `static` versions, and OpenTTD currently needs the following dependencies:
- liblzma
- libpng
- lzo
- zlib
To install both the x64 (64bit) and x86 (32bit) variants (though only one is necessary), you can use:
```ps
.\vcpkg install liblzma:x64-windows-static libpng:x64-windows-static lzo:x64-windows-static zlib:x64-windows-static
.\vcpkg install liblzma:x86-windows-static libpng:x86-windows-static lzo:x86-windows-static zlib:x86-windows-static
```
You can open the folder (as a CMake project). CMake will be detected, and you can compile from there.
If libraries are installed but not found, you need to set VCPKG_TARGET_TRIPLET in CMake parameters.
For Visual Studio 2017 you also need to set CMAKE_TOOLCHAIN_FILE.
(Typical values are shown in the MSVC project file command line example)
Alternatively, you can create a MSVC project file via CMake. For this
either download CMake from https://cmake.org/download/ or use the version
that comes with vcpkg. After that, you can run something similar to this:
```powershell
mkdir build
cd build
cmake.exe .. -G"Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="<location of vcpkg>\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static"
```
Change `<location of vcpkg>` to where you have installed vcpkg. After this
in the build folder are MSVC project files. MSVC can rebuild the project
files himself via the `ZERO_CHECK` project.
## All other platforms
Minimum required version of CMake is 3.9.
By default this produces a Debug build with assertations enabled.
This is a far slower build than release builds.
```bash
mkdir build
cd build
cmake ..
make
```
For more information on how to use CMake (including how to make Release builds),
we urge you to read [their excellent manual](https://cmake.org/cmake/help/latest/guide/user-interaction/index.html).
## CMake Options
Via CMake, several options can be influenced to get different types of
builds.
- `-DCMAKE_BUILD_TYPE=RelWithDebInfo`: build a release build. This is
significant faster than a debug build, but has far less useful information
in case of a crash.
- `-DOPTION_DEDICATED=ON`: build OpenTTD without a GUI. Useful if you are
running a headless server, as it requires less libraries to operate.
- `-DOPTION_USE_ASSERTS=OFF`: disable asserts. Use with care, as assert
statements capture early signs of trouble. Release builds have them
disabled by default.
- `-DOPTION_USE_THREADS=OFF`: disable the use of threads. This will block
the interface in many places, and in general gives a worse experience of
the game. Use with care.
- `-DOPTION_TOOLS_ONLY=ON`: only build tools like `strgen`. Does not build
the game itself. Useful for cross-compiling.
## Supported compilers
Every compiler that is supported by CMake and supports C++17, should be
able to compile OpenTTD. As the exact list of compilers changes constantly,
we refer to the compiler manual to see if it supports C++17, and to CMake
to see if it supports your compiler.
## Compilation of base sets
To recompile the extra graphics needed to play with the original Transport
Tycoon Deluxe graphics you need GRFCodec (which includes NFORenum) as well.
GRFCodec can be found at
https://www.openttd.org/downloads/grfcodec-releases/latest.html.
Having GRFCodec installed can cause regeneration of the `.grf` files, which
are written in the source directory. This can leave your repository in a
modified state, as different GRFCodec versions can cause binary differences
in the resulting `.grf` files. Also translations might have been added for
the base sets which are not yet included in the base set information files.
To avoid this behaviour, disable GRFCodec (and NFORenum) in CMake cache
(`GRFCODEC_EXECUTABLE` and `NFORENUM_EXECUTABLE`).
## Developers settings
You can control some flags directly via `CXXFLAGS` (any combination
of these flags will work fine too):
- `-DRANDOM_DEBUG`: this helps with debugging desyncs.
- `-fno-inline`: this avoids creating inline functions; this can make
debugging a lot easier.
- `-O0`: this disables all optimizations; this can make debugging a
lot easier.
- `-p`: this enables profiling.
Always use a clean buildfolder if you changing `CXXFLAGS`, as this
value is otherwise cached. Example use:
`CXXFLAGS="-fno-inline" cmake ..`

View File

@@ -1,269 +0,0 @@
# Contributing to OpenTTD
Looking to contribute something to OpenTTD? **Here's how you can help.**
Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project.
In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
## Using the issue tracker
The [issue tracker](https://github.com/OpenTTD/OpenTTD/issues) is the preferred channel for [bug reports](#bug-reports), but please respect the following restrictions:
* Please **do not** use the issue tracker for help playing or using OpenTTD.
Please try [irc](https://wiki.openttd.org/en/Development/IRC%20channel), or the [forums](https://www.tt-forums.net/)
* Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others.
* Please **do not** post comments consisting solely of "+1" or ":thumbsup:".
Use [GitHub's "reactions" feature](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) instead.
We reserve the right to delete comments which violate this rule.
* Please **do not** open issues or pull requests regarding add-on content in NewGRF, GameScripts, AIs, etc.
These are created by third-parties. Please try [irc](https://wiki.openttd.org/en/Development/IRC%20channel) or the [forums](https://www.tt-forums.net/) to discuss these.
* Please use [the web translator](https://translator.openttd.org/) to submit corrections and improvements to translations of the game.
## Bug reports
A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful, so thanks!
Guidelines for bug reports:
0. Please don't report issues with games where you changed NewGRFs mid-game. (This can be verified with the `gamelog` console command in-game.)
1. Please don't report issues with modified versions of OpenTTD (patchpacks, unofficial ports, and similar).
2. **Use the GitHub issue search** — check if the issue has already been
reported.
3. **Check if the issue has been fixed** — try to reproduce it using the latest `nightly` build of OpenTTD, available from https://www.openttd.org
4. **Isolate the problem** — ideally create reproducible steps with an attached savegame and screenshots. Try to use few or no NewGRFs, AIs etc if possible.
A good bug report shouldn't leave others needing to chase you up for more information.
Please try to be as detailed as possible in your report.
* What is your environment?
* What steps will reproduce the issue?
* Which operating system(s) experience the problem?
* What would you expect to be the outcome?
All these details will help people to fix any potential bugs.
Example:
> Short and descriptive example bug report title
>
> A summary of the issue and the OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>
> Attached savegame
> Attached screenshots showing the issue
> Crashlogs if the bug causes a crash
>
> Any other information you want to share that is relevant to the issue being
> reported. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).
## Feature requests
Before opening a feature request, please take a moment to find out whether your idea fits with the [scope and goals](./CONTRIBUTING.md#project-goals) of the project.
It's up to *you* to make a strong case to convince the project's developers of the merits of this feature.
Please provide as much detail and context as possible.
This means don't request for a solution, but describe the problem you see and how/why you think it should be fixed.
For feature request we have a strict policy.
Keeping issues around with "a good idea" or "not really a bug but we should maybe fix it" turns out to have the reversed effect: nobody looks at it anymore.
Although we really appreciate feedback and ideas, we will close feature requests that we don't expect to fulfill in the next year.
Many of those ideas etc do have a place on the [forums](https://www.tt-forums.net); and if enough people like it, someone will stand up and make it.
It's usually best to discuss on [Discord](https://discord.gg/openttd) before opening a feature request or working on a large feature in a fork.
Discussion can take time, but it can be productive and avoid disappointment. :)
## Pull requests
Good pull requests—patches, improvements, new features—are a fantastic help.
Pull requests should fit with the [goals of the project](./CONTRIBUTING.md#project-goals).
**Please do ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
Every pull request should have a clear scope, with no unrelated commits.
[Code style](https://wiki.openttd.org/en/Development/Coding%20style) must be complied with for pull requests to be accepted; this also includes [commit message format](https://wiki.openttd.org/en/Development/Coding%20style#commit-message).
Adhering to the following process is the best way to get your work included in the project:
1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
```bash
git clone https://github.com/<your-username>/OpenTTD.git openttd
git clone https://github.com/OpenTTD/OpenTTD-git-hooks.git openttd_hooks
cd openttd
git remote add upstream https://github.com/OpenTTD/OpenTTD.git
cd .git/hooks
ln -s ../../../openttd_hooks/hooks/* .
```
2. If you cloned a while ago, get the latest changes from upstream:
```bash
git fetch upstream
```
3. Create a new topic branch (off the main project development branch) to
contain your feature, change, or fix:
```bash
git checkout upstream/master -b <topic-branch-name>
```
4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](https://wiki.openttd.org/en/Development/Coding%20style#commit-message) or your code is unlikely to be merged into the main project.
Use Git's [interactive rebase](https://docs.github.com/en/get-started/using-git/about-git-rebase) feature to tidy up your commits before making them public.
5. Locally rebase the upstream development branch into your topic branch:
```bash
git fetch upstream
git rebase upstream/master
```
6. Push your topic branch up to your fork the first time:
```bash
git push --set-upstream origin <topic-branch-name>
```
And any time after that:
```bash
git push
```
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description against the `master` branch.
**IMPORTANT**: By submitting a pull request or patch, you agree to the [License](#license) and the [Privacy Notice](CONTRIBUTING.md#privacy-notice).
### Pull request validation
Continuous integration (CI) tools monitor pull requests, and help us identify build and code quality issues.
The results of the CI tests will show on your pull request.
By clicking on Details you can further zoom in; in case of a failure it will show you why it failed.
In case of success it will report how awesome you were.
Tip: [commit message format](https://wiki.openttd.org/en/Development/Coding%20style#commit-message) is a common reason for pull requests to fail validation.
### Are there any development docs?
There is no single source for OpenTTD development docs. It's a complex project with a long history, and multiple APIs.
A good entry point is [Development](https://wiki.openttd.org/en/Development/) on the OpenTTD wiki; this provides links to wiki documentation and other sources.
The GitHub repo also includes some non-comprehensive documentation in [/docs](./docs).
You may also want the guide to [compiling OpenTTD](./COMPILING.md).
## Project goals
### What are the goals of the official branch?
The main goals of the official branch are:
- Stay faithful to the original gameplay from Transport Tycoon Deluxe
- Improve the user interface
- Allow extending the gameplay with add-ons / mods via supported content APIs
- Provide a (relatively) stable core for both players of the official branch, and for authors of add-ons and maintainers of patchpacks
In contrast, extending or altering the gameplay of the base game is not encouraged.
The rationale behind these goals is that people have different opinions about what OpenTTD is and what it should be.
When it comes to gameplay, there are at least these groups of people:
- *Model railway (mostly singleplayer)*: build "realistic" landscapes, roleplay a world, or even replicate historical scenarios
- *Economical challenge (mostly singleplayer)*: run a business with economical challenges
- *Transport challenge (singleplayer or cooperative multiplayer)*: build efficient track layouts with high cargo throughput and tons of vehicles
- *Competitive speed run (competitive multiplayer)*: maximize some goal in some limited amount of time
When it comes to gameplay features there are at least these groups of interests:
- *Control freak:* micromanagement like conditional orders, refitting and loading etc.
- *Casual:* automatisation like cargodist, path based signalling etc.
To please everyone, the official branch tries to stay close to the original gameplay; after all, that is what brought everyone here.
The preferred method to alter and extend the gameplay is via add-ons like NewGRF and GameScripts.
For a long time, the official branch was also open to features which could be enabled/disabled, but the corner-cases that came with some configurations have rendered some parts of the code very complicated.
Today, new features have to work with all the already existing features, which is not only challenging in corner cases, but also requires spending considerable more work than just "making it work in the game mode that I play".
The preferred method to introduce new gameplay features is to extend the content APIs, supporting ever more add-on content / mods.
This moves conflict-solving away from the codebase to content authors / players.
It is more accepted for add-ons not working together than the base game not working with certain setting combinations.
In general the game should allow anything that doesn't violate basic rules, but it should warn players if they take potentially dangerous or "stupid" actions.
For example, players are not prevented from starting vehicles without orders, but will receive a warning about vehicles having too few orders.
This lack of limitation has led to players challenging themselves to create networks where all vehicles have no orders, increasing gameplay possibilities.
### I do not agree with the goals of the official branch, what can I do instead?
Fork! There is a rich history of experimental patches for OpenTTD.
Many of these will never be accepted for core, but are creative and interesting ways to modify OpenTTD.
Sometimes patches are combined into long-running patchpacks, modified OpenTTD versions which can be downloaded by anyone, or modified OpenTTD clients for dedicated multiplayer servers.
One of the reasons to keep core relatively stable is to make life easier for patch authors and patchpack maintainers where possible.
Patchpack discussions and related topics may be found in community sites such as [TT-Forums development section](https://www.tt-forums.net/viewforum.php?f=33).
## Legal stuff
### License
By contributing your code, you agree to license your contribution under the [GPL v2](https://github.com/OpenTTD/OpenTTD/blob/master/COPYING.md).
### Privacy Notice
We would like to make you aware that contributing to OpenTTD via git will permanently store the name and email address you provide as well as the actual changes and the time and date you made it inside git's version history.
This is inevitable, because it is a main feature of git.
If you are concerned about your privacy, we strongly recommend to use "Anonymous &lt;anonymous@openttd.org&gt;" as the git commit author. We might refuse anonymous contributions if malicious intent is suspected.
Please note that the contributor identity, once given, is used for copyright verification and to provide proof should a malicious commit be made.
As such, the [EU GDPR](https://www.eugdpr.org/key-changes.html) "right to be forgotten" does not apply, as this is an overriding legitimate interest.
Please also note that your commit is public and as such will potentially be processed by many third-parties.
Git's distributed nature makes it impossible to track where exactly your commit, and thus your personal data, will be stored and be processed.
If you would not like to accept this risk, please do either commit anonymously or refrain from contributing to the OpenTTD project.
### Attribution of this Contributing Guide
This contributing guide is adapted from [Bootstrap](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md) under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/) terms for Bootstrap documentation.
The GDPR notice is adapted from [rsyslog](https://github.com/rsyslog/rsyslog/blob/master/CONTRIBUTING.md) under the [GNU General Public License](https://github.com/rsyslog/rsyslog/blob/master/COPYING).

View File

@@ -1,69 +1,65 @@
This is the license which applies to OpenTTD with the exception of some
3rd party modules. See [./README.md](./README.md) for details
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU General Public License
==========================
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
_Version 2, June 1991_
_Copyright © 1989, 1991 Free Software Foundation, Inc.,_
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
Preamble
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
### Preamble
The licenses for most software are designed to take away your
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: **(1)** copyright the software, and
**(2)** offer you this license which gives you legal permission to copy,
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
**0.** This License applies to any program or other work which contains
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
@@ -80,7 +76,7 @@ is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
**1.** You may copy and distribute verbatim copies of the Program's
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
@@ -91,28 +87,30 @@ along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
**2.** You may modify your copy or copies of the Program or any portion
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
* **a)** You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
* **b)** You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
* **c)** If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -133,24 +131,26 @@ with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
**3.** You may copy and distribute the Program (or a work based on it,
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
* **a)** Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
* **b)** Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
* **c)** Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
@@ -168,8 +168,8 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
**4.** You may not copy, modify, sublicense, or distribute the Program
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
@@ -177,7 +177,7 @@ However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
**5.** You are not required to accept this License, since you have not
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
@@ -186,7 +186,7 @@ Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
**6.** Each time you redistribute the Program (or any work based on the
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
@@ -194,7 +194,7 @@ restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
**7.** If, as a consequence of a court judgment or allegation of patent
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
@@ -225,8 +225,8 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
**8.** If the distribution and/or use of the Program is restricted in
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
@@ -234,7 +234,7 @@ those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
**9.** The Free Software Foundation may publish revised and/or new versions
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
@@ -247,7 +247,7 @@ Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
**10.** If you wish to incorporate parts of the Program into other free
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
@@ -255,9 +255,9 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
### NO WARRANTY
NO WARRANTY
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
@@ -267,7 +267,7 @@ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
@@ -277,15 +277,15 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
@@ -303,9 +303,10 @@ the "copyright" line and a pointer to where the full notice is found.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
@@ -317,23 +318,23 @@ when it starts in an interactive mode:
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w` and `show c` should show the appropriate
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w` and `show c`; they could even be
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -1,12 +0,0 @@
# Make the current version available to CPack
set(CPACK_PACKAGE_VERSION "@REV_VERSION@")
# Name the output file with the correct version
string(REPLACE "#CPACK_PACKAGE_VERSION#" "@REV_VERSION@" CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
if (CPACK_BUNDLE_PLIST_SOURCE)
# Rewrite the Info.plist.in to contain the correct version
file(READ ${CPACK_BUNDLE_PLIST_SOURCE} INFO_PLIST_CONTENT)
string(REPLACE "#CPACK_PACKAGE_VERSION#" "@REV_VERSION@" INFO_PLIST_CONTENT "${INFO_PLIST_CONTENT}")
file(WRITE ${CPACK_BUNDLE_PLIST} "${INFO_PLIST_CONTENT}")
endif (CPACK_BUNDLE_PLIST_SOURCE)

View File

@@ -1,61 +0,0 @@
### The OpenTTD team (in alphabetical order):
- Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)
- Christoph Elsenhans (frosch) - General coding (since 0.6)
- Loïc Guilloux (glx) - General / Windows Expert (since 0.4.5)
- Charles Pigott (LordAro) - General / Correctness police (since 1.9)
- Michael Lutz (michi_cc) - General / Path based signals (since 0.7)
- Niels Martin Hansen (nielsm) - Music system, general coding (since 1.9)
- Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)
- Peter Nelson (peter1138) - Spiritual descendant from newGRF gods (since 0.4.5)
- Remko Bijker (Rubidium) - Coder and way more (since 0.4.5)
- Patric Stout (TrueBrain) - NoProgrammer (since 0.3), sys op
- Tyler Trahan (2TallTyler) - General coding (since 13)
### Inactive Developers:
- Grzegorz Duczyński (adf88) - General coding (1.7 - 1.8)
- Albert Hofkamp (Alberth) - GUI expert (0.7 - 1.9)
- Jean-François Claeys (Belugas) - GUI, newindustries and more (0.4.5 - 1.0)
- Bjarni Corfitzen (Bjarni) - macOS port, coder and vehicles (0.3 - 0.7)
- Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)
- Ulf Hermann (fonsinchen) - Cargo Distribution (1.3 - 1.6)
- Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)
- Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)
- Attila Bán (MiHaMiX) - Developer WebTranslator 1 and 2 (0.3 - 0.5)
- Ingo von Borstel (planetmaker) - General coding, Support (1.1 - 1.9)
- Zdeněk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)
- José Soler (Terkhen) - General coding (1.0 - 1.4)
- Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)
- Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)
- Leif Linse (Zuu) - AI/Game Script (1.2 - 1.6)
### Retired Developers:
- Tamás Faragó (Darkvater) - Ex-Lead coder (0.3 - 0.5)
- Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)
- Emil Djupfeld (egladil) - macOS port (0.4.5 - 0.6)
- Simon Sasburg (HackyKid) - Bug fixer (0.4 - 0.4.5)
- Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)
- Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)
- Petr Baudiš (pasky) - Many patches, newgrf support (0.3 - 0.3)
- Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)
- Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)
### Thanks to:
- Josef Drexler - For his great work on TTDPatch.
- Marcin Grzegorczyk - For his TTDPatch work and documentation of Transport Tycoon Deluxe internals and track foundations
- Stefan Meißner (sign_de) - For his work on the console
- Mike Ragsdale - OpenTTD installer
- Christian Rosentreter (tokai) - MorphOS / AmigaOS port
- Richard Kempton (RichK67) - Additional airports, initial TGP implementation
- Alberto Demichelis - Squirrel scripting language
- L. Peter Deutsch - MD5 implementation
- Michael Blunck - For revolutionizing TTD with awesome graphics
- George - Canal/Lock graphics
- Andrew Parkhouse (andythenorth) - River graphics
- David Dallaston (Pikka) - Tram tracks
- All Translators - For their support to make OpenTTD a truly international game
- Bug Reporters - Thanks for all bug reports
- Chris Sawyer - For an amazing game!

View File

@@ -1,24 +1,16 @@
# This file is part of OpenTTD.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
# Doxyfile 1.5.4
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "OpenTTD AI API"
PROJECT_NUMBER = ${REV_VERSION}
OUTPUT_DIRECTORY = ${CPACK_BINARY_DIR}/docs/ai-api/
PROJECT_NAME = openttd
OUTPUT_DIRECTORY = docs/source/
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class " \
"The $name widget " \
"The $name file " \
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
@@ -34,48 +26,43 @@ STRIP_FROM_PATH = ./
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 2
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = YES
INTERNAL_DOCS = YES
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
@@ -84,39 +71,40 @@ QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = YES
WARN_FORMAT = "$file:$line: $text "
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = . ${FIND_VERSION_BINARY_DIR}/script/api
INPUT_ENCODING = UTF-8
FILE_PATTERNS = script_*.hpp \
ai_*.hpp
INPUT = ./
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.h \
table/*.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = ai_includes.hpp
EXCLUDE_SYMBOLS = GetClassName DECLARE_ENUM_AS_BIT_SET DECLARE_POSTFIX_INCREMENT
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER = "./doxygen_filter.sh AI"
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
@@ -132,16 +120,16 @@ HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
GENERATE_HTMLHELP = NO
HTML_DYNAMIC_SECTIONS = NO
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = YES
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
TOC_EXPAND = YES
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 1
GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
@@ -170,7 +158,7 @@ RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
GENERATE_MAN = YES
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
@@ -179,6 +167,8 @@ MAN_LINKS = NO
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
@@ -195,21 +185,22 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = DOXYGEN_API
EXPAND_AS_DEFINED = DEF_COMMAND
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = ${CPACK_BINARY_DIR}/docs/openttd_ai_api.tag
GENERATE_TAGFILE = openttd.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
@@ -224,17 +215,17 @@ TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine

View File

@@ -1,350 +0,0 @@
# This file is part of OpenTTD.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "OpenTTD Source"
PROJECT_NUMBER = ${REV_VERSION}
PROJECT_BRIEF =
PROJECT_LOGO =
OUTPUT_DIRECTORY = ${CPACK_BINARY_DIR}/docs/source/
CREATE_SUBDIRS = YES
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = ./
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 2
ALIASES =
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
TOC_INCLUDE_HEADINGS = 0
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
GROUP_NESTED_COMPOUNDS = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = NO
LOOKUP_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = YES
EXTRACT_PACKAGE = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
EXTRACT_ANON_NSPACES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
HIDE_COMPOUND_REFERENCE= NO
SHOW_INCLUDE_FILES = YES
SHOW_GROUPED_MEMB_INC = NO
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
LAYOUT_FILE =
CITE_BIB_FILES =
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_AS_ERROR = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./src/
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.h \
*.hpp
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = */3rdparty \
*/script/api
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH = ./docs/
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
HTML_DYNAMIC_MENUS = YES
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_NAME = Publisher
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = YES
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = org.doxygen.Project
QHP_VIRTUAL_FOLDER = doc
QHP_CUST_FILTER_NAME =
QHP_CUST_FILTER_ATTRS =
QHP_SECT_FILTER_ATTRS =
QHG_LOCATION =
GENERATE_ECLIPSEHELP = NO
ECLIPSE_DOC_ID = org.doxygen.Project
DISABLE_INDEX = NO
GENERATE_TREEVIEW = YES
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
USE_MATHJAX = NO
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
MATHJAX_EXTENSIONS =
MATHJAX_CODEFILE =
SEARCHENGINE = NO
SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
SEARCHENGINE_URL =
SEARCHDATA_FILE = searchdata.xml
EXTERNAL_SEARCH_ID =
EXTRA_SEARCH_MAPPINGS =
#---------------------------------------------------------------------------
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
LATEX_FOOTER =
LATEX_EXTRA_STYLESHEET =
LATEX_EXTRA_FILES =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
LATEX_SOURCE_CODE = NO
LATEX_BIB_STYLE = plain
LATEX_TIMESTAMP = NO
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
RTF_SOURCE_CODE = NO
#---------------------------------------------------------------------------
# Configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_SUBDIR =
MAN_LINKS = NO
#---------------------------------------------------------------------------
# Configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# Configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
GENERATE_DOCBOOK = NO
DOCBOOK_OUTPUT = docbook
DOCBOOK_PROGRAMLISTING = NO
#---------------------------------------------------------------------------
# Configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = WITH_ZLIB \
WITH_LZO \
WITH_LIBLZMA \
WITH_SDL \
WITH_PNG \
WITH_FONTCONFIG \
WITH_FREETYPE \
WITH_ICU_I18N \
WITH_ICU_LX \
UNICODE \
_UNICODE \
_GNU_SOURCE \
FINAL=
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration options related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = ${CPACK_BINARY_DIR}/docs/openttd.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
DIA_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
DOT_NUM_THREADS = 0
DOT_FONTNAME = Helvetica
DOT_FONTSIZE = 10
DOT_FONTPATH =
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
UML_LIMIT_NUM_FIELDS = 10
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
INTERACTIVE_SVG = NO
DOT_PATH =
DOTFILE_DIRS =
MSCFILE_DIRS =
DIAFILE_DIRS =
PLANTUML_JAR_PATH =
PLANTUML_CFG_FILE =
PLANTUML_INCLUDE_PATH =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES

994
Makefile Normal file
View File

@@ -0,0 +1,994 @@
# $Id$
##############################################################################
#
# Usage
#
# Synopsis:
#
# make WITH_ZLIB=1 UNIX=1 MANUAL_CONFIG=1
#
# (See below for the list of possible options.)
#
# Alternately, you can run make without the MANUAL_CONFIG part. It then
# generates Makefile.config, where you can customize all the options.
# However beware that for all subsequent calls the option values from
# Makefile.config take precedence to the commandline options.
#
# (That means that you probably want to either specify the options on command
# line together with MANUAL_CONFIG=1 or you want to specify no commandline
# options at all.)
# Targets:
#
# Defaults to building binary
# clean: remove intermediate build files
# mrproper: remove intermediate files and makefile configuration
# upgradeconf: add new options to old Makefile.config
# osx: OS X application
# release: used by OSX to make a dmg file ready to release
# Options:
#
# Summary of OS choice defines
# WIN32: building on Windows
# UNIX: building on *nix derivate (Linux, FreeBSD)
# OSX: building on Mac OS X
# MORPHOS: building on MorphOS
# BEOS: building on BeOS
# SUNOS: building on SunOS (Solaris)
#
# Summary of library choice defines
# WITH_ZLIB: savegames using zlib
# WITH_PNG: screenshots using PNG
# WITH_SDL: SDL video driver support
# WITH_COCOA: Cocoa video driver support
#
# Summary of other defines:
# DEBUG: build in debug mode
# PROFILE: build in profile mode, disables -s and -fomit-frame-pointer
# TRANSLATOR: build in translator mode (untranslated strings are prepended by
# a <TODO> mark)
# RELEASE: this will be the released version number. It replaces all places
# where it normally would print the revision number
# MIDI: if set, it will use it as custom path to midi player.
# If unset, it will use the hardcoded path in the c code
# This can still be overriden by the music.extmidi openttd.cfg option.
# WITH_DIRECTMUSIC: enable DirectMusic MIDI support
# WITH_NETWORK: enable networking
# DEDICATED: allows compilation on UNIX without SDL. Useful for dedicated servers
# MAX_NUM_AUTOSAVES: sets the number of autosaves the games will make before starting
# to overwrite the old ones. If not set, the game will use 16.
# NOTE: assign a number, not a string of a number
#
# Paths:
# INSTALL: If not set, the game uses the directory of the binary to
# store everything (lang, data, gm, save and openttd.cfg), this is the `old' behaviour.
# In this case, none of the following paths are used, you also should _not_
# use `make install', but copy the required stuff yourself (or just play out
# of you source directory, which should work fine).
# If you want to use `make install' to install the game globally, you should
# define it _before_ you build the game. If you only define INSTALL when you
# do `make install', the game won't be able to find it's files (so you should
# also define all the following paths before building).
#
# So, the following paths should be defined if INSTALL is defined.
# None of these paths have to end with /
# PREFIX: Normally /usr/local
# BINARY_DIR: The location of the binary, normally games. (Will be prefixed
# with $PREFIX)
# DATA_DIR: The location of the data (lang, data, gm and scenario), normally
# share/games/openttd. (Will be prefixed with $PREFIX) Note that scenarios
# are only put here if USE_HOMEDIR is true, otherwise they are placed in
# PERSONAL_DIR/scenario
# ICON_DIR: The location of the openttd icon. (Will be prefixed with
# $PREFIX).
# PERSONAL_DIR: The directory where openttd.cfg and the save folder will be
# stored. You cannot use ~ here, define USE_HOMEDIR for that.
# USE_HOMEDIR: If this variable is set, PERSONAL_DIR will be prefixed with
# ~/ at runtime (the user's homedir)
# SECOND_DATA_PATH Use this data dir if a file is not found in the data dir in the data path
# CUSTOM_LANG_PATH If this is set, it will use the path given to search for lng files
# instead of the lang dir in the data path
# NOTE: both SECOND_DATA_PATH and CUSTOM_LANG_PATH uses paths relative to where OTTD is opened
#
# DEST_DIR: make install will use this directory instead of the filesystem
# root to install its files. This should normally not be used by
# ordinary users, currently it is only used for the debian
# packaging. This value should only be set when calling `make
# install' and is not saved in Makefile.config
# (Note that DESTDIR is checked if DEST_DIR is not set.)
#
# STATIC: link statically
# CYGWIN: build in Cygwin environment
# MINGW: build with MingW compiler, link with MingW libraries
#
# VERBOSE: show full compiler invocations instead of brief progress messages
#
# Special for crosscompiling there are some commands available:
#
# UNIVERSAL_BINARY: builds a universal binary for OSX. Make sure you got both PPC and x86 libs. Only works with GCC 4 or newer
# TRIPLE_BINARY: builds a universal binary with the addition of code optimised for G5 (which means a total of 3 binaries in one file)
# OTTD_PPC, OTTD_PPC970, OTTD_i386: compile for target architecture.
# Multiple flags can be used so OTTD_PPC:=1 OTTD_i386:=1 produces the same result as UNIVERSAL_BINARY
#
# JAGUAR: Crosscompiling for OSX 1.2.8 (codenamed Jaguar). Only works if OSX is defined too. Only works with GCC 4 or newer
# This can be changed to any PPC version of OSX by changing the ppc flags in Makefile.config
#
# ENDIAN_FORCE: forces the endian-check to give a certain result. Can be BE, LE or PREPROCESSOR.
# PREPROCESSOR is always used on all OSX targets and will make the preprocessor pick the right endian.
# this means that you don't have to think about endianess when compiling for OSX.
# Very useful for universal binaries and crosscompilers. Not sure if it works on non OSX targets
# WINDRES: the location of your windres
# CC_HOST: the gcc of your localhost if you are making a target that produces incompatible executables
# CFLAGS_HOST: cflags used for CC_HOST. Make it something if you are getting errors when you try to compi
# windows executables on linux. (just: CFLAGS_HOST:='-I' or something)
##############################################################################
#
# Configuration
#
# Makefile version tag
# it checks if the version tag in Makefile.config is the same and force update outdated config files
MAKEFILE_VERSION:=10
# Automatic configuration
MAKE_CONFIG:=Makefile.config
MAKEFILE:=Makefile
LIB_DETECTION=makefiledir/Makefile.libdetection
CONFIG_WRITER=makefiledir/Makefile.config_writer
# Apply automatic configuration
# See target section for how this is built, suppress errors
# since first time it isn't found but make reads this twice
-include $(MAKE_CONFIG)
# updates Makefile.config if it's outdated
ifneq ($(MAKEFILE_VERSION),$(CONFIG_VERSION))
UPDATECONFIG:=upgradeconf
CONFIG_INCLUDED:=
endif
# this is used if there aren't any Makefile.config
ifndef CONFIG_INCLUDED
# sets network on by default if there aren't any config file
ENABLE_NETWORK:=1
# paths for make install
# disabled as they would break it for some (many?) people if they were default
#PREFIX:=/usr/local
#DATA_DIR:=share/games/openttd
#BINARY_DIR:=games
#PERSONAL_DIR:=.openttd
#USE_HOMEDIR:=1
-include $(LIB_DETECTION)
endif
ifdef SUPRESS_LANG_ERRORS
LANG_ERRORS = >/dev/null 2>&1
endif
ifdef OSX
-include os/MacOSX/Makefile.setup
endif
ifdef STATIC
ifndef WIN32
ifndef OSX
ifndef MORPHOS
ifndef SKIP_STATIC_CHECK
$(error Static is only known to work on MorphOS and MacOSX!!! --- Check Makefile.config for more info and howto bypass this check)
endif
endif
endif
endif
endif
ifdef WITH_COCOA
ifdef WITH_SDL
$(error You can not use both the SDL video driver and the Cocoa video driver at the same time)
endif
ifdef DEDICATED
$(error You can not use the Cocoa video driver in a dedicated server)
endif
else
# Force SDL on UNIX platforms
ifndef WITH_SDL
ifdef UNIX
ifndef DEDICATED
$(error You need to have SDL installed in order to run OpenTTD on UNIX. Use DEDICATED if you want to compile a CLI based server)
endif
endif
endif
endif
# remove the dependancy for sdl if DEDICALTED is used
ifdef DEDICATED
WITH_SDL:=
endif
# add -lpthread to LDFLAGS
ifndef WIN32
ifndef MORPHOS
ifndef OSX
LDFLAGS+=-lpthread
endif
endif
endif
ifdef OSX
LDFLAGS+=-framework Cocoa
endif
ifdef WITH_SDL
ifndef SDL_CONFIG
$(error WITH_SDL can't be used when SDL_CONFIG is not set. Edit Makefile.config to correct this)
endif
endif
ifdef WITH_PNG
ifndef LIBPNG_CONFIG
$(error WITH_PNG can't be used when LIBPNG_CONFIG is not set. Edit Makefile.config to correct this)
endif
endif
##############################################################################
#
# Compiler configuration
#
# Executable file extension
ifdef WIN32
EXE=.exe
else
EXE=
endif
# Set output executable names
TTD=openttd$(EXE)
ENDIAN_CHECK=endian_check$(EXE)
STRGEN=strgen/strgen$(EXE)
OSXAPP="OpenTTD.app"
REV := 0.4.8-RC2
# MorphOS needs builddate
BUILDDATE=`date +%d.%m.%y`
# Check if there is a windres override
ifndef WINDRES
WINDRES = windres
endif
# Check if we have a new target
ifdef CC_TARGET
CC = $(CC_TARGET)
endif
# Check if CC_HOST is defined. If not, it is CC
ifndef CC_HOST
CC_HOST = $(CC)
endif
ifndef CFLAGS_HOST
CFLAGS_HOST = $(BASECFLAGS)
endif
CC_VERSION = $(shell $(CC) -dumpversion | cut -c 1,3)
# GNU make can only test for (in)equality
# this is a workaround to test for >=
ifeq ($(shell expr $(CC_VERSION) \>= 29), 1)
CFLAGS += -O -Wall -Wno-multichar -Wsign-compare -Wstrict-prototypes -Wundef
CFLAGS += -Wwrite-strings -Wpointer-arith
endif
ifeq ($(shell expr $(CC_VERSION) \>= 30), 1)
CFLAGS += -W -Wno-unused-parameter
endif
ifeq ($(shell expr $(CC_VERSION) \>= 34), 1)
CFLAGS += -Wdeclaration-after-statement -Wold-style-definition
endif
ifdef DEBUG
ifeq ($(shell expr $(DEBUG) \>= 1), 1)
CFLAGS += -g -D_DEBUG
endif
ifeq ($(shell expr $(DEBUG) \>= 2), 1)
CFLAGS += -fno-inline
endif
ifeq ($(shell expr $(DEBUG) \>= 3), 1)
CFLAGS += -O0
endif
endif
ifdef PROFILE
CFLAGS += -pg
LDFLAGS += -pg
endif
CDEFS=-DWITH_REV
ifndef DEBUG
ifndef PROFILE
# Release mode
ifndef MORPHOS
ifndef IRIX
# automatical strip breaks under morphos
BASECFLAGS += -s
LDFLAGS += -s
endif
endif
endif
ifdef OSX
# these compilerflags makes the app run as fast as possible without making the app unstable. It works on G3 or newer
BASECFLAGS += -O3 -funroll-loops -fsched-interblock -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-jumps-max-skip=15 -falign-loops-max-skip=15 -mdynamic-no-pic
else
ifdef MORPHOS
BASECFLAGS += -I/gg/os-include -O2 -noixemul -fstrict-aliasing -fexpensive-optimizations
BASECFLAGS += -mcpu=604 -fno-inline -mstring -mmultiple
else
BASECFLAGS += -O2
endif
ifndef PROFILE
ifndef IRIX
BASECFLAGS += -fomit-frame-pointer
endif
endif
endif
endif
ifdef STATIC
ifndef OSX # OSX can't build static if -static flag is used
LDFLAGS += -static
endif
endif
# If building on MingW don't link with Cygwin libs
ifdef WIN32
ifdef CYGWIN
BASECFLAGS += -mwin32
LDFLAGS += -mwin32
endif
ifdef MINGW
BASECFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin
endif
endif
CFLAGS += $(BASECFLAGS)
ifdef UNIX
CDEFS += -DUNIX
endif
ifdef BEOS
CDEFS += -DBEOS
LDFLAGS += -lmidi -lbe -lpthread
ifdef WITH_NETWORK
ifdef BEOS_NET_SERVER
CDEFS += -DBEOS_NET_SERVER
LDFLAGS += -lnet
else
# BONE needs a few more libraries than R5
LDFLAGS += -lbind -lsocket
endif
endif
endif
ifdef MORPHOS
# -Wstrict-prototypes generates much noise because of system headers
CFLAGS += -Wno-strict-prototypes
endif
ifdef SUNOS
CDEFS += -DSUNOS
ifdef WITH_NETWORK
LDFLAGS += -lnsl -lsocket
endif
endif
# tell the source that we are building a dedicated server
ifdef DEDICATED
CDEFS += -DDEDICATED
endif
# SDL config
ifdef WITH_SDL
CDEFS += -DWITH_SDL
CFLAGS += $(shell $(SDL_CONFIG) --cflags)
ifdef STATIC
LIBS += $(shell $(SDL_CONFIG) --static-libs)
else
LIBS += $(shell $(SDL_CONFIG) --libs)
endif
endif
# zlib config
ifdef WITH_ZLIB
CDEFS += -DWITH_ZLIB
ifdef STATIC
ifdef OSX
# OSX links dynamically to zlib, even in static builds since it's always present in the system
LIBS += -lz
else
LIBS += $(STATIC_ZLIB_PATH)
endif
else
LIBS += -lz
endif
endif
# libpng config
ifdef WITH_PNG
CDEFS += -DWITH_PNG
CFLAGS += $(shell $(LIBPNG_CONFIG) --cppflags --I_opts)
# seems like older libpng versions are broken and need this
PNGCONFIG_FLAGS = --ldflags --libs
ifdef STATIC
ifdef OSX
# Seems like we need a tiny hack for OSX static to work
LIBS += $(shell $(LIBPNG_CONFIG) --prefix)/lib/libpng.a
else
LIBS += $(shell $(LIBPNG_CONFIG) --static $(PNGCONFIG_FLAGS))
endif
else
LIBS += $(shell $(LIBPNG_CONFIG) --L_opts $(PNGCONFIG_FLAGS))
endif
endif
ifdef OSX
ifndef JAGUAR
LIBS += -liconv
endif
endif
# enables/disables assert()
ifdef DISABLE_ASSERTS
CFLAGS += -DNDEBUG
endif
# automatically disables asserts for release
ifdef RELEASE
ifndef ENABLE_ASSERTS
CFLAGS += -DNDEBUG
endif
endif
ifdef TRANSLATOR
STRGEN_FLAGS=-t
else
STRGEN_FLAGS=
endif
# OSX specific setup
ifdef OSX
# set the endian flag for OSX, that can't fail
ENDIAN_FORCE:=PREPROCESSOR
ifndef DEDICATED
LIBS += -framework QuickTime
endif
ifdef WITH_COCOA
CDEFS += -DWITH_COCOA
LIBS += -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit
endif
# OSX path setup
ifndef SECOND_DATA_PATH
SECOND_DATA_PATH:="$(OSXAPP)/Contents/Data/"
endif
ifndef CUSTOM_LANG_DIR
ifndef DEDICATED
CUSTOM_LANG_DIR:="$(OSXAPP)/Contents/Lang/"
endif
endif
endif
ifdef MIDI
CDEFS += -DEXTERNAL_PLAYER=\"$(MIDI)\"
ifdef MIDI_ARG
CDEFS += -DMIDI_ARG=\"$(MIDI_ARG)\"
endif
endif
ifdef MAX_NUM_AUTOSAVES
CDEFS += -DMAX_NUM_AUTOSAVES=$(MAX_NUM_AUTOSAVES)
endif
ifdef WITH_NETWORK
CDEFS += -DENABLE_NETWORK
ifdef QNX
LIBS += -lsocket
endif
endif
ifdef SECOND_DATA_PATH
CDEFS += -DSECOND_DATA_DIR=\"$(SECOND_DATA_PATH)/\"
endif
ifdef CUSTOM_LANG_DIR
CDEFS += -DCUSTOM_LANG_DIR=\"$(CUSTOM_LANG_DIR)/\"
endif
ifdef WITH_DIRECTMUSIC
CDEFS += -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT
endif
ifdef WIN32
LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32
ifdef WITH_DIRECTMUSIC
LIBS += -lstdc++
endif
TTDLDFLAGS += -Wl,--subsystem,windows
endif
ifndef DEST_DIR
DEST_DIR = $(DESTDIR)
endif
# sets up the paths for use for make install
ifdef INSTALL
# We use _PREFIXED vars here, so the paths are recalculated every time, and
# the prefix is not prepended in the makefile config
BINARY_DIR_PREFIXED:=$(PREFIX)/$(BINARY_DIR)
DATA_DIR_PREFIXED:=$(PREFIX)/$(DATA_DIR)
ICON_DIR_PREFIXED:=$(PREFIX)/$(ICON_DIR)
# We use _INSTALL vars here, these vars are the locations where the files will
# be installed
DATA_DIR_INSTALL=$(DEST_DIR)/$(DATA_DIR_PREFIXED)
BINARY_DIR_INSTALL=$(DEST_DIR)/$(BINARY_DIR_PREFIXED)
ICON_DIR_INSTALL=$(DEST_DIR)/$(ICON_DIR_PREFIXED)
# Let the code know where to find stuff
ifdef DATA_DIR_PREFIXED
CDEFS += -DGAME_DATA_DIR=\"$(DATA_DIR_PREFIXED)/\"
endif
ifdef PERSONAL_DIR
CDEFS += -DPERSONAL_DIR=\"$(PERSONAL_DIR)/\"
endif
ifdef USE_HOMEDIR
CDEFS += -DUSE_HOMEDIR
endif
endif
##############################################################################
#
# What to compile
# (users do not want to modify anything below)
#
### Sources
# clean up C_SOURCES first. Needed since building universal binaries on OSX calls the makefile recursively (just one time)
SRCS :=
SRCS += aircraft_cmd.c
SRCS += aircraft_gui.c
SRCS += airport.c
SRCS += airport_gui.c
SRCS += aystar.c
SRCS += bridge_gui.c
SRCS += callback_table.c
SRCS += clear_cmd.c
SRCS += command.c
SRCS += console.c
SRCS += console_cmds.c
SRCS += currency.c
SRCS += debug.c
SRCS += dedicated.c
SRCS += depot.c
SRCS += disaster_cmd.c
SRCS += dock_gui.c
SRCS += driver.c
SRCS += dummy_land.c
SRCS += economy.c
SRCS += engine.c
SRCS += engine_gui.c
SRCS += fileio.c
SRCS += gfx.c
SRCS += gfxinit.c
SRCS += graph_gui.c
SRCS += industry_cmd.c
SRCS += industry_gui.c
SRCS += intro_gui.c
SRCS += landscape.c
SRCS += main_gui.c
SRCS += map.c
SRCS += md5.c
SRCS += mersenne.c
SRCS += minilzo.c
SRCS += misc.c
SRCS += misc_cmd.c
SRCS += misc_gui.c
SRCS += mixer.c
SRCS += music_gui.c
SRCS += namegen.c
SRCS += network.c
SRCS += network_client.c
SRCS += network_data.c
SRCS += network_gamelist.c
SRCS += network_gui.c
SRCS += network_server.c
SRCS += network_udp.c
SRCS += newgrf.c
SRCS += news_gui.c
SRCS += npf.c
SRCS += oldloader.c
SRCS += openttd.c
SRCS += order_cmd.c
SRCS += order_gui.c
SRCS += pathfind.c
SRCS += player_gui.c
SRCS += players.c
SRCS += pool.c
SRCS += queue.c
SRCS += rail.c
SRCS += rail_cmd.c
SRCS += rail_gui.c
SRCS += rev.c
SRCS += road_cmd.c
SRCS += road_gui.c
SRCS += roadveh_cmd.c
SRCS += roadveh_gui.c
SRCS += saveload.c
SRCS += screenshot.c
SRCS += settings.c
SRCS += settings_gui.c
SRCS += ship_cmd.c
SRCS += ship_gui.c
SRCS += signs.c
SRCS += smallmap_gui.c
SRCS += sound.c
SRCS += sprite.c
SRCS += spritecache.c
SRCS += station_cmd.c
SRCS += station_gui.c
SRCS += station_newgrf.c
SRCS += string.c
SRCS += strings.c
SRCS += subsidy_gui.c
SRCS += terraform_gui.c
SRCS += texteff.c
SRCS += thread.c
SRCS += tile.c
SRCS += town_cmd.c
SRCS += town_gui.c
SRCS += train_cmd.c
SRCS += train_gui.c
SRCS += tree_cmd.c
SRCS += tunnel_map.c
SRCS += tunnelbridge_cmd.c
SRCS += unmovable_cmd.c
SRCS += vehicle.c
SRCS += vehicle_gui.c
SRCS += viewport.c
SRCS += water_cmd.c
SRCS += waypoint.c
SRCS += widget.c
SRCS += window.c
SRCS += music/null_m.c
SRCS += sound/null_s.c
SRCS += video/dedicated_v.c
SRCS += video/null_v.c
# AI related files
SRCS += ai/ai.c
SRCS += ai/default/default.c
SRCS += ai/trolly/build.c
SRCS += ai/trolly/pathfinder.c
SRCS += ai/trolly/shared.c
SRCS += ai/trolly/trolly.c
ifdef WITH_SDL
SRCS += sdl.c
SRCS += sound/sdl_s.c
SRCS += video/sdl_v.c
endif
ifdef WIN32
SRCS += win32.c
SRCS += music/win32_m.c
SRCS += sound/win32_s.c
SRCS += video/win32_v.c
else
SRCS += unix.c
SRCS += music/extmidi.c
endif
ifdef OSX
SRCS += os/macosx/macos.m
ifndef DEDICATED
SRCS += music/qtmidi.c
endif
ifdef WITH_COCOA
SRCS += video/cocoa_v.m
SRCS += sound/cocoa_s.c
SRCS += os/macosx/splash.c
endif
endif
ifdef BEOS
SRCS += music/bemidi.cpp
endif
ifdef WIN32
SRCS += ottdres.rc
endif
ifdef WITH_DIRECTMUSIC
SRCS += music/dmusic.cpp
endif
OBJS += $(filter %.o, $(SRCS:%.cpp=%.o) $(SRCS:%.m=%.o) $(SRCS:%.c=%.o) $(SRCS:%.rc=%.o))
DEPS = $(OBJS:%.o=.deps/%.d)
LANG_TXT = $(filter-out %.unfinished.txt,$(wildcard lang/*.txt))
LANGS = $(LANG_TXT:%.txt=%.lng)
##############################################################################
#
# Build commands
#
# If we are verbose, we will show commands prefixed by $(Q).
# The $(Q)s get replaced by @ in non-verbose mode.
# Inspired by the Linux kernel build system.
ifdef VERBOSE
Q =
else
Q = @
endif
##############################################################################
#
# Targets
#
### Normal build rules
ifdef OSX
# needs to be before all
OSX:=OSX
endif
all: endian_target.h endian_host.h $(UPDATECONFIG) $(LANGS) $(TTD) $(OSX)
ifdef OSX
-include os/macosx/Makefile
endif
endian_host.h: $(ENDIAN_CHECK)
@echo '===> Testing endianness for host'
$(Q)./$(ENDIAN_CHECK) > $@
endian_target.h: $(ENDIAN_CHECK)
@echo '===> Testing endianness for target'
$(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@
$(ENDIAN_CHECK): endian_check.c
@echo '===> Compiling and Linking $@'
$(Q)$(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@
ifndef NATIVE_OSX
# OSX links in os/macosx/Makefile to handle universal binaries better
$(TTD): $(OBJS) $(MAKE_CONFIG)
@echo '===> Linking $@'
$(Q)$(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@
endif
$(STRGEN): strgen/strgen.c endian_host.h
@echo '===> Compiling and Linking $@'
$(Q)$(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@
table/strings.h: lang/english.txt $(STRGEN)
@echo '===> Generating $@'
$(Q)$(STRGEN)
lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt
@echo '===> Compiling language $(*F)'
$(Q)$(STRGEN) $(STRGEN_FLAGS) $< $(LANG_ERRORS) || rm -f $@
ifdef MORPHOS
release: all
$(Q)rm -fr "/t/openttd-$(RELEASE)-morphos.lha"
$(Q)mkdir -p "/t/"
$(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos"
$(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/docs"
$(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/data"
$(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/lang"
$(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/scenario"
$(Q)cp -R $(TTD) "/t/openttd-$(RELEASE)-morphos/"
$(Q)cp data/* "/t/openttd-$(RELEASE)-morphos/data/"
$(Q)cp lang/*.lng "/t/openttd-$(RELEASE)-morphos/lang/"
$(Q)cp scenario/* "/t/openttd-$(RELEASE)-morphos/scenario/"
$(Q)cp readme.txt "/t/openttd-$(RELEASE)-morphos/docs/ReadMe"
$(Q)cp docs/console.txt "/t/openttd-$(RELEASE)-morphos/docs/Console"
$(Q)cp COPYING "/t/openttd-$(RELEASE)-morphos/docs/"
$(Q)cp changelog.txt "/t/openttd-$(RELEASE)-morphos/docs/ChangeLog"
$(Q)cp known-bugs.txt "/t/openttd-$(RELEASE)-morphos/docs/known-bugs.txt"
$(Q)cp os/morphos/icons/openttd.info "/t/openttd-$(RELEASE)-morphos/$(TTD).info"
$(Q)cp os/morphos/icons/docs.info "/t/openttd-$(RELEASE)-morphos/docs.info"
$(Q)cp os/morphos/icons/drawer.info "/t/openttd-$(RELEASE)-morphos.info"
$(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/ReadMe.info"
$(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/Console.info"
$(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/COPYING.info"
$(Q)cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/ChangeLog.info"
$(Q)strip --strip-all --strip-unneeded --remove-section .comment "/t/openttd-$(RELEASE)-morphos/$(TTD)"
$(Q)lha a -r "t:openttd-$(RELEASE)-morphos.lha" "t:openttd-$(RELEASE)-morphos"
$(Q)lha a "t:openttd-$(RELEASE)-morphos.lha" "t:openttd-$(RELEASE)-morphos.info"
$(Q)rm -fr "/t/openttd-$(RELEASE)-morphos"
$(Q)rm -fr "/t/openttd-$(RELEASE)-morphos.info"
@echo "Release archive can be found in RAM:t/ now."
.PHONY: release
endif
rev.c: FORCE
@# setting the revision number in a place, there the binary can read it
@echo 'const char _openttd_revision[] = "$(REV)";' >>rev.c.new
@# some additions for MorphOS versions tag
@echo '#ifdef __MORPHOS__' >>rev.c.new
@echo 'const char morphos_versions_tag[] = "\\0$$VER: OpenTTD $(REV) ('${BUILDDATE}') <20> OpenTTD Team [MorphOS, PowerPC]";' >>rev.c.new
@echo '#endif' >>rev.c.new
@# Only update the real rev.c if it actually changed, to prevent
@# useless rebuilds.
@cmp -s rev.c rev.c.new 2>/dev/null || mv rev.c.new rev.c
@rm -f rev.c.new
FORCE:
clean:
@echo '===> Cleaning up'
# endian.h is out-dated and no longer in use, so it can be removed soon
$(Q)rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(OBJS) $(OSX_MIDI_PLAYER_FILE) endian.h endian_host.h endian_target.h $(ENDIAN_CHECK) .OSX
mrproper: clean
$(Q)rm -rf $(MAKE_CONFIG)
ifndef OSX
ifndef MORPHOS
install:
ifeq ($(INSTALL),)
$(error make install is highly experimental at his state and not\
tested very much - use at your own risk - to use run \"make install INSTALL:=1\" - make sure Makefile.config\
is set correctly up - run \"make upgradeconf\")
endif
ifeq ($(PREFIX), )
$(error no prefix set - check Makefile.config)
endif
# We compare against the non prefixed version here, so we won't install
# if only the prefix has been set
ifeq ($(DATA_DIR),)
$(error no data path set - check Makefile.config)
endif
ifeq ($(BINARY_DIR),)
$(error no binary path set - check Makefile.config)
endif
# We'll install in $DEST_DIR instead of root if it is set (we don't
# care about extra /'s
install -d $(DATA_DIR_INSTALL)/lang \
$(DATA_DIR_INSTALL)/data \
$(DATA_DIR_INSTALL)/gm \
$(ICON_DIR_INSTALL) \
$(BINARY_DIR_INSTALL)
ifndef USE_HOMEDIR
mkdir -p $(PERSONAL_DIR)/scenario
else
mkdir -p $(DATA_DIR_INSTALL)/scenario
endif
install $(TTD) $(BINARY_DIR_INSTALL)
install -m 644 lang/*.lng $(DATA_DIR_INSTALL)/lang
install -m 644 data/*.grf $(DATA_DIR_INSTALL)/data
install -m 644 data/opntitle.dat $(DATA_DIR_INSTALL)/data
install -m 644 media/openttd.64.png $(ICON_DIR_INSTALL)
install -m 644 media/openttd.32.xpm $(ICON_DIR_INSTALL)
ifndef USE_HOMEDIR
cp scenario/* $(PERSONAL_DIR)/scenario/
else
cp scenario/* $(DATA_DIR_INSTALL)/scenario/
endif
else #MorphOS
install:
$(error make install is not supported on MorphOS)
endif
else # OSX
install:
$(error make install is not supported on MacOSX)
endif
love:
@echo "YES! I thought you would never ask. We will have a great time. You can keep me turned on all night"
.PHONY: clean all $(OSX) install love
### Automatic configuration
-include $(CONFIG_WRITER)
# Export all variables set to subprocesses (a bit dirty)
.EXPORT_ALL_VARIABLES:
upgradeconf: $(MAKE_CONFIG)
$(Q)rm $(MAKE_CONFIG)
$(Q)$(MAKE) $(MAKE_CONFIG)
.PHONY: upgradeconf
### Internal build rules
# This makes sure the .deps dir is always around.
DEPS_MAGIC := $(shell mkdir -p $(sort $(dir $(DEPS))))
depend:
@true # The include handles this automagically
# Introduce the dependencies
ifeq ($(findstring $(MAKECMDGOALS), clean info),)
-include $(DEPS)
endif
# Silence stale header dependency errors
%.h:
@true
.deps/%.d: %.c $(MAKE_CONFIG) table/strings.h endian_target.h
@echo '===> DEP $<'
$(Q)$(CC) $(CFLAGS) $(CDEFS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:.deps/%.d=%.o):#' > $@
.deps/%.d: %.cpp $(MAKE_CONFIG) table/strings.h endian_target.h
@echo '===> DEP $<'
$(Q)$(CXX) $(CFLAGS) $(CDEFS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:.deps/%.d=%.o):#' > $@
.deps/%.d: %.m $(MAKE_CONFIG) table/strings.h endian_target.h
@echo '===> DEP $<'
$(Q)$(CC) $(OBJCFLAGS) $(CDEFS) -MM $< | sed 's#^$(@F:%.d=%.o):#$@ $(@:.deps/%.d=%.o):#' > $@
ifndef NATIVE_OSX
# OSX uses os/macosx/Makefile to compile files
%.o: %.c $(MAKE_CONFIG)
@echo '===> Compiling $<'
$(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $<
%.o: %.cpp $(MAKE_CONFIG)
@echo '===> Compiling $<'
$(Q)$(CXX) $(CFLAGS) $(CDEFS) -c -o $@ $<
%.o: %.m $(MAKE_CONFIG)
@echo '===> Compiling $<'
$(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $<
endif
%.o: %.rc
@echo '===> Compiling resource $<'
$(Q)$(WINDRES) -o $@ $<
info:
@echo 'CFLAGS = $(CFLAGS)'
@echo 'LDFLAGS = $(LDFLAGS)'
@echo 'LIBS = $(LIBS)'
@echo 'CDEFS = $(CDEFS)'

186
README.md
View File

@@ -1,186 +0,0 @@
# OpenTTD
## Table of contents
- 1.0) [About](#10-about)
- 1.1) [Downloading OpenTTD](#11-downloading-openttd)
- 1.2) [OpenTTD gameplay manual](#12-openttd-gameplay-manual)
- 1.3) [Supported platforms](#13-supported-platforms)
- 1.4) [Installing and running OpenTTD](#14-installing-and-running-openttd)
- 1.5) [Add-on content / mods](#15-add-on-content--mods)
- 1.6) [OpenTTD directories](#16-openttd-directories)
- 1.7) [Compiling OpenTTD](#17-compiling-openttd)
- 2.0) [Contact and community](#20-contact-and-community)
- 2.1) [Contributing to OpenTTD](#21-contributing-to-openttd)
- 2.2) [Reporting bugs](#22-reporting-bugs)
- 2.3) [Translating](#23-translating)
- 3.0) [Licensing](#30-licensing)
- 4.0) [Credits](#40-credits)
## 1.0) About
OpenTTD is a transport simulation game based upon the popular game Transport Tycoon Deluxe, written by Chris Sawyer.
It attempts to mimic the original game as closely as possible while extending it with new features.
OpenTTD is licensed under the GNU General Public License version 2.0, but includes some 3rd party software under different licenses.
See the section ["Licensing"](#30-licensing) below for details.
## 1.1) Downloading OpenTTD
OpenTTD can be downloaded from the [official OpenTTD website](https://www.openttd.org/).
Both 'stable' and 'nightly' versions are available for download:
- most people should choose the 'stable' version, as this has been more extensively tested
- the 'nightly' version includes the latest changes and features, but may sometimes be less reliable
OpenTTD is also available for free on [Steam](https://store.steampowered.com/app/1536610/OpenTTD/), [GOG.com](https://www.gog.com/game/openttd), and the [Microsoft Store](https://www.microsoft.com/p/openttd-official/9ncjg5rvrr1c). On some platforms OpenTTD will be available via your OS package manager or a similar service.
## 1.2) OpenTTD gameplay manual
OpenTTD has a [community-maintained wiki](https://wiki.openttd.org/), including a gameplay manual and tips.
## 1.3) Supported platforms
OpenTTD has been ported to several platforms and operating systems.
The currently supported platforms are:
- Linux (SDL (OpenGL and non-OpenGL))
- macOS (universal) (Cocoa)
- Windows (Win32 GDI / OpenGL)
Other platforms may also work (in particular various BSD systems), but we don't actively test or maintain these.
### 1.3.1) Legacy support
Platforms, languages and compilers change.
We'll keep support going on old platforms as long as someone is interested in supporting them, except where it means the project can't move forward to keep up with language and compiler features.
We guarantee that every revision of OpenTTD will be able to load savegames from every older revision (excepting where the savegame is corrupt).
Please report a bug if you find a save that doesn't load.
## 1.4) Installing and running OpenTTD
OpenTTD is usually straightforward to install, but for more help the wiki [includes an installation guide](https://wiki.openttd.org/en/Manual/Installation).
OpenTTD needs some additional graphics and sound files to run.
For some platforms these will be downloaded during the installation process if required.
For some platforms, you will need to refer to [the installation guide](https://wiki.openttd.org/en/Manual/Installation).
### 1.4.1) Free graphics and sound files
The free data files, split into OpenGFX for graphics, OpenSFX for sounds and
OpenMSX for music can be found at:
- https://www.openttd.org/downloads/opengfx-releases/latest for OpenGFX
- https://www.openttd.org/downloads/opensfx-releases/latest for OpenSFX
- https://www.openttd.org/downloads/openmsx-releases/latest for OpenMSX
Please follow the readme of these packages about the installation procedure.
The Windows installer can optionally download and install these packages.
### 1.4.2) Original Transport Tycoon Deluxe graphics and sound files
If you want to play with the original Transport Tycoon Deluxe data files you have to copy the data files from the CD-ROM into the baseset/ directory.
It does not matter whether you copy them from the DOS or Windows version of Transport Tycoon Deluxe.
The Windows install can optionally copy these files.
You need to copy the following files:
- sample.cat
- trg1r.grf or TRG1.GRF
- trgcr.grf or TRGC.GRF
- trghr.grf or TRGH.GRF
- trgir.grf or TRGI.GRF
- trgtr.grf or TRGT.GRF
### 1.4.3) Original Transport Tycoon Deluxe music
If you want the Transport Tycoon Deluxe music, copy the appropriate files from the original game into the baseset folder.
- TTD for Windows: All files in the gm/ folder (gm_tt00.gm up to gm_tt21.gm)
- TTD for DOS: The GM.CAT file
- Transport Tycoon Original: The GM.CAT file, but rename it to GM-TTO.CAT
## 1.5) Add-on content / mods
OpenTTD features multiple types of add-on content, which modify gameplay in different ways.
Most types of add-on content can be downloaded within OpenTTD via the 'Check Online Content' button in the main menu.
Add-on content can also be installed manually, but that's more complicated; the [OpenTTD wiki](https://wiki.openttd.org/) may offer help with that, or the [OpenTTD directory structure guide](./docs/directory_structure.md).
### 1.6) OpenTTD directories
OpenTTD uses its own directory structure to store game data, add-on content etc.
For more information, see the [directory structure guide](./docs/directory_structure.md).
### 1.7) Compiling OpenTTD
If you want to compile OpenTTD from source, instructions can be found in [COMPILING.md](./COMPILING.md).
## 2.0) Contact and Community
'Official' channels
- [OpenTTD website](https://www.openttd.org)
- [OpenTTD official Discord](https://discord.gg/openttd)
- IRC chat using #openttd on irc.oftc.net [more info about our irc channel](https://wiki.openttd.org/en/Development/IRC%20channel)
- [OpenTTD on Github](https://github.com/OpenTTD/) for code repositories and for reporting issues
- [forum.openttd.org](https://forum.openttd.org/) - the primary community forum site for discussing OpenTTD and related games
- [OpenTTD wiki](https://wiki.openttd.org/) community-maintained wiki, including topics like gameplay guide, detailed explanation of some game mechanics, how to use add-on content (mods) and much more
'Unofficial' channels
- the OpenTTD wiki has a [page listing OpenTTD communities](https://wiki.openttd.org/en/Community/Community) including some in languages other than English
### 2.1) Contributing to OpenTTD
We welcome contributors to OpenTTD. More information for contributors can be found in [CONTRIBUTING.md](./CONTRIBUTING.md)
### 2.2) Reporting bugs
Good bug reports are very helpful. We have a [guide to reporting bugs](./CONTRIBUTING.md#bug-reports) to help with this.
Desyncs in multiplayer are complex to debug and report (some software development skils are required).
Instructions can be found in [debugging and reporting desyncs](./docs/debugging_desyncs.md).
### 2.3) Translating
OpenTTD is translated into many languages. Translations are added and updated via the [online translation tool](https://translator.openttd.org).
## 3.0) Licensing
OpenTTD is licensed under the GNU General Public License version 2.0.
For the complete license text, see the file '[COPYING.md](./COPYING.md)'.
This license applies to all files in this distribution, except as noted below.
The squirrel implementation in `src/3rdparty/squirrel` is licensed under the Zlib license.
See `src/3rdparty/squirrel/COPYRIGHT` for the complete license text.
The md5 implementation in `src/3rdparty/md5` is licensed under the Zlib license.
See the comments in the source files in `src/3rdparty/md5` for the complete license text.
The implementations of Posix `getaddrinfo` and `getnameinfo` for OS/2 in `src/3rdparty/os2` are distributed partly under the GNU Lesser General Public License 2.1, and partly under the (3-clause) BSD license.
The exact licensing terms can be found in `src/3rdparty/os2/getaddrinfo.c` resp. `src/3rdparty/os2/getnameinfo.c`.
The fmt implementation in `src/3rdparty/fmt` is licensed under the MIT license.
See `src/3rdparty/fmt/LICENSE.rst` for the complete license text.
## 4.0 Credits
See [CREDITS.md](./CREDITS.md)

10
StdAfx.c Normal file
View File

@@ -0,0 +1,10 @@
/* $Id$ */
// stdafx.cpp : source file that includes just the standard includes
// ttd.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

271
ai/ai.c Normal file
View File

@@ -0,0 +1,271 @@
/* $Id$ */
#include "../stdafx.h"
#include "../openttd.h"
#include "../variables.h"
#include "../command.h"
#include "../network.h"
#include "ai.h"
#include "default/default.h"
/**
* Dequeues commands put in the queue via AI_PutCommandInQueue.
*/
static void AI_DequeueCommands(byte player)
{
AICommand *com, *entry_com;
entry_com = _ai_player[player].queue;
/* It happens that DoCommandP issues a new DoCommandAI which adds a new command
* to this very same queue (don't argue about this, if it currently doesn't
* happen I can tell you it will happen with AIScript -- TrueLight). If we
* do not make the queue NULL, that commands will be dequeued immediatly.
* Therefor we safe the entry-point to entry_com, and make the queue NULL, so
* the new queue can be safely built up. */
_ai_player[player].queue = NULL;
_ai_player[player].queue_tail = NULL;
/* Dequeue all commands */
while ((com = entry_com) != NULL) {
_current_player = player;
/* Copy the DP back in place */
_cmd_text = com->text;
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
/* Free item */
entry_com = com->next;
if (com->text != NULL)
free(com->text);
free(com);
}
}
/**
* 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)
{
AICommand *com;
if (_ai_player[player].queue_tail == NULL) {
/* There is no item in the queue yet, create the queue */
_ai_player[player].queue = malloc(sizeof(AICommand));
_ai_player[player].queue_tail = _ai_player[player].queue;
} else {
/* Add an item at the end */
_ai_player[player].queue_tail->next = malloc(sizeof(AICommand));
_ai_player[player].queue_tail = _ai_player[player].queue_tail->next;
}
/* This is our new item */
com = _ai_player[player].queue_tail;
/* Assign the info */
com->tile = tile;
com->p1 = p1;
com->p2 = p2;
com->procc = procc;
com->callback = callback;
com->next = NULL;
com->text = NULL;
/* Copy the cmd_text, if needed */
if (_cmd_text != NULL) {
com->text = strdup(_cmd_text);
_cmd_text = NULL;
}
}
/**
* Executes a raw DoCommand for the AI.
*/
int32 AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
{
PlayerID old_lp;
int32 res = 0;
char *tmp_cmdtext = NULL;
/* If you enable DC_EXEC with DC_QUERY_COST you are a really strange
* person.. should we check for those funny jokes?
*/
/* The test already free _cmd_text in most cases, so let's backup the string, else we have a problem ;) */
if (_cmd_text != NULL)
tmp_cmdtext = strdup(_cmd_text);
/* First, do a test-run to see if we can do this */
res = DoCommandByTile(tile, p1, p2, flags & ~DC_EXEC, procc);
/* The command failed, or you didn't want to execute, or you are quering, return */
if ((CmdFailed(res)) || !(flags & DC_EXEC) || (flags & DC_QUERY_COST)) {
if (tmp_cmdtext != NULL)
free(tmp_cmdtext);
return res;
}
/* Recover _cmd_text */
if (tmp_cmdtext != NULL)
_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_AUTO) procc |= CMD_AUTO;
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;
_local_player = _current_player;
#ifdef ENABLE_NETWORK
/* Send the command */
if (_networking)
/* Network is easy, send it to his handler */
NetworkSend_Command(tile, p1, p2, procc, callback);
else
#endif
/* If we execute BuildCommands directly in SP, we have a big problem with events
* so we need to delay is for 1 tick */
AI_PutCommandInQueue(_current_player, tile, p1, p2, procc, callback);
/* Set _local_player back */
_local_player = old_lp;
/* Free the temp _cmd_text var */
if (tmp_cmdtext != NULL)
free(tmp_cmdtext);
return res;
}
int32 AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
{
return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL);
}
/**
* Run 1 tick of the AI. Don't overdo it, keep it realistic.
*/
static void AI_RunTick(PlayerID player)
{
extern void AiNewDoGameLoop(Player *p);
Player *p = GetPlayer(player);
_current_player = player;
if (_patches.ainew_active) {
AiNewDoGameLoop(p);
} else {
/* Enable all kind of cheats the old AI needs in order to operate correctly... */
_is_old_ai_player = true;
AiDoGameLoop(p);
_is_old_ai_player = false;
}
}
/**
* The gameloop for AIs.
* Handles one tick for all the AIs.
*/
void AI_RunGameLoop(void)
{
/* Don't do anything if ai is disabled */
if (!_ai.enabled) return;
/* Don't do anything if we are a network-client
* (too bad when a client joins, he thinks the AIs are real, so it wants to control
* them.. this avoids that, while loading a network game in singleplayer, does make
* the AIs to continue ;))
*/
if (_networking && !_network_server && !_ai.network_client)
return;
/* New tick */
_ai.tick++;
/* Make sure the AI follows the difficulty rule.. */
assert(_opt.diff.competitor_speed <= 4);
if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0)
return;
/* Check for AI-client (so joining a network with an AI) */
if (_ai.network_client && _ai_player[_ai.network_playas].active) {
/* Run the script */
AI_DequeueCommands(_ai.network_playas);
AI_RunTick(_ai.network_playas);
} else if (!_networking || _network_server) {
/* Check if we want to run AIs (server or SP only) */
Player *p;
FOR_ALL_PLAYERS(p) {
if (p->is_active && p->is_ai) {
/* This should always be true, else something went wrong... */
assert(_ai_player[p->index].active);
/* Run the script */
AI_DequeueCommands(p->index);
AI_RunTick(p->index);
}
}
}
_current_player = OWNER_NONE;
}
/**
* A new AI sees the day of light. You can do here what ever you think is needed.
*/
void AI_StartNewAI(PlayerID player)
{
assert(player < MAX_PLAYERS);
/* Called if a new AI is booted */
_ai_player[player].active = true;
}
/**
* This AI player died. Give it some chance to make a final puf.
*/
void AI_PlayerDied(PlayerID player)
{
if (_ai.network_client && _ai.network_playas == player)
_ai.network_playas = OWNER_SPECTATOR;
/* Called if this AI died */
_ai_player[player].active = false;
}
/**
* Initialize some AI-related stuff.
*/
void AI_Initialize(void)
{
bool ai_network_client = _ai.network_client;
/* First, make sure all AIs are DEAD! */
AI_Uninitialize();
memset(&_ai, 0, sizeof(_ai));
memset(&_ai_player, 0, sizeof(_ai_player));
_ai.network_client = ai_network_client;
_ai.network_playas = OWNER_SPECTATOR;
_ai.enabled = true;
}
/**
* Deinitializer for AI-related stuff.
*/
void AI_Uninitialize(void)
{
Player* p;
FOR_ALL_PLAYERS(p) {
if (p->is_active && p->is_ai) AI_PlayerDied(p->index);
}
}

114
ai/ai.h Normal file
View File

@@ -0,0 +1,114 @@
#ifndef AI_H
#define AI_H
#include "../functions.h"
#include "../network.h"
#include "../player.h"
/* How DoCommands look like for an AI */
typedef struct AICommand {
uint32 tile;
uint32 p1;
uint32 p2;
uint32 procc;
CommandCallback* callback;
char *text;
uint uid;
struct AICommand *next;
} AICommand;
/* The struct for an AIScript Player */
typedef struct AIPlayer {
bool active; //! Is this AI active?
AICommand *queue; //! The commands that he has in his queue
AICommand *queue_tail; //! The tail of this queue
} AIPlayer;
/* The struct to keep some data about the AI in general */
typedef struct AIStruct {
/* General */
bool enabled; //! Is AI enabled?
uint tick; //! The current tick (something like _frame_counter, only for AIs)
/* For network-clients (a OpenTTD client who acts as an AI connected to a server) */
bool network_client; //! Are we a network_client?
uint8 network_playas; //! The current network player we are connected as
} AIStruct;
VARDEF AIStruct _ai;
VARDEF AIPlayer _ai_player[MAX_PLAYERS];
// ai.c
void AI_StartNewAI(PlayerID player);
void AI_PlayerDied(PlayerID player);
void AI_RunGameLoop(void);
void AI_Initialize(void);
void AI_Uninitialize(void);
int32 AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
int32 AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback);
/** Is it allowed to start a new AI.
* This function checks some boundries to see if we should launch a new AI.
* @return True if we can start a new AI.
*/
static inline bool AI_AllowNewAI(void)
{
/* If disabled, no AI */
if (!_ai.enabled)
return false;
/* If in network, but no server, no AI */
if (_networking && !_network_server)
return false;
/* If in network, and server, possible AI */
if (_networking && _network_server) {
/* Do we want AIs in multiplayer? */
if (!_patches.ai_in_multiplayer)
return false;
/* Only the NewAI is allowed... sadly enough the old AI just doesn't support this
* system, because all commands are delayed by at least 1 tick, which causes
* a big problem, because it uses variables that are only set AFTER the command
* is really executed... */
if (!_patches.ainew_active)
return false;
}
return true;
}
#define AI_CHANCE16(a,b) ((uint16) AI_Random() <= (uint16)((65536 * a) / b))
#define AI_CHANCE16R(a,b,r) ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b))
/**
* The random-function that should be used by ALL AIs.
*/
static inline uint AI_RandomRange(uint max)
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client.
*/
if (_networking)
return InteractiveRandomRange(max);
else
return RandomRange(max);
}
/**
* The random-function that should be used by ALL AIs.
*/
static inline uint32 AI_Random(void)
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client.
*/
if (_networking)
return InteractiveRandom();
else
return Random();
}
#endif /* AI_H */

3980
ai/default/default.c Normal file

File diff suppressed because it is too large Load Diff

8
ai/default/default.h Normal file
View File

@@ -0,0 +1,8 @@
/* $Id$ */
#ifndef DEFAULT_H
#define DEFAULT_H
void AiDoGameLoop(Player*);
#endif

292
ai/trolly/build.c Normal file
View File

@@ -0,0 +1,292 @@
/* $Id$ */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
#include "../../tile.h"
#include "../../vehicle.h"
#include "../../command.h"
#include "trolly.h"
#include "../../engine.h"
#include "../../station.h"
#include "../../variables.h"
#include "../ai.h"
// Build HQ
// Params:
// tile : tile where HQ is going to be build
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
{
if (CmdFailed(AI_DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ)))
return false;
AI_DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
return true;
}
// Build station
// Params:
// type : AI_TRAIN/AI_BUS/AI_TRUCK : indicates the type of station
// tile : tile where station is going to be build
// length : in case of AI_TRAIN: length of station
// numtracks : in case of AI_TRAIN: tracks of station
// direction : the direction of the station
// flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
{
if (type == AI_TRAIN)
return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
if (type == AI_BUS)
return AI_DoCommand(tile, direction, RS_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
return AI_DoCommand(tile, direction, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
}
// Builds a brdige. The second best out of the ones available for this player
// Params:
// tile_a : starting point
// tile_b : end point
// flag : flag passed to DoCommand
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
{
int bridge_type, bridge_len, type, type2;
// Find a good bridgetype (the best money can buy)
bridge_len = GetBridgeLength(tile_a, tile_b);
type = type2 = 0;
for (bridge_type = MAX_BRIDGES-1; bridge_type >= 0; bridge_type--) {
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
type2 = type;
type = bridge_type;
// We found two bridges, exit
if (type2 != 0) break;
}
}
// There is only one bridge that can be build..
if (type2 == 0 && type != 0) type2 = type;
// Now, simply, build the bridge!
if (p->ainew.tbt == AI_TRAIN)
return AI_DoCommand(tile_a, tile_b, (0<<8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
return AI_DoCommand(tile_a, tile_b, (0x80 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
}
// Build the route part by part
// Basicly what this function do, is build that amount of parts of the route
// that go in the same direction. It sets 'part' to the last part of the route builded.
// The return value is the cost for the builded parts
//
// Params:
// PathFinderInfo : Pointer to the PathFinderInfo used for AiPathFinder
// part : Which part we need to build
//
// TODO: skip already builded road-pieces (e.g.: cityroad)
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag)
{
int part = PathFinderInfo->position;
byte *route_extra = PathFinderInfo->route_extra;
TileIndex *route = PathFinderInfo->route;
int dir;
int old_dir = -1;
int cost = 0;
int res;
// We need to calculate the direction with the parent of the parent.. so we skip
// the first pieces and the last piece
if (part < 1) part = 1;
// When we are done, stop it
if (part >= PathFinderInfo->route_length - 1) { PathFinderInfo->position = -2; return 0; }
if (PathFinderInfo->rail_or_road) {
// Tunnel code
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
cost += AI_DoCommand(route[part], 0, 0, flag, CMD_BUILD_TUNNEL);
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be build!");
return 0;
}
return cost;
}
// Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
cost += AiNew_Build_Bridge(p, route[part], route[part-1], flag);
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be build!");
return 0;
}
return cost;
}
// Build normal rail
// Keep it doing till we go an other way
if (route_extra[part-1] == 0 && route_extra[part] == 0) {
while (route_extra[part] == 0) {
// Get the current direction
dir = AiNew_GetRailDirection(route[part-1], route[part], route[part+1]);
// Is it the same as the last one?
if (old_dir != -1 && old_dir != dir) break;
old_dir = dir;
// Build the tile
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;
return 0;
}
cost += res;
// Go to the next tile
part++;
// Check if it is still in range..
if (part >= PathFinderInfo->route_length - 1) break;
}
part--;
}
// We want to return the last position, so we go back one
PathFinderInfo->position = part;
} else {
// Tunnel code
if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
cost += AI_DoCommand(route[part], 0x200, 0, flag, CMD_BUILD_TUNNEL);
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be build!");
return 0;
}
return cost;
}
// Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
cost += AiNew_Build_Bridge(p, route[part], route[part+1], flag);
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be build!");
return 0;
}
return cost;
}
// Build normal road
// Keep it doing till we go an other way
// EnsureNoVehicle makes sure we don't build on a tile where a vehicle is. This way
// it will wait till the vehicle is gone..
if (route_extra[part-1] == 0 && route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) {
while (route_extra[part] == 0 && (flag != DC_EXEC || EnsureNoVehicle(route[part]))) {
// Get the current direction
dir = AiNew_GetRoadDirection(route[part-1], route[part], route[part+1]);
// Is it the same as the last one?
if (old_dir != -1 && old_dir != dir) break;
old_dir = dir;
// There is already some road, and it is a bridge.. don't build!!!
if (!IsTileType(route[part], MP_TUNNELBRIDGE)) {
// Build the tile
res = AI_DoCommand(route[part], dir, 0, flag | DC_NO_WATER, CMD_BUILD_ROAD);
// Currently, we ignore CMD_ERRORs!
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) {
// Problem.. let's just abort it all!
DEBUG(ai,0)("Darn, the route could not be builded.. aborting!");
p->ainew.state = AI_STATE_NOTHING;
return 0;
}
if (!CmdFailed(res)) cost += res;
}
// Go to the next tile
part++;
// Check if it is still in range..
if (part >= PathFinderInfo->route_length - 1) break;
}
part--;
// We want to return the last position, so we go back one
}
if (!EnsureNoVehicle(route[part]) && flag == DC_EXEC) part--;
PathFinderInfo->position = part;
}
return cost;
}
// This functions tries to find the best vehicle for this type of cargo
// It returns vehicle_id or -1 if not found
int AiNew_PickVehicle(Player *p)
{
if (p->ainew.tbt == AI_TRAIN) {
// Not supported yet
return -1;
} else {
int start, count, i, ret = CMD_ERROR;
start = _cargoc.ai_roadveh_start[p->ainew.cargo];
count = _cargoc.ai_roadveh_count[p->ainew.cargo];
// Let's check it backwards.. we simply want to best engine available..
for (i = start + count - 1; i >= start; i--) {
// Is it availiable?
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
if (!HASBIT(GetEngine(i)->player_avail, _current_player) || GetEngine(i)->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
// Can we build it?
ret = AI_DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_ROAD_VEH);
if (!CmdFailed(ret)) break;
}
// We did not find a vehicle :(
if (CmdFailed(ret)) return -1;
return i;
}
}
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;
} else {
/* XXX this should be handled more gracefully */
p->ainew.state = AI_STATE_NOTHING;
}
}
// Builds the best vehicle possible
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
{
int i = AiNew_PickVehicle(p);
if (i == -1) return CMD_ERROR;
if (p->ainew.tbt == AI_TRAIN) return CMD_ERROR;
if (flag & DC_EXEC) {
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
} else {
return AI_DoCommand(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
}
}
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
{
static const byte _roadbits_by_dir[4] = {2,1,8,4};
int ret, ret2;
if (p->ainew.tbt == AI_TRAIN)
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
if (CmdFailed(ret)) return ret;
// Try to build the road from the depot
ret2 = AI_DoCommand(tile + TileOffsByDir(direction), _roadbits_by_dir[direction], 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
// If it fails, ignore it..
if (CmdFailed(ret2)) return ret;
return ret + ret2;
}

509
ai/trolly/pathfinder.c Normal file
View File

@@ -0,0 +1,509 @@
/* $Id$ */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
#include "../../tile.h"
#include "../../command.h"
#include "trolly.h"
#include "../../depot.h"
#include "../../variables.h"
#include "../ai.h"
#define TEST_STATION_NO_DIR 0xFF
// Tests if a station can be build on the given spot
// TODO: make it train compatible
static bool TestCanBuildStationHere(TileIndex tile, byte dir)
{
Player *p = GetPlayer(_current_player);
if (dir == TEST_STATION_NO_DIR) {
int32 ret;
// 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);
if (!CmdFailed(ret)) return true;
}
return false;
}
// return true if command succeeded, so the inverse of CmdFailed()
return !CmdFailed(AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST));
}
static bool IsRoad(TileIndex tile)
{
return
// MP_STREET, but not a road depot?
(IsTileType(tile, MP_STREET) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
(IsTileType(tile, MP_TUNNELBRIDGE) && (
// road tunnel?
((_m[tile].m5 & 0x80) == 0 && (_m[tile].m5 & 0x4) == 0x4) ||
// road bridge?
((_m[tile].m5 & 0x80) != 0 && (_m[tile].m5 & 0x2) == 0x2)
));
}
// Checks if a tile 'a' is between the tiles 'b' and 'c'
#define TILES_BETWEEN(a, b, c) (TileX(a) >= TileX(b) && TileX(a) <= TileX(c) && TileY(a) >= TileY(b) && TileY(a) <= TileY(c))
// Check if the current tile is in our end-area
static int32 AyStar_AiPathFinder_EndNodeCheck(AyStar *aystar, OpenListNode *current)
{
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
// It is not allowed to have a station on the end of a bridge or tunnel ;)
if (current->path.node.user_data[0] != 0) return AYSTAR_DONE;
if (TILES_BETWEEN(current->path.node.tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br))
if (IsTileType(current->path.node.tile, MP_CLEAR) || IsTileType(current->path.node.tile, MP_TREES))
if (current->path.parent == NULL || TestCanBuildStationHere(current->path.node.tile, AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile)))
return AYSTAR_FOUND_END_NODE;
return AYSTAR_DONE;
}
// Calculates the hash
// Currently it is a 10 bit hash, so the hash array has a max depth of 6 bits (so 64)
static uint AiPathFinder_Hash(uint key1, uint key2)
{
return (TileX(key1) & 0x1F) + ((TileY(key1) & 0x1F) << 5);
}
// Clear the memory of all the things
static void AyStar_AiPathFinder_Free(AyStar *aystar)
{
AyStarMain_Free(aystar);
free(aystar);
}
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current);
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current);
// This creates the AiPathFinder
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo)
{
PathNode start_node;
uint x;
uint y;
// Create AyStar
AyStar *result = malloc(sizeof(AyStar));
init_AyStar(result, AiPathFinder_Hash, 1 << 10);
// Set the function pointers
result->CalculateG = AyStar_AiPathFinder_CalculateG;
result->CalculateH = AyStar_AiPathFinder_CalculateH;
result->EndNodeCheck = AyStar_AiPathFinder_EndNodeCheck;
result->FoundEndNode = AyStar_AiPathFinder_FoundEndNode;
result->GetNeighbours = AyStar_AiPathFinder_GetNeighbours;
result->free = AyStar_AiPathFinder_Free;
// Set some information
result->loops_per_tick = AI_PATHFINDER_LOOPS_PER_TICK;
result->max_path_cost = 0;
result->max_search_nodes = AI_PATHFINDER_MAX_SEARCH_NODES;
// Set the user_data to the PathFinderInfo
result->user_target = PathFinderInfo;
// Set the start node
start_node.parent = NULL;
start_node.node.direction = 0;
start_node.node.user_data[0] = 0;
// Now we add all the starting tiles
for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
start_node.node.tile = TileXY(x, y);
result->addstart(result, &start_node.node, 0);
}
}
return result;
}
// To reuse AyStar we sometimes have to clean all the memory
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo)
{
PathNode start_node;
uint x;
uint y;
aystar->clear(aystar);
// Set the user_data to the PathFinderInfo
aystar->user_target = PathFinderInfo;
// Set the start node
start_node.parent = NULL;
start_node.node.direction = 0;
start_node.node.user_data[0] = 0;
start_node.node.tile = PathFinderInfo->start_tile_tl;
// Now we add all the starting tiles
for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
if (!(IsTileType(TileXY(x, y), MP_CLEAR) || IsTileType(TileXY(x, y), MP_TREES))) continue;
if (!TestCanBuildStationHere(TileXY(x, y), TEST_STATION_NO_DIR)) continue;
start_node.node.tile = TileXY(x, y);
aystar->addstart(aystar, &start_node.node, 0);
}
}
}
// The h-value, simple calculation
static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent)
{
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
int r, r2;
if (PathFinderInfo->end_direction != AI_PATHFINDER_NO_DIRECTION) {
// The station is pointing to a direction, add a tile towards that direction, so the H-value is more accurate
r = DistanceManhattan(current->tile, PathFinderInfo->end_tile_tl + TileOffsByDir(PathFinderInfo->end_direction));
r2 = DistanceManhattan(current->tile, PathFinderInfo->end_tile_br + TileOffsByDir(PathFinderInfo->end_direction));
} else {
// No direction, so just get the fastest route to the station
r = DistanceManhattan(current->tile, PathFinderInfo->end_tile_tl);
r2 = DistanceManhattan(current->tile, PathFinderInfo->end_tile_br);
}
// See if the bottomright is faster than the topleft..
if (r2 < r) r = r2;
return r * AI_PATHFINDER_H_MULTIPLER;
}
// We found the end.. let's get the route back and put it in an array
static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current)
{
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
uint i = 0;
PathNode *parent = &current->path;
do {
PathFinderInfo->route_extra[i] = parent->node.user_data[0];
PathFinderInfo->route[i++] = parent->node.tile;
if (i > lengthof(PathFinderInfo->route)) {
// We ran out of space for the PathFinder
DEBUG(ai, 0)("[AiPathFinder] Ran out of space in the route[] array!!!");
PathFinderInfo->route_length = -1; // -1 indicates out of space
return;
}
parent = parent->parent;
} while (parent != NULL);
PathFinderInfo->route_length = i;
DEBUG(ai, 1)("[Ai-PathFinding] Found route of %d nodes long in %d nodes of searching", i, Hash_Size(&aystar->ClosedListHash));
}
// What tiles are around us.
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current)
{
uint i;
int ret;
int dir;
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
aystar->num_neighbours = 0;
// Go through all surrounding tiles and check if they are within the limits
for (i = 0; i < 4; i++) {
TileIndex ctile = current->path.node.tile; // Current tile
TileIndex atile = ctile + TileOffsByDir(i); // Adjacent tile
if (TileX(atile) > 1 && TileX(atile) < MapMaxX() - 1 &&
TileY(atile) > 1 && TileY(atile) < MapMaxY() - 1) {
// We also directly test if the current tile can connect to this tile..
// We do this simply by just building the tile!
// 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)) {
// An existing bridge... let's test the direction ;)
if ((_m[atile].m5 & 1U) != (i & 1)) continue;
// This problem only is valid for tunnels:
// When the last tile was not yet a tunnel, check if we enter from the right side..
if ((_m[atile].m5 & 0x80) == 0) {
if (i != (_m[atile].m5 & 3U)) continue;
}
}
}
// But also if we are on a bridge, we can only move a certain direction
if (!PathFinderInfo->rail_or_road && IsRoad(ctile)) {
if (IsTileType(ctile, MP_TUNNELBRIDGE)) {
// An existing bridge/tunnel... let's test the direction ;)
if ((_m[ctile].m5 & 1U) != (i & 1)) continue;
}
}
if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
(AI_PATHFINDER_FLAG_TUNNEL & current->path.node.user_data[0]) != 0) {
// We are a bridge/tunnel, how cool!!
// This means we can only point forward.. get the direction from the user_data
if (i != (current->path.node.user_data[0] >> 8)) continue;
}
dir = 0;
// First, check if we have a parent
if (current->path.parent == NULL && current->path.node.user_data[0] == 0) {
// If not, this means we are at the starting station
if (PathFinderInfo->start_direction != AI_PATHFINDER_NO_DIRECTION) {
// We do need a direction?
if (AiNew_GetDirection(ctile, atile) != PathFinderInfo->start_direction) {
// We are not pointing the right way, invalid tile
continue;
}
}
} else if (current->path.node.user_data[0] == 0) {
if (PathFinderInfo->rail_or_road) {
// Rail check
dir = AiNew_GetRailDirection(current->path.parent->node.tile, ctile, atile);
ret = AI_DoCommand(ctile, 0, dir, DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(ret)) continue;
#ifdef AI_PATHFINDER_NO_90DEGREES_TURN
if (current->path.parent->parent != NULL) {
// Check if we don't make a 90degree curve
int dir1 = AiNew_GetRailDirection(current->path.parent->parent->node.tile, current->path.parent->node.tile, ctile);
if (_illegal_curves[dir1] == dir || _illegal_curves[dir] == dir1) {
continue;
}
}
#endif
} else {
// Road check
dir = AiNew_GetRoadDirection(current->path.parent->node.tile, ctile, atile);
if (IsRoad(ctile)) {
if (IsTileType(ctile, MP_TUNNELBRIDGE)) {
// We have a bridge, how nicely! We should mark it...
dir = 0;
} else {
// It already has road.. check if we miss any bits!
if ((_m[ctile].m5 & dir) != dir) {
// We do miss some pieces :(
dir &= ~_m[ctile].m5;
} else {
dir = 0;
}
}
}
// Only destruct things if it is MP_CLEAR of MP_TREES
if (dir != 0) {
ret = AI_DoCommand(ctile, dir, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
if (CmdFailed(ret)) continue;
}
}
}
// The tile can be connected
aystar->neighbours[aystar->num_neighbours].tile = atile;
aystar->neighbours[aystar->num_neighbours].user_data[0] = 0;
aystar->neighbours[aystar->num_neighbours++].direction = 0;
}
}
// Next step, check for bridges and tunnels
if (current->path.parent != NULL && current->path.node.user_data[0] == 0) {
TileInfo ti;
// First we get the dir from this tile and his parent
int dir = AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile);
// It means we can only walk with the track, so the bridge has to be in the same direction
TileIndex tile = current->path.node.tile;
TileIndex new_tile = tile;
FindLandscapeHeightByTile(&ti, tile);
// Bridges can only be build on land that is not flat
// And if there is a road or rail blocking
if (ti.tileh != 0 ||
(PathFinderInfo->rail_or_road && IsTileType(tile + TileOffsByDir(dir), MP_STREET)) ||
(!PathFinderInfo->rail_or_road && IsTileType(tile + TileOffsByDir(dir), MP_RAILWAY))) {
for (;;) {
new_tile += TileOffsByDir(dir);
// Precheck, is the length allowed?
if (!CheckBridge_Stuff(0, GetBridgeLength(tile, new_tile))) break;
// Check if we hit the station-tile.. we don't like that!
if (TILES_BETWEEN(new_tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br)) break;
// Try building the bridge..
ret = AI_DoCommand(tile, new_tile, (0 << 8) + (MAX_BRIDGES / 2), DC_AUTO, CMD_BUILD_BRIDGE);
if (CmdFailed(ret)) continue;
// We can build a bridge here.. add him to the neighbours
aystar->neighbours[aystar->num_neighbours].tile = new_tile;
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_BRIDGE + (dir << 8);
aystar->neighbours[aystar->num_neighbours++].direction = 0;
// We can only have 12 neighbours, and we need 1 left for tunnels
if (aystar->num_neighbours == 11) break;
}
}
// Next, check for tunnels!
// Tunnels can only be build with tileh of 3, 6, 9 or 12, depending on the direction
// For now, we check both sides for this tile.. terraforming gives fuzzy result
if ((dir == 0 && ti.tileh == 12) ||
(dir == 1 && ti.tileh == 6) ||
(dir == 2 && ti.tileh == 3) ||
(dir == 3 && ti.tileh == 9)) {
// Now simply check if a tunnel can be build
ret = AI_DoCommand(tile, (PathFinderInfo->rail_or_road?0:0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
FindLandscapeHeightByTile(&ti, _build_tunnel_endtile);
if (!CmdFailed(ret) && (ti.tileh == 3 || ti.tileh == 6 || ti.tileh == 9 || ti.tileh == 12)) {
aystar->neighbours[aystar->num_neighbours].tile = _build_tunnel_endtile;
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_TUNNEL + (dir << 8);
aystar->neighbours[aystar->num_neighbours++].direction = 0;
}
}
}
}
extern uint GetRailFoundation(uint tileh, uint bits);
extern uint GetRoadFoundation(uint tileh, uint bits);
extern uint GetBridgeFoundation(uint tileh, byte direction);
enum {
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
};
// The most important function: it calculates the g-value
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent)
{
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
int r, res = 0;
TileInfo ti, parent_ti;
// Gather some information about the tile..
FindLandscapeHeightByTile(&ti, current->tile);
FindLandscapeHeightByTile(&parent_ti, parent->path.node.tile);
// Check if we hit the end-tile
if (TILES_BETWEEN(current->tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br)) {
// We are at the end-tile, check if we had a direction or something...
if (PathFinderInfo->end_direction != AI_PATHFINDER_NO_DIRECTION && AiNew_GetDirection(current->tile, parent->path.node.tile) != PathFinderInfo->end_direction) {
// We are not pointing the right way, invalid tile
return AYSTAR_INVALID_NODE;
}
// If it was valid, drop out.. we don't build on the endtile
return 0;
}
// Give everything a small penalty
res += AI_PATHFINDER_PENALTY;
if (!PathFinderInfo->rail_or_road) {
// Road has the lovely advantage it can use other road... check if
// the current tile is road, and if so, give a good bonus
if (IsRoad(current->tile)) {
res -= AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS;
}
}
// We should give a penalty when the tile is going up or down.. this is one way to do so!
// Too bad we have to count it from the parent.. but that is not so bad.
// We also dislike long routes on slopes, since they do not look too realistic
// when there is a flat land all around, they are more expensive to build, and
// especially they essentially block the ability to connect or cross the road
// from one side.
if (parent_ti.tileh != 0 && parent->path.parent != NULL) {
// Skip if the tile was from a bridge or tunnel
if (parent->path.node.user_data[0] == 0 && current->user_data[0] == 0) {
if (PathFinderInfo->rail_or_road) {
r = GetRailFoundation(parent_ti.tileh, 1 << AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
// Maybe is BRIDGE_NO_FOUNDATION a bit strange here, but it contains just the right information..
if (r >= 15 || (r == 0 && (BRIDGE_NO_FOUNDATION & (1 << ti.tileh)))) {
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
} else {
res += AI_PATHFINDER_FOUNDATION_PENALTY;
}
} else {
if (!(IsRoad(parent->path.node.tile) && IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE))) {
r = GetRoadFoundation(parent_ti.tileh, AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
if (r >= 15 || r == 0)
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
else
res += AI_PATHFINDER_FOUNDATION_PENALTY;
}
}
}
}
// Are we part of a tunnel?
if ((AI_PATHFINDER_FLAG_TUNNEL & current->user_data[0]) != 0) {
// Tunnels are very expensive when build on long routes..
// Ironicly, we are using BridgeCode here ;)
r = AI_PATHFINDER_TUNNEL_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
res += r + (r >> 8);
}
// Are we part of a bridge?
if ((AI_PATHFINDER_FLAG_BRIDGE & current->user_data[0]) != 0) {
// That means for every length a penalty
res += AI_PATHFINDER_BRIDGE_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
// Check if we are going up or down, first for the starting point
// In user_data[0] is at the 8th bit the direction
if (!(BRIDGE_NO_FOUNDATION & (1 << parent_ti.tileh))) {
if (GetBridgeFoundation(parent_ti.tileh, (current->user_data[0] >> 8) & 1) < 15)
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
}
// Second for the end point
if (!(BRIDGE_NO_FOUNDATION & (1 << ti.tileh))) {
if (GetBridgeFoundation(ti.tileh, (current->user_data[0] >> 8) & 1) < 15)
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
}
if (parent_ti.tileh == 0) res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
if (ti.tileh == 0) res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
}
// To prevent the AI from taking the fastest way in tiles, but not the fastest way
// in speed, we have to give a good penalty to direction changing
// This way, we get almost the fastest way in tiles, and a very good speed on the track
if (!PathFinderInfo->rail_or_road) {
if (parent->path.parent != NULL &&
AiNew_GetDirection(current->tile, parent->path.node.tile) != AiNew_GetDirection(parent->path.node.tile, parent->path.parent->node.tile)) {
// When road exists, we don't like turning, but its free, so don't be to piggy about it
if (IsRoad(parent->path.node.tile))
res += AI_PATHFINDER_DIRECTION_CHANGE_ON_EXISTING_ROAD_PENALTY;
else
res += AI_PATHFINDER_DIRECTION_CHANGE_PENALTY;
}
} else {
// For rail we have 1 exeption: diagonal rail..
// So we fetch 2 raildirection. That of the current one, and of the one before that
if (parent->path.parent != NULL && parent->path.parent->parent != NULL) {
int dir1 = AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile);
int dir2 = AiNew_GetRailDirection(parent->path.parent->parent->node.tile, parent->path.parent->node.tile, parent->path.node.tile);
// First, see if we are on diagonal path, that is better than straight path
if (dir1 > 1) { res -= AI_PATHFINDER_DIAGONAL_BONUS; }
// First see if they are different
if (dir1 != dir2) {
// dir 2 and 3 are 1 diagonal track, and 4 and 5.
if (!(((dir1 == 2 || dir1 == 3) && (dir2 == 2 || dir2 == 3)) || ((dir1 == 4 || dir1 == 5) && (dir2 == 4 || dir2 == 5)))) {
// It is not, so we changed of direction
res += AI_PATHFINDER_DIRECTION_CHANGE_PENALTY;
}
if (parent->path.parent->parent->parent != NULL) {
int dir3 = AiNew_GetRailDirection(parent->path.parent->parent->parent->node.tile, parent->path.parent->parent->node.tile, parent->path.parent->node.tile);
// Check if we changed 3 tiles of direction in 3 tiles.. bad!!!
if ((dir1 == 0 || dir1 == 1) && dir2 > 1 && (dir3 == 0 || dir3 == 1)) {
res += AI_PATHFINDER_CURVE_PENALTY;
}
}
}
}
}
return (res < 0) ? 0 : res;
}

124
ai/trolly/shared.c Normal file
View File

@@ -0,0 +1,124 @@
/* $Id$ */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../debug.h"
#include "../../map.h"
#include "trolly.h"
#include "../../vehicle.h"
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
{
// 0 = vert
// 1 = horz
// 2 = dig up-left
// 3 = dig down-right
// 4 = dig down-left
// 5 = dig up-right
int x1, x2, x3;
int y1, y2, y3;
x1 = TileX(tile_a);
x2 = TileX(tile_b);
x3 = TileX(tile_c);
y1 = TileY(tile_a);
y2 = TileY(tile_b);
y3 = TileY(tile_c);
if (y1 == y2 && y2 == y3) return 0;
if (x1 == x2 && x2 == x3) return 1;
if (y2 > y1) {
if (x2 > x3) return 2;
else return 4;
}
if (x2 > x1) {
if (y2 > y3) return 2;
else return 5;
}
if (y1 > y2) {
if (x2 > x3) return 5;
else return 3;
}
if (x1 > x2) {
if (y2 > y3) return 4;
else return 3;
}
return 0;
}
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
{
int x1, x2, x3;
int y1, y2, y3;
int r;
x1 = TileX(tile_a);
x2 = TileX(tile_b);
x3 = TileX(tile_c);
y1 = TileY(tile_a);
y2 = TileY(tile_b);
y3 = TileY(tile_c);
r = 0;
if (x1 < x2) r += 8;
if (y1 < y2) r += 1;
if (x1 > x2) r += 2;
if (y1 > y2) r += 4;
if (x2 < x3) r += 2;
if (y2 < y3) r += 4;
if (x2 > x3) r += 8;
if (y2 > y3) r += 1;
return r;
}
// Get's the direction between 2 tiles seen from tile_a
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
{
if (TileY(tile_a) < TileY(tile_b)) return 1;
if (TileY(tile_a) > TileY(tile_b)) return 3;
if (TileX(tile_a) < TileX(tile_b)) return 2;
return 0;
}
// This functions looks up if this vehicle is special for this AI
// and returns his flag
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v) {
int 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;
}
}
// Not found :(
return 0;
}
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag) {
int i, new_id = -1;
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;
return true;
}
if (new_id == -1 && p->ainew.special_vehicles[i].veh_id == 0 &&
p->ainew.special_vehicles[i].flag == 0)
new_id = i;
}
// Out of special_vehicle spots :s
if (new_id == -1) {
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;
return true;
}

1353
ai/trolly/trolly.c Normal file

File diff suppressed because it is too large Load Diff

262
ai/trolly/trolly.h Normal file
View File

@@ -0,0 +1,262 @@
/* $Id$ */
#ifndef AI_TROLLY_H
#define AI_TROLLY_H
#include "../../aystar.h"
#include "../../player.h"
/*
* These defines can be altered to change the behavoir of the AI
*
* WARNING:
* This can also alter the AI in a negative way. I will never claim these settings
* are perfect, but don't change them if you don't know what the effect is.
*/
// How many times it the H multiplied. The higher, the more it will go straight to the
// end point. The lower, how more it will find the route with the lowest cost.
// also: the lower, the longer it takes before route is calculated..
#define AI_PATHFINDER_H_MULTIPLER 100
// How many loops may AyStar do before it stops
// 0 = infinite
#define AI_PATHFINDER_LOOPS_PER_TICK 5
// How long may the AI search for one route?
// 0 = infinite
// This number is the number of tiles tested.
// It takes (AI_PATHFINDER_MAX_SEARCH_NODES / AI_PATHFINDER_LOOPS_PER_TICK) ticks
// to get here.. with 5000 / 10 = 500. 500 / 74 (one day) = 8 days till it aborts
// (that is: if the AI is on VERY FAST! :p
#define AI_PATHFINDER_MAX_SEARCH_NODES 5000
// If you enable this, the AI is not allowed to make 90degree turns
#define AI_PATHFINDER_NO_90DEGREES_TURN
// Below are defines for the g-calculation
// Standard penalty given to a tile
#define AI_PATHFINDER_PENALTY 150
// The penalty given to a tile that is going up
#define AI_PATHFINDER_TILE_GOES_UP_PENALTY 450
// The penalty given to a tile which would have to use fundation
#define AI_PATHFINDER_FOUNDATION_PENALTY 100
// Changing direction is a penalty, to prevent curved ways (with that: slow ways)
#define AI_PATHFINDER_DIRECTION_CHANGE_PENALTY 200
// Same penalty, only for when road already exists
#define AI_PATHFINDER_DIRECTION_CHANGE_ON_EXISTING_ROAD_PENALTY 50
// A diagonal track cost the same as a straigh, but a diagonal is faster... so give
// a bonus for using diagonal track
#ifdef AI_PATHFINDER_NO_90DEGREES_TURN
#define AI_PATHFINDER_DIAGONAL_BONUS 95
#else
#define AI_PATHFINDER_DIAGONAL_BONUS 75
#endif
// If a roadblock already exists, it gets a bonus
#define AI_PATHFINDER_ROAD_ALREADY_EXISTS_BONUS 140
// To prevent 3 direction changes in 3 tiles, this penalty is given in such situation
#define AI_PATHFINDER_CURVE_PENALTY 200
// Penalty a bridge gets per length
#define AI_PATHFINDER_BRIDGE_PENALTY 180
// The penalty for a bridge going up
#define AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY 1000
// Tunnels are expensive...
// Because of that, every tile the cost is increased with 1/8th of his value
// This is also true if you are building a tunnel yourself
#define AI_PATHFINDER_TUNNEL_PENALTY 350
/*
* Ai_New defines
*/
// How long may we search cities and industry for a new route?
#define AI_LOCATE_ROUTE_MAX_COUNTER 200
// How many days must there be between building the first station and the second station
// within one city. This number is in days and should be more than 4 months.
#define AI_CHECKCITY_DATE_BETWEEN 180
// How many cargo is needed for one station in a city?
#define AI_CHECKCITY_CARGO_PER_STATION 60
// How much cargo must there not be used in a city before we can build a new station?
#define AI_CHECKCITY_NEEDED_CARGO 50
// When there is already a station which takes the same good and the rating of that
// city is higher then this numer, we are not going to attempt to build anything
// there
#define AI_CHECKCITY_CARGO_RATING 50
// But, there is a chance of 1 out of this number, that we do ;)
#define AI_CHECKCITY_CARGO_RATING_CHANCE 5
// If a city is too small to contain a station, there is a small chance
// that we still do so.. just to make the city bigger!
#define AI_CHECKCITY_CITY_CHANCE 5
// This number indicates for every unit of cargo, how many tiles two stations maybe be away
// from eachother. In other words: if we have 120 units of cargo in one station, and 120 units
// of the cargo in the other station, both stations can be 96 units away from eachother, if the
// next number is 0.4.
#define AI_LOCATEROUTE_BUS_CARGO_DISTANCE 0.4
#define AI_LOCATEROUTE_TRUCK_CARGO_DISTANCE 0.7
// In whole tiles, the minimum distance for a truck route
#define AI_LOCATEROUTE_TRUCK_MIN_DISTANCE 30
// The amount of tiles in a square from -X to +X that is scanned for a station spot
// (so if this number is 10, 20x20 = 400 tiles are scanned for _the_ perfect spot
// Safe values are between 15 and 5
#define AI_FINDSTATION_TILE_RANGE 10
// Building on normal speed goes very fast. Idle this amount of ticks between every
// building part. It is calculated like this: (4 - competitor_speed) * num + 1
// where competitor_speed is between 0 (very slow) to 4 (very fast)
#define AI_BUILDPATH_PAUSE 10
// Minimum % of reliabilty a vehicle has to have before the AI buys it
#define AI_VEHICLE_MIN_RELIABILTY 60
// The minimum amount of money a player should always have
#define AI_MINIMUM_MONEY 15000
// If the most cheap route is build, how much is it going to cost..
// This is to prevent the AI from trying to build a route which can not be paid for
#define AI_MINIMUM_BUS_ROUTE_MONEY 25000
#define AI_MINIMUM_TRUCK_ROUTE_MONEY 35000
// The minimum amount of money before we are going to repay any money
#define AI_MINIMUM_LOAN_REPAY_MONEY 40000
// How many repays do we do if we have enough money to do so?
// Every repay is 10000
#define AI_LOAN_REPAY 2
// How much income must we have before paying back a loan? Month-based (and looked at the last month)
#define AI_MINIMUM_INCOME_FOR_LOAN 7000
// If there is <num> time as much cargo in the station then the vehicle can handle
// reuse the station instead of building a new one!
#define AI_STATION_REUSE_MULTIPLER 2
// No more than this amount of vehicles per station..
#define AI_CHECK_MAX_VEHICLE_PER_STATION 10
// How many thick between building 2 vehicles
#define AI_BUILD_VEHICLE_TIME_BETWEEN DAY_TICKS
// How many days must there between vehicle checks
// The more often, the less non-money-making lines there will be
// but the unfair it may seem to a human player
#define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
// How money profit does a vehicle needs to make to stay in order
// This is the profit of this year + profit of last year
// But also for vehicles that are just one year old. In other words:
// Vehicles of 2 years do easier meet this setting then vehicles
// of one year. This is a very good thing. New vehicles are filtered,
// while old vehicles stay longer, because we do get less in return.
#define AI_MINIMUM_ROUTE_PROFIT 1000
// A vehicle is considered lost when he his cargo is more than 180 days old
#define AI_VEHICLE_LOST_DAYS 180
// How many times may the AI try to find a route before it gives up
#define AI_MAX_TRIES_FOR_SAME_ROUTE 8
/*
* End of defines
*/
// This stops 90degrees curves
static const byte _illegal_curves[6] = {
255, 255, // Horz and vert, don't have the effect
5, // upleft and upright are not valid
4, // downright and downleft are not valid
2, // downleft and upleft are not valid
3, // upright and downright are not valid
};
enum {
AI_STATE_STARTUP = 0,
AI_STATE_FIRST_TIME,
AI_STATE_NOTHING,
AI_STATE_WAKE_UP,
AI_STATE_LOCATE_ROUTE,
AI_STATE_FIND_STATION,
AI_STATE_FIND_PATH,
AI_STATE_FIND_DEPOT,
AI_STATE_VERIFY_ROUTE,
AI_STATE_BUILD_STATION,
AI_STATE_BUILD_PATH,
AI_STATE_BUILD_DEPOT,
AI_STATE_BUILD_VEHICLE,
AI_STATE_WAIT_FOR_BUILD,
AI_STATE_GIVE_ORDERS,
AI_STATE_START_VEHICLE,
AI_STATE_REPAY_MONEY,
AI_STATE_CHECK_ALL_VEHICLES,
AI_STATE_ACTION_DONE,
AI_STATE_STOP, // Temporary function to stop the AI
};
// Used for tbt (train/bus/truck)
enum {
AI_TRAIN = 0,
AI_BUS,
AI_TRUCK,
};
enum {
AI_ACTION_NONE = 0,
AI_ACTION_BUS_ROUTE,
AI_ACTION_TRUCK_ROUTE,
AI_ACTION_REPAY_LOAN,
AI_ACTION_CHECK_ALL_VEHICLES,
};
// Used for from_type/to_type
enum {
AI_NO_TYPE = 0,
AI_CITY,
AI_INDUSTRY,
};
// Flags for in the vehicle
enum {
AI_VEHICLEFLAG_SELL = 1,
// Remember, flags must be in power of 2
};
#define AI_NO_CARGO 0xFF // Means that there is no cargo defined yet (used for industry)
#define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
#define AI_STATION_RANGE TileXY(MapMaxX(), MapMaxY())
#define AI_PATHFINDER_NO_DIRECTION (byte)-1
// Flags used in user_data
#define AI_PATHFINDER_FLAG_BRIDGE 1
#define AI_PATHFINDER_FLAG_TUNNEL 2
typedef void AiNew_StateFunction(Player *p);
// ai_new.c
void AiNewDoGameLoop(Player *p);
// ai_pathfinder.c
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo);
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo);
// ai_shared.c
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b);
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
// ai_build.c
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
int AiNew_PickVehicle(Player *p);
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag);
#endif /* AI_TROLLY_H */

16
aircraft.h Normal file
View File

@@ -0,0 +1,16 @@
/* $Id$ */
#include "station_map.h"
#include "vehicle.h"
static inline bool IsAircraftInHangar(const Vehicle* v)
{
assert(v->type == VEH_Aircraft);
return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
}
static inline bool IsAircraftInHangarStopped(const Vehicle* v)
{
return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
}

1988
aircraft_cmd.c Normal file

File diff suppressed because it is too large Load Diff

1193
aircraft_gui.c Normal file

File diff suppressed because it is too large Load Diff

383
airport.c Normal file
View File

@@ -0,0 +1,383 @@
/* $Id$ */
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "map.h"
#include "airport.h"
#include "macros.h"
#include "variables.h"
static AirportFTAClass* CountryAirport;
static AirportFTAClass* CityAirport;
static AirportFTAClass* Oilrig;
static AirportFTAClass* Heliport;
static AirportFTAClass* MetropolitanAirport;
static AirportFTAClass* InternationalAirport;
static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
const byte *terminals, const byte *helipads,
const byte entry_point, const byte acc_planes,
const AirportFTAbuildup *FA,
const TileIndexDiffC *depots, const byte nof_depots);
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA);
static byte AirportTestFTA(const AirportFTAClass *Airport);
/*static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
static byte AirportBlockToString(uint32 block);*/
void InitializeAirports(void)
{
// country airport
CountryAirport = malloc(sizeof(AirportFTAClass));
AirportFTAClass_Constructor(
CountryAirport,
_airport_terminal_country,
NULL,
16,
ALL,
_airport_fta_country,
_airport_depots_country,
lengthof(_airport_depots_country)
);
// city airport
CityAirport = malloc(sizeof(AirportFTAClass));
AirportFTAClass_Constructor(
CityAirport,
_airport_terminal_city,
NULL,
19,
ALL,
_airport_fta_city,
_airport_depots_city,
lengthof(_airport_depots_city)
);
// metropolitan airport
MetropolitanAirport = malloc(sizeof(AirportFTAClass));
AirportFTAClass_Constructor(
MetropolitanAirport,
_airport_terminal_metropolitan,
NULL,
20,
ALL,
_airport_fta_metropolitan,
_airport_depots_metropolitan,
lengthof(_airport_depots_metropolitan)
);
// international airport
InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
AirportFTAClass_Constructor(
InternationalAirport,
_airport_terminal_international,
_airport_helipad_international,
37,
ALL,
_airport_fta_international,
_airport_depots_international,
lengthof(_airport_depots_international)
);
// heliport, oilrig
Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
AirportFTAClass_Constructor(
Heliport,
NULL,
_airport_helipad_heliport_oilrig,
7,
HELICOPTERS_ONLY,
_airport_fta_heliport_oilrig,
NULL,
0
);
Oilrig = Heliport; // exactly the same structure for heliport/oilrig, so share state machine
}
void UnInitializeAirports(void)
{
AirportFTAClass_Destructor(CountryAirport);
AirportFTAClass_Destructor(CityAirport);
AirportFTAClass_Destructor(Heliport);
AirportFTAClass_Destructor(MetropolitanAirport);
AirportFTAClass_Destructor(InternationalAirport);
}
static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
const byte *terminals, const byte *helipads,
const byte entry_point, const byte acc_planes,
const AirportFTAbuildup *FA,
const TileIndexDiffC *depots, const byte nof_depots)
{
byte nofterminals, nofhelipads;
byte nofterminalgroups = 0;
byte nofhelipadgroups = 0;
const byte * curr;
int i;
nofterminals = nofhelipads = 0;
//now we read the number of terminals we have
if (terminals != NULL) {
i = terminals[0];
nofterminalgroups = i;
curr = terminals;
while (i-- > 0) {
curr++;
assert(*curr != 0); //we don't want to have an empty group
nofterminals += *curr;
}
}
Airport->terminals = terminals;
//read helipads
if (helipads != NULL) {
i = helipads[0];
nofhelipadgroups = i;
curr = helipads;
while (i-- > 0) {
curr++;
assert(*curr != 0); //no empty groups please
nofhelipads += *curr;
}
}
Airport->helipads = helipads;
// if there are more terminals than 6, internal variables have to be changed, so don't allow that
// same goes for helipads
if (nofterminals > MAX_TERMINALS) { printf("Currently only maximum of %2d terminals are supported (you wanted %2d)\n", MAX_TERMINALS, nofterminals);}
if (nofhelipads > MAX_HELIPADS) { printf("Currently only maximum of %2d helipads are supported (you wanted %2d)\n", MAX_HELIPADS, nofhelipads);}
// terminals/helipads are divided into groups. Groups are computed by dividing the number
// of terminals by the number of groups. Half in half. If #terminals is uneven, first group
// will get the less # of terminals
assert(nofterminals <= MAX_TERMINALS);
assert(nofhelipads <= MAX_HELIPADS);
Airport->nofelements = AirportGetNofElements(FA);
// check
if (entry_point >= Airport->nofelements) {printf("Entry point (%2d) must be within the airport positions (which is max %2d)\n", entry_point, Airport->nofelements);}
assert(entry_point < Airport->nofelements);
Airport->acc_planes = acc_planes;
Airport->entry_point = entry_point;
Airport->airport_depots = depots;
Airport->nof_depots = nof_depots;
// build the state machine
AirportBuildAutomata(Airport, FA);
DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s); Entry Point %d",
Airport->nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, Airport->entry_point
);
{
byte ret = AirportTestFTA(Airport);
if (ret != MAX_ELEMENTS) printf("ERROR with element: %d\n", ret - 1);
assert(ret == MAX_ELEMENTS);
}
// print out full information
// true -- full info including heading, block, etc
// false -- short info, only position and next position
//AirportPrintOut(Airport, false);
}
static void AirportFTAClass_Destructor(AirportFTAClass *Airport)
{
int i;
AirportFTA *current, *next;
for (i = 0; i < Airport->nofelements; i++) {
current = Airport->layout[i].next_in_chain;
while (current != NULL) {
next = current->next_in_chain;
free(current);
current = next;
};
}
free(Airport->layout);
free(Airport);
}
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA)
{
int i;
uint16 nofelements = 0;
int temp = FA[0].position;
for (i = 0; i < MAX_ELEMENTS; i++) {
if (temp != FA[i].position) {
nofelements++;
temp = FA[i].position;
}
if (FA[i].position == MAX_ELEMENTS) break;
}
return nofelements;
}
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA)
{
AirportFTA *FAutomata;
AirportFTA *current;
uint16 internalcounter, i;
FAutomata = malloc(sizeof(AirportFTA) * Airport->nofelements);
Airport->layout = FAutomata;
internalcounter = 0;
for (i = 0; i < Airport->nofelements; i++) {
current = &Airport->layout[i];
current->position = FA[internalcounter].position;
current->heading = FA[internalcounter].heading;
current->block = FA[internalcounter].block;
current->next_position = FA[internalcounter].next_in_chain;
// outgoing nodes from the same position, create linked list
while (current->position == FA[internalcounter + 1].position) {
AirportFTA* newNode = malloc(sizeof(AirportFTA));
newNode->position = FA[internalcounter + 1].position;
newNode->heading = FA[internalcounter + 1].heading;
newNode->block = FA[internalcounter + 1].block;
newNode->next_position = FA[internalcounter + 1].next_in_chain;
// create link
current->next_in_chain = newNode;
current = current->next_in_chain;
internalcounter++;
} // while
current->next_in_chain = NULL;
internalcounter++;
}
}
static byte AirportTestFTA(const AirportFTAClass *Airport)
{
byte position, i, next_element;
AirportFTA *temp;
next_element = 0;
for (i = 0; i < Airport->nofelements; i++) {
position = Airport->layout[i].position;
if (position != next_element) return i;
temp = &Airport->layout[i];
do {
if (temp->heading > MAX_HEADINGS && temp->heading != 255) return i;
if (temp->heading == 0 && temp->next_in_chain != 0) return i;
if (position != temp->position) return i;
if (temp->next_position >= Airport->nofelements) return i;
temp = temp->next_in_chain;
} while (temp != NULL);
next_element++;
}
return MAX_ELEMENTS;
}
#if 0
static const char* const _airport_heading_strings[] = {
"TO_ALL",
"HANGAR",
"TERM1",
"TERM2",
"TERM3",
"TERM4",
"TERM5",
"TERM6",
"HELIPAD1",
"HELIPAD2",
"TAKEOFF",
"STARTTAKEOFF",
"ENDTAKEOFF",
"HELITAKEOFF",
"FLYING",
"LANDING",
"ENDLANDING",
"HELILANDING",
"HELIENDLANDING",
"DUMMY" // extra heading for 255
};
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report)
{
AirportFTA *temp;
uint16 i;
byte heading;
printf("(P = Current Position; NP = Next Position)\n");
for (i = 0; i < Airport->nofelements; i++) {
temp = &Airport->layout[i];
if (full_report) {
heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
_airport_heading_strings[heading], AirportBlockToString(temp->block));
} else {
printf("P:%2d NP:%2d", temp->position, temp->next_position);
}
while (temp->next_in_chain != NULL) {
temp = temp->next_in_chain;
if (full_report) {
heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
_airport_heading_strings[heading], AirportBlockToString(temp->block));
} else {
printf("P:%2d NP:%2d", temp->position, temp->next_position);
}
}
printf("\n");
}
}
static byte AirportBlockToString(uint32 block)
{
byte i = 0;
if (block & 0xffff0000) { block >>= 16; i += 16; }
if (block & 0x0000ff00) { block >>= 8; i += 8; }
if (block & 0x000000f0) { block >>= 4; i += 4; }
if (block & 0x0000000c) { block >>= 2; i += 2; }
if (block & 0x00000002) { i += 1; }
return i;
}
#endif
const AirportFTAClass* GetAirport(const byte airport_type)
{
AirportFTAClass *Airport = NULL;
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code
// needs constant change if more airports are added
switch (airport_type) {
case AT_SMALL: Airport = CountryAirport; break;
case AT_LARGE: Airport = CityAirport; break;
case AT_METROPOLITAN: Airport = MetropolitanAirport; break;
case AT_HELIPORT: Airport = Heliport; break;
case AT_OILRIG: Airport = Oilrig; break;
case AT_INTERNATIONAL: Airport = InternationalAirport; break;
default:
#ifdef DEBUG__
printf("Airport AircraftNextAirportPos_and_Order not yet implemented\n");
#endif
assert(airport_type <= AT_INTERNATIONAL);
}
return Airport;
}
uint32 GetValidAirports(void)
{
uint32 bytemask = _avail_aircraft; /// sets the first 3 bytes, 0 - 2, @see AdjustAvailAircraft()
// 1980-1-1 is --> 21915
// 1990-1-1 is --> 25568
if (_date >= 21915) SETBIT(bytemask, 3); // metropilitan airport 1980
if (_date >= 25568) SETBIT(bytemask, 4); // international airport 1990
return bytemask;
}

60
airport.h Normal file
View File

@@ -0,0 +1,60 @@
/* $Id$ */
#ifndef AIRPORT_H
#define AIRPORT_H
#include "airport_movement.h"
enum {MAX_TERMINALS = 6};
enum {MAX_HELIPADS = 2};
// Airport types
enum {
AT_SMALL = 0,
AT_LARGE = 1,
AT_HELIPORT = 2,
AT_METROPOLITAN = 3,
AT_INTERNATIONAL = 4,
AT_OILRIG = 15
};
// do not change unless you change v->subtype too. This aligns perfectly with its current setting
enum {
AIRCRAFT_ONLY = 0,
ALL = 1,
HELICOPTERS_ONLY = 2
};
// Finite sTate mAchine --> FTA
typedef struct AirportFTAClass {
byte nofelements; // number of positions the airport consists of
const byte *terminals;
const byte *helipads;
byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point
byte acc_planes; // accept airplanes or helicopters or both
const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
byte nof_depots; // number of depots this airport has
struct AirportFTA *layout; // state machine for airport
} AirportFTAClass;
// internal structure used in openttd - Finite sTate mAchine --> FTA
typedef struct AirportFTA {
byte position; // the position that an airplane is at
byte next_position; // next position from this position
uint32 block; // 32 bit blocks (st->airport_flags), should be enough for the most complex airports
byte heading; // heading (current orders), guiding an airplane to its target on an airport
struct AirportFTA *next_in_chain; // possible extra movement choices from this position
} AirportFTA;
void InitializeAirports(void);
void UnInitializeAirports(void);
const AirportFTAClass* GetAirport(const byte airport_type);
/** Get buildable airport bitmask.
* @return get all buildable airports at this given time, bitmasked.
* Bit 0 means the small airport is buildable, etc.
* @todo set availability of airports by year, instead of airplane
*/
uint32 GetValidAirports(void);
#endif /* AIRPORT_H */

251
airport_gui.c Normal file
View File

@@ -0,0 +1,251 @@
/* $Id$ */
#include "stdafx.h"
#include "openttd.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "map.h"
#include "window.h"
#include "gui.h"
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "vehicle.h"
#include "station.h"
#include "airport.h"
#include "depot.h"
static byte _selected_airport_type;
static void ShowBuildAirportPicker(void);
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
if (success) {
SndPlayTileFx(SND_1F_SPLAT, tile);
ResetObjectToPlace();
}
}
static void PlaceAirport(TileIndex tile)
{
DoCommandP(tile, _selected_airport_type, 0, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
}
static void PlaceAir_DemolishArea(TileIndex tile)
{
VpStartPlaceSizing(tile, 4);
}
static void BuildAirClick_Airport(Window *w)
{
if (HandlePlacePushButton(w, 3, SPR_CURSOR_AIRPORT, 1, PlaceAirport)) ShowBuildAirportPicker();
}
static void BuildAirClick_Demolish(Window *w)
{
HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceAir_DemolishArea);
}
static void BuildAirClick_Landscaping(Window *w)
{
ShowTerraformToolbar();
}
typedef void OnButtonClick(Window *w);
static OnButtonClick * const _build_air_button_proc[] = {
BuildAirClick_Airport,
BuildAirClick_Demolish,
BuildAirClick_Landscaping,
};
static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
break;
case WE_CLICK:
if (e->click.widget - 3 >= 0)
_build_air_button_proc[e->click.widget - 3](w);
break;
case WE_KEYPRESS: {
switch (e->keypress.keycode) {
case '1': BuildAirClick_Airport(w); break;
case '2': BuildAirClick_Demolish(w); break;
case 'l': BuildAirClick_Landscaping(w); break;
default: return;
}
} break;
case WE_PLACE_OBJ:
_place_proc(e->place.tile);
break;
case WE_PLACE_DRAG: {
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
return;
}
case WE_PLACE_MOUSEUP:
if (e->place.pt.x != -1) {
DoCommandP(e->place.tile, e->place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
}
break;
case WE_ABORT_PLACE_OBJ:
UnclickWindowButtons(w);
SetWindowDirty(w);
w = FindWindowById(WC_BUILD_STATION, 0);
if (w != 0)
WP(w,def_d).close = true;
break;
case WE_DESTROY:
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
break;
}
}
static const Widget _air_toolbar_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 73, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_NONE, 7, 74, 85, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PANEL, RESIZE_NONE, 7, 0, 41, 14, 35, 0x2E8, STR_A01E_BUILD_AIRPORT},
{ WWT_PANEL, RESIZE_NONE, 7, 42, 63, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC},
{ WWT_PANEL, RESIZE_NONE, 7, 64, 85, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP},
{ WIDGETS_END},
};
static const WindowDesc _air_toolbar_desc = {
640-86, 22, 86, 36,
WC_BUILD_TOOLBAR,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
_air_toolbar_widgets,
BuildAirToolbWndProc
};
void ShowBuildAirToolbar(void)
{
if (_current_player == OWNER_SPECTATOR) return;
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDescFront(&_air_toolbar_desc, 0);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();
}
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT: {
int sel;
int rad = 4; // default catchment radious
uint32 avail_airports;
if (WP(w,def_d).close) return;
sel = _selected_airport_type;
avail_airports = GetValidAirports();
if (!HASBIT(avail_airports, 0) && sel == AT_SMALL) sel = AT_LARGE;
if (!HASBIT(avail_airports, 1) && sel == AT_LARGE) sel = AT_SMALL;
/* 'Country Airport' starts at widget 3, and if its bit is set, it is
* available, so take its opposite value to set the disabled_state. There
* are only 5 available airports, so XOR with 0x1F (1 1111) */
w->disabled_state = (avail_airports ^ 0x1F) << 3;
_selected_airport_type = sel;
// select default the coverage area to 'Off' (8)
w->click_state = ((1<<3) << sel) | ((1<<8) << _station_show_coverage);
SetTileSelectSize(_airport_size_x[sel],_airport_size_y[sel]);
if (_patches.modified_catchment) {
switch (sel) {
case AT_OILRIG: rad = CA_AIR_OILPAD; break;
case AT_HELIPORT: rad = CA_AIR_HELIPORT; break;
case AT_SMALL: rad = CA_AIR_SMALL; break;
case AT_LARGE: rad = CA_AIR_LARGE; break;
case AT_METROPOLITAN: rad = CA_AIR_METRO; break;
case AT_INTERNATIONAL: rad = CA_AIR_INTER; break;
}
}
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
DrawWindowWidgets(w);
// strings such as 'Size' and 'Coverage Area'
DrawStringCentered(74, 16, STR_305B_SIZE, 0);
DrawStringCentered(74, 78, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0);
DrawStationCoverageAreaText(2, 104, (uint)-1, rad);
break;
}
case WE_CLICK: {
switch (e->click.widget) {
case 3: case 4: case 5: case 6: case 7:
_selected_airport_type = e->click.widget - 3;
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
case 8: case 9:
_station_show_coverage = e->click.widget - 8;
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
}
} break;
case WE_MOUSELOOP: {
if (WP(w,def_d).close) {
DeleteWindow(w);
return;
}
CheckRedrawStationCoverage(w);
} break;
case WE_DESTROY:
if (!WP(w,def_d).close) ResetObjectToPlace();
break;
}
}
static const Widget _build_airport_picker_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 130, 0x0, STR_NULL},
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 73, 27, 38, STR_3059_SMALL, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 74, 145, 27, 38, STR_305A_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 145, 63, 74, STR_306B_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 145, 39, 50, STR_305AA_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 2, 145, 51, 62, STR_305AB_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 88, 98, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 88, 98, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
{ WIDGETS_END},
};
static const WindowDesc _build_airport_desc = {
-1, -1, 148, 131, // height, 130+1
WC_BUILD_STATION,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_airport_picker_widgets,
BuildAirportPickerWndProc
};
static void ShowBuildAirportPicker(void)
{
AllocateWindowDesc(&_build_airport_desc);
}
void InitializeAirportGui(void)
{
_selected_airport_type = AT_SMALL;
_last_built_aircraft_depot_tile = 0;
}

469
airport_movement.h Normal file
View File

@@ -0,0 +1,469 @@
/* $Id$ */
#ifndef AIRPORT_MOVEMENT_H
#define AIRPORT_MOVEMENT_H
#include "stdafx.h"
typedef struct AirportMovingData {
int x,y;
byte flag;
byte direction;
} AirportMovingData;
// state machine input struct (from external file, etc.)
// Finite sTate mAchine --> FTA
typedef struct AirportFTAbuildup {
byte position; // the position that an airplane is at
byte heading; // the current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.)
uint32 block; // the block this position is on on the airport (st->airport_flags)
byte next_in_chain; // next position from this position
} AirportFTAbuildup;
enum {
AMED_NOSPDCLAMP = 1<<0,
AMED_TAKEOFF = 1<<1,
AMED_SLOWTURN = 1<<2,
AMED_LAND = 1<<3,
AMED_EXACTPOS = 1<<4,
AMED_BRAKE = 1<<5,
AMED_HELI_RAISE = 1<<6,
AMED_HELI_LOWER = 1<<7,
};
enum {MAX_ELEMENTS = 255};
enum {MAX_HEADINGS = 18};
///////////////////////////////////////////////////////////////////////
///////***********Movement States on Airports********************//////
// headings target
enum {
TO_ALL = 0,
HANGAR = 1,
TERM1 = 2,
TERM2 = 3,
TERM3 = 4,
TERM4 = 5,
TERM5 = 6,
TERM6 = 7,
HELIPAD1 = 8,
HELIPAD2 = 9,
TAKEOFF = 10,
STARTTAKEOFF = 11,
ENDTAKEOFF = 12,
HELITAKEOFF = 13,
FLYING = 14,
LANDING = 15,
ENDLANDING = 16,
HELILANDING = 17,
HELIENDLANDING = 18
};
///////////////////////////////////////////////////////////////////////
///////**********Movement Blocks on Airports*********************//////
// blocks (eg_airport_flags)
enum {
TERM1_block = 1 << 0,
TERM2_block = 1 << 1,
TERM3_block = 1 << 2,
TERM4_block = 1 << 3,
TERM5_block = 1 << 4,
TERM6_block = 1 << 5,
HELIPAD1_block = 1 << 6,
HELIPAD2_block = 1 << 7,
RUNWAY_IN_OUT_block = 1 << 8,
RUNWAY_IN_block = 1 << 8,
AIRPORT_BUSY_block = 1 << 8,
RUNWAY_OUT_block = 1 << 9,
TAXIWAY_BUSY_block = 1 << 10,
OUT_WAY_block = 1 << 11,
IN_WAY_block = 1 << 12,
AIRPORT_ENTRANCE_block = 1 << 13,
TERM_GROUP1_block = 1 << 14,
TERM_GROUP2_block = 1 << 15,
HANGAR2_AREA_block = 1 << 16,
TERM_GROUP2_ENTER1_block = 1 << 17,
TERM_GROUP2_ENTER2_block = 1 << 18,
TERM_GROUP2_EXIT1_block = 1 << 19,
TERM_GROUP2_EXIT2_block = 1 << 20,
PRE_HELIPAD_block = 1 << 21,
NOTHING_block = 1 << 30
};
///////////////////////////////////////////////////////////////////////
/////*********Movement Positions on Airports********************///////
// Country Airfield (small) 4x3
static const AirportMovingData _airport_moving_data_country[22] = {
{ 53, 3,AMED_EXACTPOS,3}, // 00 In Hangar
{ 53, 27,0,0}, // 01 Taxi to right outside depot
{ 32, 23,AMED_EXACTPOS,7}, // 02 Terminal 1
{ 10, 23,AMED_EXACTPOS,7}, // 03 Terminal 2
{ 43, 37,0,0}, // 04 Going towards terminal 2
{ 24, 37,0,0}, // 05 Going towards terminal 2
{ 53, 37,0,0}, // 06 Going for takeoff
{ 61, 40,AMED_EXACTPOS,1}, // 07 Taxi to start of runway (takeoff)
{ 3, 40,AMED_NOSPDCLAMP,0}, // 08 Accelerate to end of runway
{-79, 40,AMED_NOSPDCLAMP | AMED_TAKEOFF,0}, // 09 Take off
{177, 40,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 10 Fly to landing position in air
{ 56, 40,AMED_NOSPDCLAMP | AMED_LAND,0}, // 11 Going down for land
{ 3, 40,AMED_NOSPDCLAMP | AMED_BRAKE,0}, // 12 Just landed, brake until end of runway
{ 7, 40,0,0}, // 13 Just landed, turn around and taxi 1 square
{ 53, 40,0,0}, // 14 Taxi from runway to crossing
{-31,193,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 15 Fly around waiting for a landing spot (north-east)
{ 1, 1,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 16 Fly around waiting for a landing spot (north-west)
{257, 1,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 17 Fly around waiting for a landing spot (south-west)
{273, 49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 18 Fly around waiting for a landing spot (south)
{ 44, 37,AMED_HELI_RAISE,0}, // 19 Helicopter takeoff
{ 44, 40,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 20 In position above landing spot helicopter
{ 44, 40,AMED_HELI_LOWER,0} // 21 Helicopter landing
};
// City Airport (large) 6x6
static const AirportMovingData _airport_moving_data_town[25] = {
{ 85, 3,AMED_EXACTPOS,3}, // 00 In Hangar
{ 85, 27,0,0}, // 01 Taxi to right outside depot
{ 26, 41,AMED_EXACTPOS,5}, // 02 Terminal 1
{ 56, 20,AMED_EXACTPOS,3}, // 03 Terminal 2
{ 38, 8,AMED_EXACTPOS,5}, // 04 Terminal 3
{ 65, 6,0,0}, // 05 Taxi to right in infront of terminal 2/3
{ 80, 27,0,0}, // 06 Taxiway terminals 2-3
{ 44, 63,0,0}, // 07 Taxi to Airport center
{ 58, 71,0,0}, // 08 Towards takeoff
{ 72, 85,0,0}, // 09 Taxi to runway (takeoff)
{ 89, 85,AMED_EXACTPOS,1}, // 10 Taxi to start of runway (takeoff)
{ 3, 85,AMED_NOSPDCLAMP,0}, // 11 Accelerate to end of runway
{-79, 85,AMED_NOSPDCLAMP | AMED_TAKEOFF,0}, // 12 Take off
{177, 85,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 13 Fly to landing position in air
{ 89, 85,AMED_NOSPDCLAMP | AMED_LAND,0}, // 14 Going down for land
{ 3, 85,AMED_NOSPDCLAMP | AMED_BRAKE,0}, // 15 Just landed, brake until end of runway
{ 20, 87,0,0}, // 16 Just landed, turn around and taxi 1 square
{ 36, 71,0,0}, // 17 Taxi from runway to crossing
{-31,193,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 18 Fly around waiting for a landing spot (north-east)
{ 1, 1,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 19 Fly around waiting for a landing spot (north-west)
{257, 1,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 20 Fly around waiting for a landing spot (south-west)
{273, 49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 21 Fly around waiting for a landing spot (south)
{ 44, 63,AMED_HELI_RAISE,0}, // 22 Helicopter takeoff
{ 28, 74,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 23 In position above landing spot helicopter
{ 28, 74,AMED_HELI_LOWER,0} // 24 Helicopter landing
};
// Metropolitan Airport (metropolitan) - 2 runways
static const AirportMovingData _airport_moving_data_metropolitan[27] = {
{ 85, 3,AMED_EXACTPOS,3}, // 00 In Hangar
{ 85, 27,0,0}, // 01 Taxi to right outside depot
{ 26, 41,AMED_EXACTPOS,5}, // 02 Terminal 1
{ 56, 20,AMED_EXACTPOS,3}, // 03 Terminal 2
{ 38, 8,AMED_EXACTPOS,5}, // 04 Terminal 3
{ 65, 6,0,0}, // 05 Taxi to right in infront of terminal 2/3
{ 70, 33,0,0}, // 06 Taxiway terminals 2-3
{ 44, 58,0,0}, // 07 Taxi to Airport center
{ 72, 58,0,0}, // 08 Towards takeoff
{ 72, 69,0,0}, // 09 Taxi to runway (takeoff)
{ 89, 69,AMED_EXACTPOS,1}, // 10 Taxi to start of runway (takeoff)
{ 3, 69,AMED_NOSPDCLAMP,0}, // 11 Accelerate to end of runway
{-79, 69,AMED_NOSPDCLAMP | AMED_TAKEOFF,0}, // 12 Take off
{177, 85,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 13 Fly to landing position in air
{ 89, 85,AMED_NOSPDCLAMP | AMED_LAND,0}, // 14 Going down for land
{ 3, 85,AMED_NOSPDCLAMP | AMED_BRAKE,0}, // 15 Just landed, brake until end of runway
{ 21, 85,0,0}, // 16 Just landed, turn around and taxi 1 square
{ 21, 69,0,0}, // 17 On Runway-out taxiing to In-Way
{ 21, 54,AMED_EXACTPOS,5}, // 18 Taxi from runway to crossing
{-31,193,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 19 Fly around waiting for a landing spot (north-east)
{ 1, 1,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 20 Fly around waiting for a landing spot (north-west)
{257, 1,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 21 Fly around waiting for a landing spot (south-west)
{273, 49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 22 Fly around waiting for a landing spot (south)
{ 44, 58,0,0}, // 23 Helicopter takeoff spot on ground (to clear airport sooner)
{ 44, 63,AMED_HELI_RAISE,0}, // 24 Helicopter takeoff
{ 15, 54,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 25 Get in position above landing spot helicopter
{ 15, 54,AMED_HELI_LOWER,0} // 26 Helicopter landing
};
// International Airport (international) - 2 runways, 6 terminals, dedicated helipod
static const AirportMovingData _airport_moving_data_international[51] = {
{ 7, 55,AMED_EXACTPOS,3}, // 00 In Hangar 1
{100, 21,AMED_EXACTPOS,3}, // 01 In Hangar 2
{ 7, 70,0,0}, // 02 Taxi to right outside depot
{100, 36,0,0}, // 03 Taxi to right outside depot
{ 38, 70,AMED_EXACTPOS,5}, // 04 Terminal 1
{ 38, 54,AMED_EXACTPOS,5}, // 05 Terminal 2
{ 38, 38,AMED_EXACTPOS,5}, // 06 Terminal 3
{ 70, 70,AMED_EXACTPOS,1}, // 07 Terminal 4
{ 70, 54,AMED_EXACTPOS,1}, // 08 Terminal 5
{ 70, 38,AMED_EXACTPOS,1}, // 09 Terminal 6
{104, 71,AMED_EXACTPOS,1}, // 10 Helipad 1
{104, 55,AMED_EXACTPOS,1}, // 11 Helipad 2
{ 22, 87,0,0}, // 12 Towards Terminals 4/5/6, Helipad 1/2
{ 60, 87,0,0}, // 13 Towards Terminals 4/5/6, Helipad 1/2
{ 66, 87,0,0}, // 14 Towards Terminals 4/5/6, Helipad 1/2
{ 86, 87,AMED_EXACTPOS,7}, // 15 Towards Terminals 4/5/6, Helipad 1/2
{ 86, 70,0,0}, // 16 In Front of Terminal 4 / Helipad 1
{ 86, 54,0,0}, // 17 In Front of Terminal 5 / Helipad 2
{ 86, 38,0,0}, // 18 In Front of Terminal 6
{ 86, 22,0,0}, // 19 Towards Terminals Takeoff (Taxiway)
{ 66, 22,0,0}, // 20 Towards Terminals Takeoff (Taxiway)
{ 60, 22,0,0}, // 21 Towards Terminals Takeoff (Taxiway)
{ 38, 22,0,0}, // 22 Towards Terminals Takeoff (Taxiway)
{ 22, 70,0,0}, // 23 In Front of Terminal 1
{ 22, 58,0,0}, // 24 In Front of Terminal 2
{ 22, 38,0,0}, // 25 In Front of Terminal 3
{ 22, 22,AMED_EXACTPOS,7}, // 26 Going for Takeoff
{ 22, 6,0,0}, // 27 On Runway-out, prepare for takeoff
{ 3, 6,AMED_EXACTPOS,5}, // 28 Accelerate to end of runway
{ 60, 6,AMED_NOSPDCLAMP,0}, // 29 Release control of runway, for smoother movement
{105, 6,AMED_NOSPDCLAMP,0}, // 30 End of runway
{190, 6,AMED_NOSPDCLAMP | AMED_TAKEOFF,0}, // 31 Take off
{193,104,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 32 Fly to landing position in air
{105,104,AMED_NOSPDCLAMP | AMED_LAND,0}, // 33 Going down for land
{ 3,104,AMED_NOSPDCLAMP | AMED_BRAKE,0}, // 34 Just landed, brake until end of runway
{ 12,104,0,0}, // 35 Just landed, turn around and taxi 1 square
{ 7, 84,0,0}, // 36 Taxi from runway to crossing
{-31,209,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 37 Fly around waiting for a landing spot (north-east)
{ 1, 6,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 38 Fly around waiting for a landing spot (north-west)
{273, 6,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 39 Fly around waiting for a landing spot (south-west)
{305, 81,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 40 Fly around waiting for a landing spot (south)
// Helicopter
{128, 80,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 41 Bufferspace before helipad
{128, 80,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 42 Bufferspace before helipad
{ 96, 71,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 43 Get in position for Helipad1
{ 96, 55,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 44 Get in position for Helipad2
{ 96, 71,AMED_HELI_LOWER,0}, // 45 Land at Helipad1
{ 96, 55,AMED_HELI_LOWER,0}, // 46 Land at Helipad2
{104, 71,AMED_HELI_RAISE,0}, // 47 Takeoff Helipad1
{104, 55,AMED_HELI_RAISE,0}, // 48 Takeoff Helipad2
{104, 32,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 49 Go to position for Hangarentrance in air
{104, 32,AMED_HELI_LOWER,0} // 50 Land in HANGAR2_AREA to go to hangar
};
// Heliport (heliport)
static const AirportMovingData _airport_moving_data_heliport[9] = {
{ 5, 9,AMED_EXACTPOS,1}, // 0 - At heliport terminal
{ 2, 9,AMED_HELI_RAISE,0}, // 1 - Take off (play sound)
{ -3, 9,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 2 - In position above landing spot helicopter
{ -3, 9,AMED_HELI_LOWER,0}, // 3 - Land
{ 2, 9,0,0}, // 4 - Goto terminal on ground
{-31, 59,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 5 - Circle #1 (north-east)
{-31,-49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 6 - Circle #2 (north-west)
{ 49,-49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 7 - Circle #3 (south-west)
{ 70, 9,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 8 - Circle #4 (south)
};
// Oilrig
static const AirportMovingData _airport_moving_data_oilrig[9] = {
{ 31, 9,AMED_EXACTPOS,1}, // 0 - At oilrig terminal
{ 28, 9,AMED_HELI_RAISE,0}, // 1 - Take off (play sound)
{ 23, 9,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 2 - In position above landing spot helicopter
{ 23, 9,AMED_HELI_LOWER,0}, // 3 - Land
{ 28, 9,0,0}, // 4 - Goto terminal on ground
{-31, 69,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 5 - circle #1 (north-east)
{-31,-49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 6 - circle #2 (north-west)
{ 69,-49,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 7 - circle #3 (south-west)
{ 70, 9,AMED_NOSPDCLAMP | AMED_SLOWTURN,0}, // 8 - circle #4 (south)
};
///////////////////////////////////////////////////////////////////////
/////**********Movement Machine on Airports*********************///////
// first element of depots array tells us how many depots there are (to know size of array)
// this may be changed later when airports are moved to external file
static const TileIndexDiffC _airport_depots_country[] = {{3, 0}};
static const byte _airport_terminal_country[] = {1, 2};
static const AirportFTAbuildup _airport_fta_country[] = {
{ 0,HANGAR,NOTHING_block,1},
{ 1,255,AIRPORT_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM1,TERM1_block,2}, {1,TERM2,0,4}, {1,HELITAKEOFF,0,19}, {1,0,0,6},
{ 2,TERM1,TERM1_block,1},
{ 3,TERM2,TERM2_block,5},
{ 4,255,AIRPORT_BUSY_block,0}, {4,TERM2,0,5}, {4,HANGAR,0,1}, {4,TAKEOFF,0,6}, {4,HELITAKEOFF,0,1},
{ 5,255,AIRPORT_BUSY_block,0}, {5,TERM2,TERM2_block,3}, {5,0,0,4},
{ 6,0,AIRPORT_BUSY_block,7},
// takeoff
{ 7,TAKEOFF,AIRPORT_BUSY_block,8},
{ 8,STARTTAKEOFF,NOTHING_block,9},
{ 9,ENDTAKEOFF,NOTHING_block,0},
// landing
{10,FLYING,NOTHING_block,15}, {10,LANDING,0,11}, {10,HELILANDING,0,20},
{11,LANDING,AIRPORT_BUSY_block,12},
{12,0,AIRPORT_BUSY_block,13},
{13,ENDLANDING,AIRPORT_BUSY_block,14}, {13,TERM2,0,5}, {13,0,0,14},
{14,0,AIRPORT_BUSY_block,1},
// In air
{15,0,NOTHING_block,16},
{16,0,NOTHING_block,17},
{17,0,NOTHING_block,18},
{18,0,NOTHING_block,10},
{19,HELITAKEOFF,NOTHING_block,0},
{20,HELILANDING,AIRPORT_BUSY_block,21},
{21,HELIENDLANDING,AIRPORT_BUSY_block,1},
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
static const TileIndexDiffC _airport_depots_city[] = {{5, 0}};
static const byte _airport_terminal_city[] = {1, 3};
static const AirportFTAbuildup _airport_fta_city[] = {
{ 0,HANGAR,NOTHING_block,1}, {0,TAKEOFF,OUT_WAY_block,1}, {0,0,0,1},
{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
{ 2,TERM1,TERM1_block,7}, {2,TAKEOFF,OUT_WAY_block,7}, {2,0,0,7},
{ 3,TERM2,TERM2_block,5}, {3,TAKEOFF,OUT_WAY_block,5}, {3,0,0,5},
{ 4,TERM3,TERM3_block,5}, {4,TAKEOFF,OUT_WAY_block,5}, {4,0,0,5},
{ 5,255,TAXIWAY_BUSY_block,0}, {5,TERM2,TERM2_block,3}, {5,TERM3,TERM3_block,4}, {5,0,0,6},
{ 6,255,TAXIWAY_BUSY_block,0}, {6,TERM2,0,5}, {6,TERM3,0,5}, {6,HANGAR,0,1}, {6,0,0,7},
{ 7,255,TAXIWAY_BUSY_block,0}, {7,TERM1,TERM1_block,2}, {7,TAKEOFF,OUT_WAY_block,8}, {7,HELITAKEOFF,0,22}, {7,HANGAR,0,1}, {7,0,0,6},
{ 8,0,OUT_WAY_block,9},
{ 9,0,RUNWAY_IN_OUT_block,10},
// takeoff
{10,TAKEOFF,RUNWAY_IN_OUT_block,11},
{11,STARTTAKEOFF,NOTHING_block,12},
{12,ENDTAKEOFF,NOTHING_block,0},
// landing
{13,FLYING,NOTHING_block,18}, {13,LANDING,0,14}, {13,HELILANDING,0,23},
{14,LANDING,RUNWAY_IN_OUT_block,15},
{15,0,RUNWAY_IN_OUT_block,16},
{16,0,RUNWAY_IN_OUT_block,17},
{17,ENDLANDING,IN_WAY_block,7},
// In Air
{18,0,NOTHING_block,19},
{19,0,NOTHING_block,20},
{20,0,NOTHING_block,21},
{21,0,NOTHING_block,13},
// helicopter
{22,HELITAKEOFF,NOTHING_block,0},
{23,HELILANDING,IN_WAY_block,24},
{24,HELIENDLANDING,IN_WAY_block,17},
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
static const TileIndexDiffC _airport_depots_metropolitan[] = {{5, 0}};
static const byte _airport_terminal_metropolitan[] = {1, 3};
static const AirportFTAbuildup _airport_fta_metropolitan[] = {
{ 0,HANGAR,NOTHING_block,1},
{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
{ 2,TERM1,TERM1_block,7},
{ 3,TERM2,TERM2_block,5},
{ 4,TERM3,TERM3_block,5},
{ 5,255,TAXIWAY_BUSY_block,0}, {5,TERM2,TERM2_block,3}, {5,TERM3,TERM3_block,4}, {5,0,0,6},
{ 6,255,TAXIWAY_BUSY_block,0}, {6,TERM2,0,5}, {6,TERM3,0,5}, {6,HANGAR,0,1}, {6,0,0,7},
{ 7,255,TAXIWAY_BUSY_block,0}, {7,TERM1,TERM1_block,2}, {7,TAKEOFF,0,8}, {7,HELITAKEOFF,0,23}, {7,HANGAR,0,1}, {7,0,0,6},
{ 8,0,OUT_WAY_block,9},
{ 9,0,RUNWAY_OUT_block,10},
// takeoff
{10,TAKEOFF,RUNWAY_OUT_block,11},
{11,STARTTAKEOFF,NOTHING_block,12},
{12,ENDTAKEOFF,NOTHING_block,0},
// landing
{13,FLYING,NOTHING_block,19}, {13,LANDING,0,14}, {13,HELILANDING,0,25},
{14,LANDING,RUNWAY_IN_block,15},
{15,0,RUNWAY_IN_block,16},
{16,255,RUNWAY_IN_block,0}, {16,ENDLANDING,IN_WAY_block,17},
{17,255,RUNWAY_OUT_block,0}, {17,ENDLANDING,IN_WAY_block,18},
{18,ENDLANDING,IN_WAY_block,7},
// In Air
{19,0,NOTHING_block,20},
{20,0,NOTHING_block,21},
{21,0,NOTHING_block,22},
{22,0,NOTHING_block,13},
// helicopter
{23,0,NOTHING_block,24},
{24,HELITAKEOFF,NOTHING_block,0},
{25,HELILANDING,IN_WAY_block,26},
{26,HELIENDLANDING,IN_WAY_block,18},
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
static const TileIndexDiffC _airport_depots_international[] = {{0, 3}, {6, 1}};
static const byte _airport_terminal_international[] = {2, 3, 3};
static const byte _airport_helipad_international[] = {1, 2};
static const AirportFTAbuildup _airport_fta_international[] = {
{ 0,HANGAR,NOTHING_block,2}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER1_block,1}, {0,HELITAKEOFF,HELIPAD1_block,2}, {0,0,0,2},
{ 1,HANGAR,NOTHING_block,3}, {1,255,HANGAR2_AREA_block,1}, {1,HELITAKEOFF,HELIPAD2_block,3}, {1,0,0,3},
{ 2,255,AIRPORT_ENTRANCE_block,0}, {2,HANGAR,0,0}, {2,TERM4,0,12}, {2,TERM5,0,12}, {2,TERM6,0,12}, {2,HELIPAD1,0,12}, {2,HELIPAD2,0,12}, {2,HELITAKEOFF,0,12}, {2,0,0,23},
{ 3,255,HANGAR2_AREA_block,0}, {3,HANGAR,0,1}, {3,0,0,18},
{ 4,TERM1,TERM1_block,23}, {4,HANGAR,AIRPORT_ENTRANCE_block,23}, {4,0,0,23},
{ 5,TERM2,TERM2_block,24}, {5,HANGAR,AIRPORT_ENTRANCE_block,24}, {5,0,0,24},
{ 6,TERM3,TERM3_block,25}, {6,HANGAR,AIRPORT_ENTRANCE_block,25}, {6,0,0,25},
{ 7,TERM4,TERM4_block,16}, {7,HANGAR,HANGAR2_AREA_block,16}, {7,0,0,16},
{ 8,TERM5,TERM5_block,17}, {8,HANGAR,HANGAR2_AREA_block,17}, {8,0,0,17},
{ 9,TERM6,TERM6_block,18}, {9,HANGAR,HANGAR2_AREA_block,18}, {9,0,0,18},
{10,HELIPAD1,HELIPAD1_block,10}, {10,HANGAR,HANGAR2_AREA_block,16}, {10,HELITAKEOFF,0,47},
{11,HELIPAD2,HELIPAD2_block,11}, {11,HANGAR,HANGAR2_AREA_block,17}, {11,HELITAKEOFF,0,48},
{12,0,TERM_GROUP2_ENTER1_block,13},
{13,0,TERM_GROUP2_ENTER1_block,14},
{14,0,TERM_GROUP2_ENTER2_block,15},
{15,0,TERM_GROUP2_ENTER2_block,16},
{16,255,TERM_GROUP2_block,0}, {16,TERM4,TERM4_block,7}, {16,HELIPAD1,HELIPAD1_block,10}, {16,HELITAKEOFF,HELIPAD1_block,10}, {16,0,0,17},
{17,255,TERM_GROUP2_block,0}, {17,TERM5,TERM5_block,8}, {17,TERM4,0,16}, {17,HELIPAD1,0,16}, {17,HELIPAD2,HELIPAD2_block,11}, {17,HELITAKEOFF,HELIPAD2_block,11}, {17,0,0,18},
{18,255,TERM_GROUP2_block,0}, {18,TERM6,TERM6_block,9}, {18,TAKEOFF,0,19}, {18,HANGAR,HANGAR2_AREA_block,3}, {18,0,0,17},
{19,0,TERM_GROUP2_EXIT1_block,20},
{20,0,TERM_GROUP2_EXIT1_block,21},
{21,0,TERM_GROUP2_EXIT2_block,22},
{22,0,TERM_GROUP2_EXIT2_block,26},
{23,255,TERM_GROUP1_block,0}, {23,TERM1,TERM1_block,4}, {23,HANGAR,AIRPORT_ENTRANCE_block,2}, {23,0,0,24},
{24,255,TERM_GROUP1_block,0}, {24,TERM2,TERM2_block,5}, {24,TERM1,0,23}, {24,HANGAR,0,23}, {24,0,0,25},
{25,255,TERM_GROUP1_block,0}, {25,TERM3,TERM3_block,6}, {25,TAKEOFF,0,26}, {25,0,0,24},
{26,255,TAXIWAY_BUSY_block,0}, {26,TAKEOFF,0,27}, {26,0,0,25},
{27,0,OUT_WAY_block,28},
// takeoff
{28,TAKEOFF,OUT_WAY_block,29},
{29,0,RUNWAY_OUT_block,30},
{30,STARTTAKEOFF,NOTHING_block,31},
{31,ENDTAKEOFF,NOTHING_block,0},
// landing
{32,FLYING,NOTHING_block,37}, {32,LANDING,0,33}, {32,HELILANDING,0,41},
{33,LANDING,RUNWAY_IN_block,34},
{34,0,RUNWAY_IN_block,35},
{35,0,RUNWAY_IN_block,36},
{36,ENDLANDING,IN_WAY_block,36}, {36,255,TERM_GROUP1_block,0}, {36,255,TERM_GROUP2_ENTER1_block,1}, {36,TERM4,0,12}, {36,TERM5,0,12}, {36,TERM6,0,12}, {36,0,0,2},
// In Air
{37,0,NOTHING_block,38},
{38,0,NOTHING_block,39},
{39,0,NOTHING_block,40},
{40,0,NOTHING_block,32},
// Helicopter -- stay in air in special place as a buffer to choose from helipads
{41,HELILANDING,PRE_HELIPAD_block,42},
{42,HELIENDLANDING,PRE_HELIPAD_block,42}, {42,HELIPAD1,0,43}, {42,HELIPAD2,0,44}, {42,HANGAR,0,49},
{43,0,NOTHING_block,45},
{44,0,NOTHING_block,46},
// landing
{45,255,NOTHING_block,0}, {45,HELIPAD1,HELIPAD1_block,10},
{46,255,NOTHING_block,0}, {46,HELIPAD2,HELIPAD2_block,11},
// Helicopter -- takeoff
{47,HELITAKEOFF,NOTHING_block,0},
{48,HELITAKEOFF,NOTHING_block,0},
{49,0,HANGAR2_AREA_block,50}, // need to go to hangar when waiting in air
{50,0,HANGAR2_AREA_block,3},
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
// heliports, oilrigs don't have depots
static const byte _airport_helipad_heliport_oilrig[] = {1, 1};
static const AirportFTAbuildup _airport_fta_heliport_oilrig[] = {
{0,HELIPAD1,HELIPAD1_block,1},
{1,HELITAKEOFF,NOTHING_block,0}, // takeoff
{2,255,AIRPORT_BUSY_block,0}, {2,HELILANDING,0,3}, {2,HELITAKEOFF,0,1},
{3,HELILANDING,AIRPORT_BUSY_block,4},
{4,HELIENDLANDING,AIRPORT_BUSY_block,4}, {4,HELIPAD1,HELIPAD1_block,0}, {4,HELITAKEOFF,0,2},
// In Air
{5,0,NOTHING_block,6},
{6,0,NOTHING_block,7},
{7,0,NOTHING_block,8},
{8,FLYING,NOTHING_block,5}, {8,HELILANDING,HELIPAD1_block,2}, // landing
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
static const AirportMovingData * const _airport_moving_datas[] = {
_airport_moving_data_country, // Country Airfield (small) 4x3
_airport_moving_data_town, // City Airport (large) 6x6
_airport_moving_data_heliport, // Heliport
_airport_moving_data_metropolitan, // Metropolitain Airport (large) - 2 runways
_airport_moving_data_international, // International Airport (xlarge) - 2 runways
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_airport_moving_data_oilrig // Oilrig
};
#endif /* AIRPORT_MOVEMENT_H */

280
aystar.c Normal file
View File

@@ -0,0 +1,280 @@
/* $Id$ */
/*
* This file has the core function for AyStar
* AyStar is a fast pathfinding routine and is used for things like
* AI_pathfinding and Train_pathfinding.
* For more information about AyStar (A* Algorithm), you can look at
* http://en.wikipedia.org/wiki/A-star_search_algorithm
*/
/*
* Friendly reminder:
* Call (AyStar).free() when you are done with Aystar. It reserves a lot of memory
* And when not free'd, it can cause system-crashes.
* Also remember that when you stop an algorithm before it is finished, your
* should call clear() yourself!
*/
#include "stdafx.h"
#include "openttd.h"
#include "aystar.h"
// This looks in the Hash if a node exists in ClosedList
// If so, it returns the PathNode, else NULL
static PathNode *AyStarMain_ClosedList_IsInList(AyStar *aystar, AyStarNode *node)
{
return (PathNode*)Hash_Get(&aystar->ClosedListHash, node->tile, node->direction);
}
// This adds a node to the ClosedList
// It makes a copy of the data
static void AyStarMain_ClosedList_Add(AyStar *aystar, PathNode *node)
{
// Add a node to the ClosedList
PathNode *new_node = malloc(sizeof(PathNode));
*new_node = *node;
Hash_Set(&aystar->ClosedListHash, node->node.tile, node->node.direction, new_node);
}
// Checks if a node is in the OpenList
// If so, it returns the OpenListNode, else NULL
static OpenListNode *AyStarMain_OpenList_IsInList(AyStar *aystar, AyStarNode *node)
{
return (OpenListNode*)Hash_Get(&aystar->OpenListHash, node->tile, node->direction);
}
// Gets the best node from OpenList
// returns the best node, or NULL of none is found
// Also it deletes the node from the OpenList
static OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar)
{
// Return the item the Queue returns.. the best next OpenList item.
OpenListNode* res = (OpenListNode*)aystar->OpenListQueue.pop(&aystar->OpenListQueue);
if (res != NULL)
Hash_Delete(&aystar->OpenListHash, res->path.node.tile, res->path.node.direction);
return res;
}
// Adds a node to the OpenList
// It makes a copy of node, and puts the pointer of parent in the struct
static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, AyStarNode *node, int f, int g)
{
// Add a new Node to the OpenList
OpenListNode* new_node = malloc(sizeof(OpenListNode));
new_node->g = g;
new_node->path.parent = parent;
new_node->path.node = *node;
Hash_Set(&aystar->OpenListHash, node->tile, node->direction, new_node);
// Add it to the queue
aystar->OpenListQueue.push(&aystar->OpenListQueue, new_node, f);
}
/*
* Checks one tile and calculate his f-value
* return values:
* AYSTAR_DONE : indicates we are done
*/
int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent) {
int new_f, new_g, new_h;
PathNode *closedlist_parent;
OpenListNode *check;
// Check the new node against the ClosedList
if (AyStarMain_ClosedList_IsInList(aystar, current) != NULL) return AYSTAR_DONE;
// Calculate the G-value for this node
new_g = aystar->CalculateG(aystar, current, parent);
// If the value was INVALID_NODE, we don't do anything with this node
if (new_g == AYSTAR_INVALID_NODE) return AYSTAR_DONE;
// There should not be given any other error-code..
assert(new_g >= 0);
// Add the parent g-value to the new g-value
new_g += parent->g;
if (aystar->max_path_cost != 0 && (uint)new_g > aystar->max_path_cost) return AYSTAR_DONE;
// Calculate the h-value
new_h = aystar->CalculateH(aystar, current, parent);
// There should not be given any error-code..
assert(new_h >= 0);
// The f-value if g + h
new_f = new_g + new_h;
// Get the pointer to the parent in the ClosedList (the currentone is to a copy of the one in the OpenList)
closedlist_parent = AyStarMain_ClosedList_IsInList(aystar, &parent->path.node);
// Check if this item is already in the OpenList
if ((check = AyStarMain_OpenList_IsInList(aystar, current)) != NULL) {
uint i;
// Yes, check if this g value is lower..
if (new_g > check->g) return AYSTAR_DONE;
aystar->OpenListQueue.del(&aystar->OpenListQueue, check, 0);
// It is lower, so change it to this item
check->g = new_g;
check->path.parent = closedlist_parent;
/* Copy user data, will probably have changed */
for (i=0;i<lengthof(current->user_data);i++)
check->path.node.user_data[i] = current->user_data[i];
// Readd him in the OpenListQueue
aystar->OpenListQueue.push(&aystar->OpenListQueue, check, new_f);
} else {
// A new node, add him to the OpenList
AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g);
}
return AYSTAR_DONE;
}
/*
* This function is the core of AyStar. It handles one item and checks
* his neighbour items. If they are valid, they are added to be checked too.
* return values:
* AYSTAR_EMPTY_OPENLIST : indicates all items are tested, and no path
* has been found.
* AYSTAR_LIMIT_REACHED : Indicates that the max_nodes limit has been
* reached.
* AYSTAR_FOUND_END_NODE : indicates we found the end. Path_found now is true, and in path is the path found.
* AYSTAR_STILL_BUSY : indicates we have done this tile, did not found the path yet, and have items left to try.
*/
int AyStarMain_Loop(AyStar *aystar) {
int i, r;
// Get the best node from OpenList
OpenListNode *current = AyStarMain_OpenList_Pop(aystar);
// If empty, drop an error
if (current == NULL) return AYSTAR_EMPTY_OPENLIST;
// Check for end node and if found, return that code
if (aystar->EndNodeCheck(aystar, current) == AYSTAR_FOUND_END_NODE) {
if (aystar->FoundEndNode != NULL)
aystar->FoundEndNode(aystar, current);
free(current);
return AYSTAR_FOUND_END_NODE;
}
// Add the node to the ClosedList
AyStarMain_ClosedList_Add(aystar, &current->path);
// Load the neighbours
aystar->GetNeighbours(aystar, current);
// Go through all neighbours
for (i=0;i<aystar->num_neighbours;i++) {
// Check and add them to the OpenList if needed
r = aystar->checktile(aystar, &aystar->neighbours[i], current);
}
// Free the node
free(current);
if (aystar->max_search_nodes != 0 && Hash_Size(&aystar->ClosedListHash) >= aystar->max_search_nodes)
/* We've expanded enough nodes */
return AYSTAR_LIMIT_REACHED;
else
// Return that we are still busy
return AYSTAR_STILL_BUSY;
}
/*
* This function frees the memory it allocated
*/
void AyStarMain_Free(AyStar *aystar) {
aystar->OpenListQueue.free(&aystar->OpenListQueue, false);
/* 2nd argument above is false, below is true, to free the values only
* once */
delete_Hash(&aystar->OpenListHash, true);
delete_Hash(&aystar->ClosedListHash, true);
#ifdef AYSTAR_DEBUG
printf("[AyStar] Memory free'd\n");
#endif
}
/*
* This function make the memory go back to zero
* This function should be called when you are using the same instance again.
*/
void AyStarMain_Clear(AyStar *aystar) {
// Clean the Queue, but not the elements within. That will be done by
// the hash.
aystar->OpenListQueue.clear(&aystar->OpenListQueue, false);
// Clean the hashes
clear_Hash(&aystar->OpenListHash, true);
clear_Hash(&aystar->ClosedListHash, true);
#ifdef AYSTAR_DEBUG
printf("[AyStar] Cleared AyStar\n");
#endif
}
/*
* This is the function you call to run AyStar.
* return values:
* AYSTAR_FOUND_END_NODE : indicates we found an end node.
* AYSTAR_NO_PATH : indicates that there was no path found.
* AYSTAR_STILL_BUSY : indicates we have done some checked, that we did not found the path yet, and that we still have items left to try.
* When the algorithm is done (when the return value is not AYSTAR_STILL_BUSY)
* aystar->clear() is called. Note that when you stop the algorithm halfway,
* you should still call clear() yourself!
*/
int AyStarMain_Main(AyStar *aystar) {
int r, i = 0;
// Loop through the OpenList
// Quit if result is no AYSTAR_STILL_BUSY or is more than loops_per_tick
while ((r = aystar->loop(aystar)) == AYSTAR_STILL_BUSY && (aystar->loops_per_tick == 0 || ++i < aystar->loops_per_tick)) { }
#ifdef AYSTAR_DEBUG
if (r == AYSTAR_FOUND_END_NODE)
printf("[AyStar] Found path!\n");
else if (r == AYSTAR_EMPTY_OPENLIST)
printf("[AyStar] OpenList run dry, no path found\n");
else if (r == AYSTAR_LIMIT_REACHED)
printf("[AyStar] Exceeded search_nodes, no path found\n");
#endif
if (r != AYSTAR_STILL_BUSY)
/* We're done, clean up */
aystar->clear(aystar);
// Check result-value
if (r == AYSTAR_FOUND_END_NODE) return AYSTAR_FOUND_END_NODE;
// Check if we have some left in the OpenList
if (r == AYSTAR_EMPTY_OPENLIST || r == AYSTAR_LIMIT_REACHED) return AYSTAR_NO_PATH;
// Return we are still busy
return AYSTAR_STILL_BUSY;
}
/*
* Adds a node from where to start an algorithm. Multiple nodes can be added
* if wanted. You should make sure that clear() is called before adding nodes
* if the AyStar has been used before (though the normal main loop calls
* clear() automatically when the algorithm finishes
* g is the cost for starting with this node.
*/
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g) {
#ifdef AYSTAR_DEBUG
printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n",
TileX(start_node->tile), TileY(start_node->tile), start_node->direction);
#endif
AyStarMain_OpenList_Add(aystar, NULL, start_node, 0, g);
}
void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets) {
// Allocated the Hash for the OpenList and ClosedList
init_Hash(&aystar->OpenListHash, hash, num_buckets);
init_Hash(&aystar->ClosedListHash, hash, num_buckets);
// Set up our sorting queue
// BinaryHeap allocates a block of 1024 nodes
// When thatone gets full it reserves an otherone, till this number
// That is why it can stay this high
init_BinaryHeap(&aystar->OpenListQueue, 102400);
aystar->addstart = AyStarMain_AddStartNode;
aystar->main = AyStarMain_Main;
aystar->loop = AyStarMain_Loop;
aystar->free = AyStarMain_Free;
aystar->clear = AyStarMain_Clear;
aystar->checktile = AyStarMain_CheckTile;
}

179
aystar.h Normal file
View File

@@ -0,0 +1,179 @@
/* $Id$ */
/*
* This file has the header for AyStar
* AyStar is a fast pathfinding routine and is used for things like
* AI_pathfinding and Train_pathfinding.
* For more information about AyStar (A* Algorithm), you can look at
* http://en.wikipedia.org/wiki/A-star_search_algorithm
*/
#ifndef AYSTAR_H
#define AYSTAR_H
#include "queue.h"
//#define AYSTAR_DEBUG
enum {
AYSTAR_FOUND_END_NODE,
AYSTAR_EMPTY_OPENLIST,
AYSTAR_STILL_BUSY,
AYSTAR_NO_PATH,
AYSTAR_LIMIT_REACHED,
AYSTAR_DONE
};
enum{
AYSTAR_INVALID_NODE = -1,
};
typedef struct AyStarNode AyStarNode;
struct AyStarNode {
TileIndex tile;
uint direction;
uint user_data[2];
};
// The resulting path has nodes looking like this.
typedef struct PathNode PathNode;
struct PathNode {
AyStarNode node;
// The parent of this item
PathNode *parent;
};
// For internal use only
// We do not save the h-value, because it is only needed to calculate the f-value.
// h-value should _always_ be the distance left to the end-tile.
typedef struct OpenListNode OpenListNode;
struct OpenListNode {
int g;
PathNode path;
};
typedef struct AyStar AyStar;
/*
* This function is called to check if the end-tile is found
* return values can be:
* AYSTAR_FOUND_END_NODE : indicates this is the end tile
* AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)
*/
/*
* The 2nd parameter should be OpenListNode, and NOT AyStarNode. AyStarNode is
* part of OpenListNode and so it could be accessed without any problems.
* The good part about OpenListNode is, and how AIs use it, that you can
* access the parent of the current node, and so check if you, for example
* don't try to enter the file tile with a 90-degree curve. So please, leave
* this an OpenListNode, it works just fine -- TrueLight
*/
typedef int32 AyStar_EndNodeCheck(AyStar *aystar, OpenListNode *current);
/*
* This function is called to calculate the G-value for AyStar Algorithm.
* return values can be:
* AYSTAR_INVALID_NODE : indicates an item is not valid (e.g.: unwalkable)
* Any value >= 0 : the g-value for this tile
*/
typedef int32 AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
/*
* This function is called to calculate the H-value for AyStar Algorithm.
* Mostly, this must result the distance (Manhattan way) between the
* current point and the end point
* return values can be:
* Any value >= 0 : the h-value for this tile
*/
typedef int32 AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
/*
* This function request the tiles around the current tile and put them in tiles_around
* tiles_around is never resetted, so if you are not using directions, just leave it alone.
* Warning: never add more tiles_around than memory allocated for it.
*/
typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current);
/*
* If the End Node is found, this function is called.
* It can do, for example, calculate the route and put that in an array
*/
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
// For internal use, see aystar.c
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode* start_node, uint g);
typedef int AyStar_Main(AyStar *aystar);
typedef int AyStar_Loop(AyStar *aystar);
typedef int AyStar_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
typedef void AyStar_Free(AyStar *aystar);
typedef void AyStar_Clear(AyStar *aystar);
struct AyStar {
/* These fields should be filled before initting the AyStar, but not changed
* afterwards (except for user_data and user_path)! (free and init again to change them) */
/* These should point to the application specific routines that do the
* actual work */
AyStar_CalculateG* CalculateG;
AyStar_CalculateH* CalculateH;
AyStar_GetNeighbours* GetNeighbours;
AyStar_EndNodeCheck* EndNodeCheck;
AyStar_FoundEndNode* FoundEndNode;
/* These are completely untouched by AyStar, they can be accesed by
* the application specific routines to input and output data.
* user_path should typically contain data about the resulting path
* afterwards, user_target should typically contain information about
* what where looking for, and user_data can contain just about
* everything */
void *user_path;
void *user_target;
uint user_data[10];
/* How many loops are there called before AyStarMain_Main gives
* control back to the caller. 0 = until done */
byte loops_per_tick;
/* If the g-value goes over this number, it stops searching
* 0 = infinite */
uint max_path_cost;
/* The maximum amount of nodes that will be expanded, 0 = infinite */
uint max_search_nodes;
/* These should be filled with the neighbours of a tile by
* GetNeighbours */
AyStarNode neighbours[12];
byte num_neighbours;
/* These will contain the methods for manipulating the AyStar. Only
* main() should be called externally */
AyStar_AddStartNode* addstart;
AyStar_Main* main;
AyStar_Loop* loop;
AyStar_Free* free;
AyStar_Clear* clear;
AyStar_CheckTile* checktile;
/* These will contain the open and closed lists */
/* The actual closed list */
Hash ClosedListHash;
/* The open queue */
Queue OpenListQueue;
/* An extra hash to speed up the process of looking up an element in
* the open list */
Hash OpenListHash;
};
void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
int AyStarMain_Main(AyStar *aystar);
int AyStarMain_Loop(AyStar *aystar);
int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
void AyStarMain_Free(AyStar *aystar);
void AyStarMain_Clear(AyStar *aystar);
/* Initialize an AyStar. You should fill all appropriate fields before
* callling init_AyStar (see the declaration of AyStar for which fields are
* internal */
void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets);
#endif /* AYSTAR_H */

View File

@@ -1,2 +0,0 @@
add_subdirectory(ai)
add_subdirectory(game)

View File

@@ -1,40 +0,0 @@
set(AI_COMPAT_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/compat_0.7.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.0.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.1.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.2.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.3.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.4.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.5.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.6.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.7.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.8.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.9.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.10.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.11.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_12.nut
)
foreach(AI_COMPAT_SOURCE_FILE IN LISTS AI_COMPAT_SOURCE_FILES)
string(REPLACE "${CMAKE_SOURCE_DIR}/bin/" "" AI_COMPAT_SOURCE_FILE_NAME "${AI_COMPAT_SOURCE_FILE}")
string(CONCAT AI_COMPAT_BINARY_FILE "${CMAKE_BINARY_DIR}/" "${AI_COMPAT_SOURCE_FILE_NAME}")
add_custom_command(OUTPUT ${AI_COMPAT_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E copy
${AI_COMPAT_SOURCE_FILE}
${AI_COMPAT_BINARY_FILE}
MAIN_DEPENDENCY ${AI_COMPAT_SOURCE_FILE}
COMMENT "Copying ${AI_COMPAT_SOURCE_FILE_NAME}"
)
list(APPEND AI_COMPAT_BINARY_FILES ${AI_COMPAT_BINARY_FILE})
endforeach()
# Create a new target which copies all compat files
add_custom_target(ai_compat_files
DEPENDS ${AI_COMPAT_BINARY_FILES}
)
add_dependencies(openttd
ai_compat_files
)

View File

@@ -1,394 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("0.7 API compatibility in effect:");
AILog.Info(" - AITown::GetLastMonthProduction's behaviour has slightly changed.");
AILog.Info(" - AISubsidy::GetDestination returns STATION_INVALID for awarded subsidies.");
AILog.Info(" - AISubsidy::GetSource returns STATION_INVALID for awarded subsidies.");
AISign.GetMaxSignID <- function()
{
local list = AISignList();
local max_id = 0;
foreach (id, d in list) {
if (id > max_id) max_id = id;
}
return max_id;
}
AITile.GetHeight <- function(tile)
{
if (!AIMap.IsValidTile(tile)) return -1;
return AITile.GetCornerHeight(tile, AITile.CORNER_N);
}
AIOrder.ChangeOrder <- function(vehicle_id, order_position, order_flags)
{
return AIOrder.SetOrderFlags(vehicle_id, order_position, order_flags);
}
AIWaypoint.WAYPOINT_INVALID <- 0xFFFF;
AISubsidy.SourceIsTown <- function(subsidy_id)
{
if (!AISubsidy.IsValidSubsidy(subsidy_id) || AISubsidy.IsAwarded(subsidy_id)) return false;
return AISubsidy.GetSourceType(subsidy_id) == AISubsidy.SPT_TOWN;
}
AISubsidy.GetSource <- function(subsidy_id)
{
if (!AISubsidy.IsValidSubsidy(subsidy_id)) return AIBaseStation.STATION_INVALID;
if (AISubsidy.IsAwarded(subsidy_id)) {
return AIBaseStation.STATION_INVALID;
}
return AISubsidy.GetSourceIndex(subsidy_id);
}
AISubsidy.DestinationIsTown <- function(subsidy_id)
{
if (!AISubsidy.IsValidSubsidy(subsidy_id) || AISubsidy.IsAwarded(subsidy_id)) return false;
return AISubsidy.GetDestinationType(subsidy_id) == AISubsidy.SPT_TOWN;
}
AISubsidy.GetDestination <- function(subsidy_id)
{
if (!AISubsidy.IsValidSubsidy(subsidy_id)) return AIBaseStation.STATION_INVALID;
if (AISubsidy.IsAwarded(subsidy_id)) {
return AIBaseStation.STATION_INVALID;
}
return AISubsidy.GetDestinationIndex(subsidy_id);
}
AITown.GetMaxProduction <- function(town_id, cargo_id)
{
return AITown.GetLastMonthProduction(town_id, cargo_id);
}
AIRail.RemoveRailWaypoint <- function(tile)
{
return AIRail.RemoveRailWaypointTileRect(tile, tile, true);
}
AIRail.RemoveRailStationTileRect <- function(tile, tile2)
{
return AIRail.RemoveRailStationTileRectangle(tile, tile2, false);
}
AIVehicle.SkipToVehicleOrder <- function(vehicle_id, order_position)
{
return AIOrder.SkipToOrder(vehicle_id, order_position);
}
AIEngine.IsValidEngine <- function(engine_id)
{
return AIEngine.IsBuildable(engine_id);
}
AIEngine._GetName <- AIEngine.GetName;
AIEngine.GetName <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return null;
return AIEngine._GetName(engine_id);
}
AIEngine._GetCargoType <- AIEngine.GetCargoType;
AIEngine.GetCargoType <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return 255;
return AIEngine._GetCargoType(engine_id);
}
AIEngine._CanRefitCargo <- AIEngine.CanRefitCargo;
AIEngine.CanRefitCargo <- function(engine_id, cargo_id)
{
if (!AIEngine.IsBuildable(engine_id)) return false;
return AIEngine._CanRefitCargo(engine_id, cargo_id);
}
AIEngine._CanPullCargo <- AIEngine.CanPullCargo;
AIEngine.CanPullCargo <- function(engine_id, cargo_id)
{
if (!AIEngine.IsBuildable(engine_id)) return false;
return AIEngine._CanPullCargo(engine_id, cargo_id);
}
AIEngine._GetCapacity <- AIEngine.GetCapacity;
AIEngine.GetCapacity <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetCapacity(engine_id);
}
AIEngine._GetReliability <- AIEngine.GetReliability;
AIEngine.GetReliability <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetReliability(engine_id);
}
AIEngine._GetMaxSpeed <- AIEngine.GetMaxSpeed;
AIEngine.GetMaxSpeed <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetMaxSpeed(engine_id);
}
AIEngine._GetPrice <- AIEngine.GetPrice;
AIEngine.GetPrice <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetPrice(engine_id);
}
AIEngine._GetMaxAge <- AIEngine.GetMaxAge;
AIEngine.GetMaxAge <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetMaxAge(engine_id);
}
AIEngine._GetRunningCost <- AIEngine.GetRunningCost;
AIEngine.GetRunningCost <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetRunningCost(engine_id);
}
AIEngine._GetPower <- AIEngine.GetPower;
AIEngine.GetPower <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetPower(engine_id);
}
AIEngine._GetWeight <- AIEngine.GetWeight;
AIEngine.GetWeight <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetWeight(engine_id);
}
AIEngine._GetMaxTractiveEffort <- AIEngine.GetMaxTractiveEffort;
AIEngine.GetMaxTractiveEffort <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetMaxTractiveEffort(engine_id);
}
AIEngine._GetDesignDate <- AIEngine.GetDesignDate;
AIEngine.GetDesignDate <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetDesignDate(engine_id);
}
AIEngine._GetVehicleType <- AIEngine.GetVehicleType;
AIEngine.GetVehicleType <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return AIVehicle.VT_INVALID;
return AIEngine._GetVehicleType(engine_id);
}
AIEngine._IsWagon <- AIEngine.IsWagon;
AIEngine.IsWagon <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return false;
return AIEngine._IsWagon(engine_id);
}
AIEngine._CanRunOnRail <- AIEngine.CanRunOnRail;
AIEngine.CanRunOnRail <- function(engine_id, track_rail_type)
{
if (!AIEngine.IsBuildable(engine_id)) return false;
return AIEngine._CanRunOnRail(engine_id, track_rail_type);
}
AIEngine._HasPowerOnRail <- AIEngine.HasPowerOnRail;
AIEngine.HasPowerOnRail <- function(engine_id, track_rail_type)
{
if (!AIEngine.IsBuildable(engine_id)) return false;
return AIEngine._HasPowerOnRail(engine_id, track_rail_type);
}
AIEngine._GetRoadType <- AIEngine.GetRoadType;
AIEngine.GetRoadType <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return AIRoad.ROADTYPE_INVALID;
return AIEngine._GetRoadType(engine_id);
}
AIEngine._GetRailType <- AIEngine.GetRailType;
AIEngine.GetRailType <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return AIRail.RAILTYPE_INVALID;
return AIEngine._GetRailType(engine_id);
}
AIEngine._IsArticulated <- AIEngine.IsArticulated;
AIEngine.IsArticulated <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return false;
return AIEngine._IsArticulated(engine_id);
}
AIEngine._GetPlaneType <- AIEngine.GetPlaneType;
AIEngine.GetPlaneType <- function(engine_id)
{
if (!AIEngine.IsBuildable(engine_id)) return -1;
return AIEngine._GetPlaneType(engine_id);
}
_AIWaypointList <- AIWaypointList;
class AIWaypointList extends _AIWaypointList {
constructor()
{
::_AIWaypointList.constructor(AIWaypoint.WAYPOINT_RAIL);
}
}
AIRoad._BuildRoadStation <- AIRoad.BuildRoadStation;
AIRoad.BuildRoadStation <- function(tile, front, road_veh_type, station_id)
{
if (AIRoad.IsRoadStationTile(tile) && AICompany.IsMine(AITile.GetOwner(tile))) return false;
return AIRoad._BuildRoadStation(tile, front, road_veh_type, station_id);
}
AIRoad._BuildDriveThroughRoadStation <- AIRoad.BuildDriveThroughRoadStation;
AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, station_id)
{
if (AIRoad.IsRoadStationTile(tile) && AICompany.IsMine(AITile.GetOwner(tile))) return false;
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
}
AIBridgeList.HasNext <-
AIBridgeList_Length.HasNext <-
AICargoList.HasNext <-
AICargoList_IndustryAccepting.HasNext <-
AICargoList_IndustryProducing.HasNext <-
AIDepotList.HasNext <-
AIEngineList.HasNext <-
AIGroupList.HasNext <-
AIIndustryList.HasNext <-
AIIndustryList_CargoAccepting.HasNext <-
AIIndustryList_CargoProducing.HasNext <-
AIIndustryTypeList.HasNext <-
AIList.HasNext <-
AIRailTypeList.HasNext <-
AISignList.HasNext <-
AIStationList.HasNext <-
AIStationList_Vehicle.HasNext <-
AISubsidyList.HasNext <-
AITileList.HasNext <-
AITileList_IndustryAccepting.HasNext <-
AITileList_IndustryProducing.HasNext <-
AITileList_StationType.HasNext <-
AITownList.HasNext <-
AIVehicleList.HasNext <-
AIVehicleList_DefaultGroup.HasNext <-
AIVehicleList_Group.HasNext <-
AIVehicleList_SharedOrders.HasNext <-
AIVehicleList_Station.HasNext <-
AIWaypointList.HasNext <-
AIWaypointList_Vehicle.HasNext <-
function()
{
return !this.IsEnd();
}
AIIndustry._IsCargoAccepted <- AIIndustry.IsCargoAccepted;
AIIndustry.IsCargoAccepted <- function(industry_id, cargo_id)
{
return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
}
AIAbstractList <- AIList;
AIList.ChangeItem <- AIList.SetValue;
AIRail.ERR_NONUNIFORM_STATIONS_DISABLED <- 0xFFFF;
AICompany.GetCompanyValue <- function(company)
{
return AICompany.GetQuarterlyCompanyValue(company, AICompany.CURRENT_QUARTER);
}
AITown.GetLastMonthTransported <- AITown.GetLastMonthSupplied;
AIEvent.AI_ET_INVALID <- AIEvent.ET_INVALID;
AIEvent.AI_ET_TEST <- AIEvent.ET_TEST;
AIEvent.AI_ET_SUBSIDY_OFFER <- AIEvent.ET_SUBSIDY_OFFER;
AIEvent.AI_ET_SUBSIDY_OFFER_EXPIRED <- AIEvent.ET_SUBSIDY_OFFER_EXPIRED;
AIEvent.AI_ET_SUBSIDY_AWARDED <- AIEvent.ET_SUBSIDY_AWARDED;
AIEvent.AI_ET_SUBSIDY_EXPIRED <- AIEvent.ET_SUBSIDY_EXPIRED;
AIEvent.AI_ET_ENGINE_PREVIEW <- AIEvent.ET_ENGINE_PREVIEW;
AIEvent.AI_ET_COMPANY_NEW <- AIEvent.ET_COMPANY_NEW;
AIEvent.AI_ET_COMPANY_IN_TROUBLE <- AIEvent.ET_COMPANY_IN_TROUBLE;
AIEvent.AI_ET_COMPANY_MERGER <- AIEvent.ET_COMPANY_MERGER;
AIEvent.AI_ET_COMPANY_BANKRUPT <- AIEvent.ET_COMPANY_BANKRUPT;
AIEvent.AI_ET_VEHICLE_CRASHED <- AIEvent.ET_VEHICLE_CRASHED;
AIEvent.AI_ET_VEHICLE_LOST <- AIEvent.ET_VEHICLE_LOST;
AIEvent.AI_ET_VEHICLE_WAITING_IN_DEPOT <- AIEvent.ET_VEHICLE_WAITING_IN_DEPOT;
AIEvent.AI_ET_VEHICLE_UNPROFITABLE <- AIEvent.ET_VEHICLE_UNPROFITABLE;
AIEvent.AI_ET_INDUSTRY_OPEN <- AIEvent.ET_INDUSTRY_OPEN;
AIEvent.AI_ET_INDUSTRY_CLOSE <- AIEvent.ET_INDUSTRY_CLOSE;
AIEvent.AI_ET_ENGINE_AVAILABLE <- AIEvent.ET_ENGINE_AVAILABLE;
AIEvent.AI_ET_STATION_FIRST_VEHICLE <- AIEvent.ET_STATION_FIRST_VEHICLE;
AIEvent.AI_ET_DISASTER_ZEPPELINER_CRASHED <- AIEvent.ET_DISASTER_ZEPPELINER_CRASHED;
AIEvent.AI_ET_DISASTER_ZEPPELINER_CLEARED <- AIEvent.ET_DISASTER_ZEPPELINER_CLEARED;
AIOrder.AIOF_NONE <- AIOrder.OF_NONE
AIOrder.AIOF_NON_STOP_INTERMEDIATE <- AIOrder.OF_NON_STOP_INTERMEDIATE
AIOrder.AIOF_NON_STOP_DESTINATION <- AIOrder.OF_NON_STOP_DESTINATION
AIOrder.AIOF_UNLOAD <- AIOrder.OF_UNLOAD
AIOrder.AIOF_TRANSFER <- AIOrder.OF_TRANSFER
AIOrder.AIOF_NO_UNLOAD <- AIOrder.OF_NO_UNLOAD
AIOrder.AIOF_FULL_LOAD <- AIOrder.OF_FULL_LOAD
AIOrder.AIOF_FULL_LOAD_ANY <- AIOrder.OF_FULL_LOAD_ANY
AIOrder.AIOF_NO_LOAD <- AIOrder.OF_NO_LOAD
AIOrder.AIOF_SERVICE_IF_NEEDED <- AIOrder.OF_SERVICE_IF_NEEDED
AIOrder.AIOF_STOP_IN_DEPOT <- AIOrder.OF_STOP_IN_DEPOT
AIOrder.AIOF_GOTO_NEAREST_DEPOT <- AIOrder.OF_GOTO_NEAREST_DEPOT
AIOrder.AIOF_NON_STOP_FLAGS <- AIOrder.OF_NON_STOP_FLAGS
AIOrder.AIOF_UNLOAD_FLAGS <- AIOrder.OF_UNLOAD_FLAGS
AIOrder.AIOF_LOAD_FLAGS <- AIOrder.OF_LOAD_FLAGS
AIOrder.AIOF_DEPOT_FLAGS <- AIOrder.OF_DEPOT_FLAGS
AIOrder.AIOF_INVALID <- AIOrder.OF_INVALID
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,146 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.0 API compatibility in effect.");
AIRoad._BuildRoadStation <- AIRoad.BuildRoadStation;
AIRoad.BuildRoadStation <- function(tile, front, road_veh_type, station_id)
{
if (AIRoad.IsRoadStationTile(tile) && AICompany.IsMine(AITile.GetOwner(tile))) return false;
return AIRoad._BuildRoadStation(tile, front, road_veh_type, station_id);
}
AIRoad._BuildDriveThroughRoadStation <- AIRoad.BuildDriveThroughRoadStation;
AIRoad.BuildDriveThroughRoadStation <- function(tile, front, road_veh_type, station_id)
{
if (AIRoad.IsRoadStationTile(tile) && AICompany.IsMine(AITile.GetOwner(tile))) return false;
return AIRoad._BuildDriveThroughRoadStation(tile, front, road_veh_type, station_id);
}
AIBridgeList.HasNext <-
AIBridgeList_Length.HasNext <-
AICargoList.HasNext <-
AICargoList_IndustryAccepting.HasNext <-
AICargoList_IndustryProducing.HasNext <-
AIDepotList.HasNext <-
AIEngineList.HasNext <-
AIGroupList.HasNext <-
AIIndustryList.HasNext <-
AIIndustryList_CargoAccepting.HasNext <-
AIIndustryList_CargoProducing.HasNext <-
AIIndustryTypeList.HasNext <-
AIList.HasNext <-
AIRailTypeList.HasNext <-
AISignList.HasNext <-
AIStationList.HasNext <-
AIStationList_Vehicle.HasNext <-
AISubsidyList.HasNext <-
AITileList.HasNext <-
AITileList_IndustryAccepting.HasNext <-
AITileList_IndustryProducing.HasNext <-
AITileList_StationType.HasNext <-
AITownList.HasNext <-
AIVehicleList.HasNext <-
AIVehicleList_DefaultGroup.HasNext <-
AIVehicleList_Depot.HasNext <-
AIVehicleList_Group.HasNext <-
AIVehicleList_SharedOrders.HasNext <-
AIVehicleList_Station.HasNext <-
AIWaypointList.HasNext <-
AIWaypointList_Vehicle.HasNext <-
function()
{
return !this.IsEnd();
}
AIIndustry._IsCargoAccepted <- AIIndustry.IsCargoAccepted;
AIIndustry.IsCargoAccepted <- function(industry_id, cargo_id)
{
return AIIndustry._IsCargoAccepted(industry_id, cargo_id) != AIIndustry.CAS_NOT_ACCEPTED;
}
AIAbstractList <- AIList;
AIList.ChangeItem <- AIList.SetValue;
AIRail.ERR_NONUNIFORM_STATIONS_DISABLED <- 0xFFFF;
AICompany.GetCompanyValue <- function(company)
{
return AICompany.GetQuarterlyCompanyValue(company, AICompany.CURRENT_QUARTER);
}
AITown.GetLastMonthTransported <- AITown.GetLastMonthSupplied;
AIEvent.AI_ET_INVALID <- AIEvent.ET_INVALID;
AIEvent.AI_ET_TEST <- AIEvent.ET_TEST;
AIEvent.AI_ET_SUBSIDY_OFFER <- AIEvent.ET_SUBSIDY_OFFER;
AIEvent.AI_ET_SUBSIDY_OFFER_EXPIRED <- AIEvent.ET_SUBSIDY_OFFER_EXPIRED;
AIEvent.AI_ET_SUBSIDY_AWARDED <- AIEvent.ET_SUBSIDY_AWARDED;
AIEvent.AI_ET_SUBSIDY_EXPIRED <- AIEvent.ET_SUBSIDY_EXPIRED;
AIEvent.AI_ET_ENGINE_PREVIEW <- AIEvent.ET_ENGINE_PREVIEW;
AIEvent.AI_ET_COMPANY_NEW <- AIEvent.ET_COMPANY_NEW;
AIEvent.AI_ET_COMPANY_IN_TROUBLE <- AIEvent.ET_COMPANY_IN_TROUBLE;
AIEvent.AI_ET_COMPANY_ASK_MERGER <- AIEvent.ET_COMPANY_ASK_MERGER;
AIEvent.AI_ET_COMPANY_MERGER <- AIEvent.ET_COMPANY_MERGER;
AIEvent.AI_ET_COMPANY_BANKRUPT <- AIEvent.ET_COMPANY_BANKRUPT;
AIEvent.AI_ET_VEHICLE_CRASHED <- AIEvent.ET_VEHICLE_CRASHED;
AIEvent.AI_ET_VEHICLE_LOST <- AIEvent.ET_VEHICLE_LOST;
AIEvent.AI_ET_VEHICLE_WAITING_IN_DEPOT <- AIEvent.ET_VEHICLE_WAITING_IN_DEPOT;
AIEvent.AI_ET_VEHICLE_UNPROFITABLE <- AIEvent.ET_VEHICLE_UNPROFITABLE;
AIEvent.AI_ET_INDUSTRY_OPEN <- AIEvent.ET_INDUSTRY_OPEN;
AIEvent.AI_ET_INDUSTRY_CLOSE <- AIEvent.ET_INDUSTRY_CLOSE;
AIEvent.AI_ET_ENGINE_AVAILABLE <- AIEvent.ET_ENGINE_AVAILABLE;
AIEvent.AI_ET_STATION_FIRST_VEHICLE <- AIEvent.ET_STATION_FIRST_VEHICLE;
AIEvent.AI_ET_DISASTER_ZEPPELINER_CRASHED <- AIEvent.ET_DISASTER_ZEPPELINER_CRASHED;
AIEvent.AI_ET_DISASTER_ZEPPELINER_CLEARED <- AIEvent.ET_DISASTER_ZEPPELINER_CLEARED;
AIOrder.AIOF_NONE <- AIOrder.OF_NONE
AIOrder.AIOF_NON_STOP_INTERMEDIATE <- AIOrder.OF_NON_STOP_INTERMEDIATE
AIOrder.AIOF_NON_STOP_DESTINATION <- AIOrder.OF_NON_STOP_DESTINATION
AIOrder.AIOF_UNLOAD <- AIOrder.OF_UNLOAD
AIOrder.AIOF_TRANSFER <- AIOrder.OF_TRANSFER
AIOrder.AIOF_NO_UNLOAD <- AIOrder.OF_NO_UNLOAD
AIOrder.AIOF_FULL_LOAD <- AIOrder.OF_FULL_LOAD
AIOrder.AIOF_FULL_LOAD_ANY <- AIOrder.OF_FULL_LOAD_ANY
AIOrder.AIOF_NO_LOAD <- AIOrder.OF_NO_LOAD
AIOrder.AIOF_SERVICE_IF_NEEDED <- AIOrder.OF_SERVICE_IF_NEEDED
AIOrder.AIOF_STOP_IN_DEPOT <- AIOrder.OF_STOP_IN_DEPOT
AIOrder.AIOF_GOTO_NEAREST_DEPOT <- AIOrder.OF_GOTO_NEAREST_DEPOT
AIOrder.AIOF_NON_STOP_FLAGS <- AIOrder.OF_NON_STOP_FLAGS
AIOrder.AIOF_UNLOAD_FLAGS <- AIOrder.OF_UNLOAD_FLAGS
AIOrder.AIOF_LOAD_FLAGS <- AIOrder.OF_LOAD_FLAGS
AIOrder.AIOF_DEPOT_FLAGS <- AIOrder.OF_DEPOT_FLAGS
AIOrder.AIOF_INVALID <- AIOrder.OF_INVALID
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,83 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.1 API compatibility in effect.");
AICompany.GetCompanyValue <- function(company)
{
return AICompany.GetQuarterlyCompanyValue(company, AICompany.CURRENT_QUARTER);
}
AITown.GetLastMonthTransported <- AITown.GetLastMonthSupplied;
AIEvent.AI_ET_INVALID <- AIEvent.ET_INVALID;
AIEvent.AI_ET_TEST <- AIEvent.ET_TEST;
AIEvent.AI_ET_SUBSIDY_OFFER <- AIEvent.ET_SUBSIDY_OFFER;
AIEvent.AI_ET_SUBSIDY_OFFER_EXPIRED <- AIEvent.ET_SUBSIDY_OFFER_EXPIRED;
AIEvent.AI_ET_SUBSIDY_AWARDED <- AIEvent.ET_SUBSIDY_AWARDED;
AIEvent.AI_ET_SUBSIDY_EXPIRED <- AIEvent.ET_SUBSIDY_EXPIRED;
AIEvent.AI_ET_ENGINE_PREVIEW <- AIEvent.ET_ENGINE_PREVIEW;
AIEvent.AI_ET_COMPANY_NEW <- AIEvent.ET_COMPANY_NEW;
AIEvent.AI_ET_COMPANY_IN_TROUBLE <- AIEvent.ET_COMPANY_IN_TROUBLE;
AIEvent.AI_ET_COMPANY_ASK_MERGER <- AIEvent.ET_COMPANY_ASK_MERGER;
AIEvent.AI_ET_COMPANY_MERGER <- AIEvent.ET_COMPANY_MERGER;
AIEvent.AI_ET_COMPANY_BANKRUPT <- AIEvent.ET_COMPANY_BANKRUPT;
AIEvent.AI_ET_VEHICLE_CRASHED <- AIEvent.ET_VEHICLE_CRASHED;
AIEvent.AI_ET_VEHICLE_LOST <- AIEvent.ET_VEHICLE_LOST;
AIEvent.AI_ET_VEHICLE_WAITING_IN_DEPOT <- AIEvent.ET_VEHICLE_WAITING_IN_DEPOT;
AIEvent.AI_ET_VEHICLE_UNPROFITABLE <- AIEvent.ET_VEHICLE_UNPROFITABLE;
AIEvent.AI_ET_INDUSTRY_OPEN <- AIEvent.ET_INDUSTRY_OPEN;
AIEvent.AI_ET_INDUSTRY_CLOSE <- AIEvent.ET_INDUSTRY_CLOSE;
AIEvent.AI_ET_ENGINE_AVAILABLE <- AIEvent.ET_ENGINE_AVAILABLE;
AIEvent.AI_ET_STATION_FIRST_VEHICLE <- AIEvent.ET_STATION_FIRST_VEHICLE;
AIEvent.AI_ET_DISASTER_ZEPPELINER_CRASHED <- AIEvent.ET_DISASTER_ZEPPELINER_CRASHED;
AIEvent.AI_ET_DISASTER_ZEPPELINER_CLEARED <- AIEvent.ET_DISASTER_ZEPPELINER_CLEARED;
AIEvent.AI_ET_TOWN_FOUNDED <- AIEvent.ET_TOWN_FOUNDED;
AIOrder.AIOF_NONE <- AIOrder.OF_NONE
AIOrder.AIOF_NON_STOP_INTERMEDIATE <- AIOrder.OF_NON_STOP_INTERMEDIATE
AIOrder.AIOF_NON_STOP_DESTINATION <- AIOrder.OF_NON_STOP_DESTINATION
AIOrder.AIOF_UNLOAD <- AIOrder.OF_UNLOAD
AIOrder.AIOF_TRANSFER <- AIOrder.OF_TRANSFER
AIOrder.AIOF_NO_UNLOAD <- AIOrder.OF_NO_UNLOAD
AIOrder.AIOF_FULL_LOAD <- AIOrder.OF_FULL_LOAD
AIOrder.AIOF_FULL_LOAD_ANY <- AIOrder.OF_FULL_LOAD_ANY
AIOrder.AIOF_NO_LOAD <- AIOrder.OF_NO_LOAD
AIOrder.AIOF_SERVICE_IF_NEEDED <- AIOrder.OF_SERVICE_IF_NEEDED
AIOrder.AIOF_STOP_IN_DEPOT <- AIOrder.OF_STOP_IN_DEPOT
AIOrder.AIOF_GOTO_NEAREST_DEPOT <- AIOrder.OF_GOTO_NEAREST_DEPOT
AIOrder.AIOF_NON_STOP_FLAGS <- AIOrder.OF_NON_STOP_FLAGS
AIOrder.AIOF_UNLOAD_FLAGS <- AIOrder.OF_UNLOAD_FLAGS
AIOrder.AIOF_LOAD_FLAGS <- AIOrder.OF_LOAD_FLAGS
AIOrder.AIOF_DEPOT_FLAGS <- AIOrder.OF_DEPOT_FLAGS
AIOrder.AIOF_INVALID <- AIOrder.OF_INVALID
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,21 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.10 API compatibility in effect.");
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,21 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.11 API compatibility in effect.");
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.2 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.3 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.4 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.5 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.6 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.7 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.8 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
AIBridge._GetName <- AIBridge.GetName;
AIBridge.GetName <- function(bridge_id)
{
return AIBridge._GetName(bridge_id, AIVehicle.VT_RAIL);
}
/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,21 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("1.9 API compatibility in effect.");
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,21 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
AILog.Info("12 API compatibility in effect.");
/* 13 really checks RoadType against RoadType */
AIRoad._HasRoadType <- AIRoad.HasRoadType;
AIRoad.HasRoadType <- function(tile, road_type)
{
local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (AIRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,6 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@@ -1,37 +0,0 @@
set(GS_COMPAT_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.2.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.3.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.4.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.5.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.6.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.7.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.8.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.9.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.10.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.11.nut
${CMAKE_CURRENT_SOURCE_DIR}/compat_12.nut
)
foreach(GS_COMPAT_SOURCE_FILE IN LISTS GS_COMPAT_SOURCE_FILES)
string(REPLACE "${CMAKE_SOURCE_DIR}/bin/" "" GS_COMPAT_SOURCE_FILE_NAME "${GS_COMPAT_SOURCE_FILE}")
string(CONCAT GS_COMPAT_BINARY_FILE "${CMAKE_BINARY_DIR}/" "${GS_COMPAT_SOURCE_FILE_NAME}")
add_custom_command(OUTPUT ${GS_COMPAT_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E copy
${GS_COMPAT_SOURCE_FILE}
${GS_COMPAT_BINARY_FILE}
MAIN_DEPENDENCY ${GS_COMPAT_SOURCE_FILE}
COMMENT "Copying ${GS_COMPAT_SOURCE_FILE_NAME}"
)
list(APPEND GS_COMPAT_BINARY_FILES ${GS_COMPAT_BINARY_FILE})
endforeach()
# Create a new target which copies all compat files
add_custom_target(gs_compat_files
DEPENDS ${GS_COMPAT_BINARY_FILES}
)
add_dependencies(openttd
gs_compat_files
)

View File

@@ -1,28 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.10 API compatibility in effect.");
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,21 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.11 API compatibility in effect.");
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,50 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.2 API compatibility in effect.");
GSTown._SetGrowthRate <- GSTown.SetGrowthRate;
GSTown.SetGrowthRate <- function(town_id, days_between_town_growth)
{
/* Growth rate 0 caused resetting the custom growth rate. While this was undocumented, it was used nevertheless (ofc). */
if (days_between_town_growth == 0) days_between_town_growth = GSTown.TOWN_GROWTH_NORMAL;
return GSTown._SetGrowthRate(town_id, days_between_town_growth);
}
/* 1.5 adds a game element reference to the news. */
GSNews._Create <- GSNews.Create;
GSNews.Create <- function(type, text, company)
{
return GSNews._Create(type, text, company, GSNews.NR_NONE, 0);
}
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,50 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.3 API compatibility in effect.");
GSTown._SetGrowthRate <- GSTown.SetGrowthRate;
GSTown.SetGrowthRate <- function(town_id, days_between_town_growth)
{
/* Growth rate 0 caused resetting the custom growth rate. While this was undocumented, it was used nevertheless (ofc). */
if (days_between_town_growth == 0) days_between_town_growth = GSTown.TOWN_GROWTH_NORMAL;
return GSTown._SetGrowthRate(town_id, days_between_town_growth);
}
/* 1.5 adds a game element reference to the news. */
GSNews._Create <- GSNews.Create;
GSNews.Create <- function(type, text, company)
{
return GSNews._Create(type, text, company, GSNews.NR_NONE, 0);
}
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,42 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.4 API compatibility in effect.");
/* 1.5 adds a game element reference to the news. */
GSNews._Create <- GSNews.Create;
GSNews.Create <- function(type, text, company)
{
return GSNews._Create(type, text, company, GSNews.NR_NONE, 0);
}
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.5 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.6 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.7 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.8 API compatibility in effect.");
/* 1.9 adds a vehicle type parameter. */
GSBridge._GetName <- GSBridge.GetName;
GSBridge.GetName <- function(bridge_id)
{
return GSBridge._GetName(bridge_id, GSVehicle.VT_RAIL);
}
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,28 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("1.9 API compatibility in effect.");
/* 1.11 adds a tile parameter. */
GSCompany._ChangeBankBalance <- GSCompany.ChangeBankBalance;
GSCompany.ChangeBankBalance <- function(company, delta, expenses_type)
{
return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID);
}
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,21 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
GSLog.Info("12 API compatibility in effect.");
/* 13 really checks RoadType against RoadType */
GSRoad._HasRoadType <- GSRoad.HasRoadType;
GSRoad.HasRoadType <- function(tile, road_type)
{
local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type));
foreach (rt, _ in list) {
if (GSRoad._HasRoadType(tile, rt)) {
return true;
}
}
return false;
}

View File

@@ -1,6 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@@ -1,2 +0,0 @@
start_ai MyAI

View File

@@ -1,2 +0,0 @@
# Show a MOTD
say "Welcome..."

25
bridge.h Normal file
View File

@@ -0,0 +1,25 @@
/* $Id$ */
/** @file bridge.h Header file for bridges */
#ifndef BRIDGE_H
#define BRIDGE_H
/** Struct containing information about a single bridge type
*/
typedef struct Bridge {
byte avail_year; ///< the year in which the bridge becomes available
byte min_length; ///< the minimum length of the bridge (not counting start and end tile)
byte max_length; ///< the maximum length of the bridge (not counting start and end tile)
uint16 price; ///< the relative price of the bridge
uint16 speed; ///< maximum travel speed
PalSpriteID sprite; ///< the sprite which is used in the GUI (possibly with a recolor sprite)
StringID material; ///< the string that contains the bridge description
PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
byte flags; ///< bit 0 set: disable drawing of far pillars.
} Bridge;
extern const Bridge orig_bridge[MAX_BRIDGES];
extern Bridge _bridge[MAX_BRIDGES];
#endif /* BRIDGE_H */

167
bridge_gui.c Normal file
View File

@@ -0,0 +1,167 @@
/* $Id$ */
/** @file bridge_gui.c Graphical user interface for bridge construction*/
#include "stdafx.h"
#include "openttd.h"
#include "table/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 "variables.h"
#include "bridge.h"
static struct BridgeData {
uint count;
TileIndex start_tile;
TileIndex end_tile;
byte type;
byte indexes[MAX_BRIDGES];
int32 costs[MAX_BRIDGES];
} _bridgedata;
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
}
static void BuildBridge(Window *w, int i)
{
DeleteWindow(w);
DoCommandP(_bridgedata.end_tile, _bridgedata.start_tile,
_bridgedata.indexes[i] | (_bridgedata.type << 8), CcBuildBridge,
CMD_BUILD_BRIDGE | CMD_AUTO | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
}
static void BuildBridgeWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
uint i;
DrawWindowWidgets(w);
for (i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) {
const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]];
SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
SetDParam(1, (b->speed >> 4) * 10);
SetDParam(0, b->material);
DrawSprite(b->sprite, 3, 15 + i * 22);
DrawString(44, 15 + i * 22 , STR_500D, 0);
}
} break;
case WE_KEYPRESS: {
uint i = e->keypress.keycode - '1';
if (i < 9 && i < _bridgedata.count) {
e->keypress.cont = false;
BuildBridge(w, i);
}
break;
}
case WE_CLICK:
if (e->click.widget == 2) {
uint ind = ((int)e->click.pt.y - 14) / 22;
if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count)
BuildBridge(w, ind);
}
break;
}
}
static const Widget _build_bridge_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WIDGETS_END},
};
static const WindowDesc _build_bridge_desc = {
-1, -1, 200, 102,
WC_BUILD_BRIDGE,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_bridge_widgets,
BuildBridgeWndProc
};
static const Widget _build_road_bridge_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WIDGETS_END},
};
static const WindowDesc _build_road_bridge_desc = {
-1, -1, 200, 102,
WC_BUILD_BRIDGE,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_road_bridge_widgets,
BuildBridgeWndProc
};
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
{
uint j = 0;
int32 ret;
StringID errmsg;
DeleteWindowById(WC_BUILD_BRIDGE, 0);
_bridgedata.type = bridge_type;
_bridgedata.start_tile = start;
_bridgedata.end_tile = end;
errmsg = INVALID_STRING_ID;
// only query bridge building possibility once, result is the same for all bridges!
// returns CMD_ERROR on failure, and price on success
ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
if (CmdFailed(ret)) {
errmsg = _error_message;
} else {
// check which bridges can be built
int bridge_len; // length of the middle parts of the bridge
int tot_bridgedata_len; // total length of bridge
// get absolute bridge length
bridge_len = GetBridgeLength(start, end);
tot_bridgedata_len = bridge_len + 2;
tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
const Bridge *b = &_bridge[bridge_type];
// bridge is accepted, add to list
// add to terraforming & bulldozing costs the cost of the bridge itself (not computed with DC_QUERY_COST)
_bridgedata.costs[j] = ret + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
_bridgedata.indexes[j] = bridge_type;
j++;
}
}
}
_bridgedata.count = j;
if (j != 0) {
Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
w->vscroll.cap = 4;
w->vscroll.count = (byte)j;
} else {
ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * 16, TileY(end) * 16);
}
}

64
bridge_map.h Normal file
View File

@@ -0,0 +1,64 @@
/* $Id$ */
#ifndef BRIDGE_MAP_H
#define BRIDGE_MAP_H
#include "direction.h"
#include "macros.h"
#include "map.h"
#include "rail.h"
#include "tile.h"
static inline bool IsBridge(TileIndex t)
{
assert(IsTileType(t, MP_TUNNELBRIDGE));
return HASBIT(_m[t].m5, 7);
}
static inline bool IsBridgeTile(TileIndex t)
{
return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
}
static inline bool IsBridgeRamp(TileIndex t)
{
assert(IsBridgeTile(t));
return !HASBIT(_m[t].m5, 6);
}
static inline bool IsBridgeMiddle(TileIndex t)
{
assert(IsBridgeTile(t));
return HASBIT(_m[t].m5, 6);
}
/**
* Get the direction pointing onto the bridge
*/
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
{
assert(IsBridgeRamp(t));
/* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
* bridges to a DiagDirection
*/
return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);
}
static inline Axis GetBridgeAxis(TileIndex t)
{
assert(IsBridgeMiddle(t));
return (Axis)GB(_m[t].m5, 0, 1);
}
static inline bool IsTransportUnderBridge(TileIndex t)
{
assert(IsBridgeMiddle(t));
return HASBIT(_m[t].m5, 5);
}
#endif

87
callback_table.c Normal file
View File

@@ -0,0 +1,87 @@
/* $Id$ */
#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!
// If you don't do it, it won't work across the network!!
/* aircraft_gui.c */
CommandCallback CcBuildAircraft;
CommandCallback CcCloneAircraft;
/* airport_gui.c */
CommandCallback CcBuildAirport;
/* bridge_gui.c */
CommandCallback CcBuildBridge;
/* dock_gui.c */
CommandCallback CcBuildDocks;
CommandCallback CcBuildCanal;
/* main_gui.c */
CommandCallback CcPlaySound10;
CommandCallback CcPlaceSign;
CommandCallback CcTerraform;
CommandCallback CcBuildTown;
/* rail_gui.c */
CommandCallback CcPlaySound1E;
CommandCallback CcRailDepot;
CommandCallback CcStation;
CommandCallback CcBuildRailTunnel;
/* road_gui.c */
CommandCallback CcPlaySound1D;
CommandCallback CcBuildRoadTunnel;
CommandCallback CcRoadDepot;
/* roadveh_gui.c */
CommandCallback CcBuildRoadVeh;
CommandCallback CcCloneRoadVeh;
/* ship_gui.c */
CommandCallback CcBuildShip;
CommandCallback CcCloneShip;
/* train_gui.c */
CommandCallback CcBuildWagon;
CommandCallback CcBuildLoco;
CommandCallback CcCloneTrain;
CommandCallback CcAI;
CommandCallback *_callback_table[] = {
/* 0x00 */ NULL,
/* 0x01 */ CcBuildAircraft,
/* 0x02 */ CcBuildAirport,
/* 0x03 */ CcBuildBridge,
/* 0x04 */ CcBuildCanal,
/* 0x05 */ CcBuildDocks,
/* 0x06 */ CcBuildLoco,
/* 0x07 */ CcBuildRoadVeh,
/* 0x08 */ CcBuildShip,
/* 0x09 */ CcBuildTown,
/* 0x0A */ CcBuildRoadTunnel,
/* 0x0B */ CcBuildRailTunnel,
/* 0x0C */ CcBuildWagon,
/* 0x0D */ CcRoadDepot,
/* 0x0E */ CcRailDepot,
/* 0x0F */ CcPlaceSign,
/* 0x10 */ CcPlaySound10,
/* 0x11 */ CcPlaySound1D,
/* 0x12 */ CcPlaySound1E,
/* 0x13 */ CcStation,
/* 0x14 */ CcTerraform,
/* 0x15 */ CcCloneAircraft,
/* 0x16 */ CcCloneRoadVeh,
/* 0x17 */ CcCloneShip,
/* 0x18 */ CcCloneTrain,
/* 0x19 */ CcAI
};
const int _callback_table_count = lengthof(_callback_table);

11
callback_table.h Normal file
View File

@@ -0,0 +1,11 @@
/* $Id$ */
#ifndef CALLBACK_TABLE_H
#define CALLBACK_TABLE_H
#include "functions.h"
extern CommandCallback *_callback_table[];
extern const int _callback_table_count;
#endif /* CALLBACK_TABLE_H */

File diff suppressed because it is too large Load Diff

864
clear_cmd.c Normal file
View File

@@ -0,0 +1,864 @@
/* $Id$ */
#include "stdafx.h"
#include "openttd.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 "variables.h"
#include "table/sprites.h"
typedef struct TerraformerHeightMod {
TileIndex tile;
byte height;
} TerraformerHeightMod;
typedef struct TerraformerState {
int height[4];
uint32 flags;
int direction;
int modheight_count;
int tile_table_count;
int32 cost;
TileIndex *tile_table;
TerraformerHeightMod *modheight;
} TerraformerState;
static int TerraformAllowTileProcess(TerraformerState *ts, TileIndex tile)
{
TileIndex *t;
int count;
if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return -1;
t = ts->tile_table;
for (count = ts->tile_table_count; count != 0; count--, t++) {
if (*t == tile) return 0;
}
return 1;
}
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;
}
return TileHeight(tile);
}
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
{
int count;
TileIndex *t;
count = ts->tile_table_count;
if (count >= 625) return;
for(t = ts->tile_table; count != 0; count--,t++) {
if (*t == tile) return;
}
ts->tile_table[ts->tile_table_count++] = tile;
}
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);
}
static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
{
int r;
int32 ret;
assert(tile < MapSize());
r = TerraformAllowTileProcess(ts, tile);
if (r <= 0) return r;
if (IsTileType(tile, MP_RAILWAY)) {
static const TrackBits safe_track[] = { TRACK_BIT_LOWER, TRACK_BIT_LEFT, TRACK_BIT_UPPER, TRACK_BIT_RIGHT };
static const Slope unsafe_slope[] = { SLOPE_S, SLOPE_W, SLOPE_N, SLOPE_E };
Slope tileh;
uint z;
// Nothing could be built at the steep slope - this avoids a bug
// when you have a single diagonal track in one corner on a
// basement and then you raise/lower the other corner.
tileh = GetTileSlope(tile, &z);
if (tileh == unsafe_slope[mode] ||
tileh == ComplementSlope(unsafe_slope[mode])) {
_terraform_err_tile = tile;
_error_message = STR_1008_MUST_REMOVE_RAILROAD_TRACK;
return -1;
}
// If we have a single diagonal track there, the other side of
// tile can be terraformed.
if (IsPlainRailTile(tile) && GetTrackBits(tile) == safe_track[mode]) {
/* If terraforming downwards prevent damaging a potential tunnel below.
* This check is only necessary for flat tiles, because if the tile is
* non-flat, then the corner opposing the rail is raised. Only this corner
* can be lowered and this is a safe action
*/
if (tileh == SLOPE_FLAT &&
ts->direction == -1 &&
IsTunnelInWay(tile, z - TILE_HEIGHT)) {
_terraform_err_tile = tile;
_error_message = STR_1002_EXCAVATION_WOULD_DAMAGE;
return -1;
}
return 0;
}
}
ret = DoCommandByTile(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (ret == CMD_ERROR) {
_terraform_err_tile = tile;
return -1;
}
ts->cost += ret;
if (ts->tile_table_count >= 625) return -1;
ts->tile_table[ts->tile_table_count++] = tile;
return 0;
}
static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
{
int nh;
TerraformerHeightMod *mod;
int count;
assert(tile < MapSize());
if (height < 0) {
_error_message = STR_1003_ALREADY_AT_SEA_LEVEL;
return false;
}
_error_message = STR_1004_TOO_HIGH;
if (height > 15) return false;
nh = TerraformGetHeightOfTile(ts, tile);
if (nh < 0 || height == nh) return false;
if (TerraformProc(ts, tile, 0) < 0) return false;
if (TerraformProc(ts, tile + TileDiffXY( 0, -1), 1) < 0) return false;
if (TerraformProc(ts, tile + TileDiffXY(-1, -1), 2) < 0) return false;
if (TerraformProc(ts, tile + TileDiffXY(-1, 0), 3) < 0) return false;
mod = ts->modheight;
count = ts->modheight_count;
for (;;) {
if (count == 0) {
if (ts->modheight_count >= 576)
return false;
ts->modheight_count++;
break;
}
if (mod->tile == tile) break;
mod++;
count--;
}
mod->tile = tile;
mod->height = (byte)height;
ts->cost += _price.terraform;
{
int direction = ts->direction, r;
const TileIndexDiffC *ttm;
static const TileIndexDiffC _terraform_tilepos[] = {
{ 1, 0},
{-2, 0},
{ 1, 1},
{ 0, -2}
};
for(ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
tile += ToTileIndexDiff(*ttm);
r = TerraformGetHeightOfTile(ts, tile);
if (r != height && r-direction != height && r+direction != height) {
if (!TerraformTileHeight(ts, tile, r+direction))
return false;
}
}
}
return true;
}
/** Terraform land
* @param x,y coordinates to terraform
* @param p1 corners to terraform.
* @param p2 direction; eg up or down
*/
int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
TerraformerState ts;
TileIndex tile;
int direction;
TerraformerHeightMod modheight_data[576];
TileIndex tile_table_data[625];
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
_terraform_err_tile = 0;
ts.direction = direction = p2 ? 1 : -1;
ts.flags = flags;
ts.modheight_count = ts.tile_table_count = 0;
ts.cost = 0;
ts.modheight = modheight_data;
ts.tile_table = tile_table_data;
tile = TileVirtXY(x, y);
/* Make an extra check for map-bounds cause we add tiles to the originating tile */
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
if (p1 & 1) {
if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 0),
TileHeight(tile + TileDiffXY(1, 0)) + direction))
return CMD_ERROR;
}
if (p1 & 2) {
if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 1),
TileHeight(tile + TileDiffXY(1, 1)) + direction))
return CMD_ERROR;
}
if (p1 & 4) {
if (!TerraformTileHeight(&ts, tile + TileDiffXY(0, 1),
TileHeight(tile + TileDiffXY(0, 1)) + direction))
return CMD_ERROR;
}
if (p1 & 8) {
if (!TerraformTileHeight(&ts, tile + TileDiffXY(0, 0),
TileHeight(tile + TileDiffXY(0, 0)) + direction))
return CMD_ERROR;
}
if (direction == -1) {
/* Check if tunnel would take damage */
int count;
TileIndex *ti = ts.tile_table;
for (count = ts.tile_table_count; count != 0; count--, ti++) {
uint z, t;
TileIndex tile = *ti;
z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
if (t <= z) z = t;
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
if (t <= z) z = t;
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
if (t <= z) z = t;
if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
}
}
}
if (flags & DC_EXEC) {
/* Clear the landscape at the tiles */
{
int count;
TileIndex *ti = ts.tile_table;
for (count = ts.tile_table_count; count != 0; count--, ti++) {
DoCommandByTile(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
}
/* 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);
TerraformAddDirtyTileAround(&ts, til);
}
}
/* 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 ts.cost;
}
/** Levels a selected (rectangle) area of land
* @param x,y end tile of area-drag
* @param p1 start tile of area drag
* @param p2 unused
*/
int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
{
int size_x, size_y;
int sx, sy;
uint h, curh;
TileIndex tile;
int32 ret, cost, money;
if (p1 >= MapSize()) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
// remember level height
h = TileHeight(p1);
ex >>= 4; ey >>= 4;
// make sure sx,sy are smaller than ex,ey
sx = TileX(p1);
sy = TileY(p1);
if (ex < sx) intswap(ex, sx);
if (ey < sy) intswap(ey, sy);
tile = TileXY(sx, sy);
size_x = ex-sx+1;
size_y = ey-sy+1;
money = GetAvailableMoneyForCommand();
cost = 0;
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
curh = TileHeight(tile2);
while (curh != h) {
ret = DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
if (CmdFailed(ret)) break;
cost += ret;
if (flags & DC_EXEC) {
if ((money -= ret) < 0) {
_additional_cash_required = ret;
return cost - ret;
}
DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
}
curh += (curh > h) ? -1 : 1;
}
} END_TILE_LOOP(tile2, size_x, size_y, tile)
return (cost == 0) ? CMD_ERROR : cost;
}
/** Purchase a land area. Actually you only purchase one tile, so
* the name is a bit confusing ;p
* @param x,y the tile the player is purchasing
* @param p1 unused
* @param p2 unused
*/
int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
TileIndex tile;
int32 cost;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
tile = TileVirtXY(x, y);
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
if (IsTileType(tile, MP_UNMOVABLE) && _m[tile].m5 == 3 &&
IsTileOwner(tile, _current_player))
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
if (flags & DC_EXEC) {
ModifyTile(tile,
MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5,
3 /* map5 */
);
}
return cost + _price.purchase_land * 10;
}
static int32 ClearTile_Clear(TileIndex tile, byte flags)
{
static const int32 null = 0;
static const int32* clear_price_table[] = {
&null,
&_price.clear_1,
&_price.clear_1,
&_price.clear_1,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.clear_2,
&_price.clear_2,
&_price.clear_2,
&_price.clear_2,
&_price.clear_3,
&_price.clear_3,
&_price.clear_3,
&_price.clear_3,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.purchase_land,
&_price.clear_2,
&_price.clear_2,
&_price.clear_2,
&_price.clear_2,
};
const int32 *price = clear_price_table[GB(_m[tile].m5, 0, 5)];
if (flags & DC_EXEC) DoClearSquare(tile);
return *price;
}
/** Sell a land area. Actually you only sell one tile, so
* the name is a bit confusing ;p
* @param x,y the tile the player is selling
* @param p1 unused
* @param p2 unused
*/
int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
TileIndex tile;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
tile = TileVirtXY(x, y);
if (!IsTileType(tile, MP_UNMOVABLE) || _m[tile].m5 != 3) return CMD_ERROR;
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
if (flags & DC_EXEC)
DoClearSquare(tile);
return - _price.purchase_land * 2;
}
#include "table/clear_land.h"
void DrawClearLandTile(const TileInfo *ti, byte set)
{
DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19);
}
void DrawHillyLandTile(const TileInfo *ti)
{
if (ti->tileh != 0) {
DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh]);
} else {
DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)]);
}
}
void DrawClearLandFence(const TileInfo *ti)
{
byte m4 = _m[ti->tile].m4;
byte z = ti->z;
if (ti->tileh & 2) {
z += 8;
if (ti->tileh == 0x17) z += 8;
}
if (GB(m4, 5, 3) != 0) {
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GB(m4, 5, 3) - 1] + _fence_mod_by_tileh[ti->tileh], ti->x, ti->y, z);
}
if (GB(m4, 2, 3) != 0) {
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GB(m4, 2, 3) - 1] + _fence_mod_by_tileh_2[ti->tileh], ti->x, ti->y, z);
}
}
static void DrawTile_Clear(TileInfo *ti)
{
switch (GB(ti->map5, 2, 3)) {
case 0:
DrawClearLandTile(ti, GB(ti->map5, 0, 2));
break;
case 1:
DrawHillyLandTile(ti);
break;
case 2:
DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh]);
break;
case 3:
DrawGroundSprite(_clear_land_sprites_1[GB(_m[ti->tile].m3, 0, 4)] + _tileh_to_sprite[ti->tileh]);
break;
case 4:
DrawGroundSprite(_clear_land_sprites_2[GB(ti->map5, 0, 2)] + _tileh_to_sprite[ti->tileh]);
break;
case 5:
DrawGroundSprite(_clear_land_sprites_3[GB(ti->map5, 0, 2)] + _tileh_to_sprite[ti->tileh]);
break;
}
DrawClearLandFence(ti);
}
static uint GetSlopeZ_Clear(const TileInfo* ti)
{
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
}
static uint GetSlopeTileh_Clear(const TileInfo *ti)
{
return ti->tileh;
}
static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
{
/* unused */
}
static void AnimateTile_Clear(TileIndex tile)
{
/* unused */
}
void TileLoopClearHelper(TileIndex tile)
{
byte self;
byte neighbour;
TileIndex dirty = INVALID_TILE;
switch (GetTileType(tile)) {
case MP_CLEAR:
self = (GB(_m[tile].m5, 0, 5) == 15);
break;
default:
self = 0;
break;
}
switch (GetTileType(TILE_ADDXY(tile, 1, 0))) {
case MP_CLEAR:
neighbour = (GB(_m[TILE_ADDXY(tile, 1, 0)].m5, 0, 5) == 15);
break;
default:
neighbour = 0;
break;
}
if (GB(_m[tile].m4, 5, 3) == 0) {
if (self != neighbour) {
SB(_m[tile].m4, 5, 3, 3);
dirty = tile;
}
} else {
if (self == 0 && neighbour == 0) {
SB(_m[tile].m4, 5, 3, 0);
dirty = tile;
}
}
switch (GetTileType(TILE_ADDXY(tile, 0, 1))) {
case MP_CLEAR:
neighbour = (GB(_m[TILE_ADDXY(tile, 0, 1)].m5, 0, 5) == 15);
break;
default:
neighbour = 0;
break;
}
if (GB(_m[tile].m4, 2, 3) == 0) {
if (self != neighbour) {
SB(_m[tile].m4, 2, 3, 3);
dirty = tile;
}
} else {
if (self == 0 && neighbour == 0) {
SB(_m[tile].m4, 2, 3, 0);
dirty = tile;
}
}
if (dirty != INVALID_TILE) MarkTileDirtyByTile(dirty);
}
/* convert into snowy tiles */
static void TileLoopClearAlps(TileIndex tile)
{
int k;
byte m5,tmp;
/* distance from snow line, in steps of 8 */
k = GetTileZ(tile) - _opt.snow_line;
m5 = _m[tile].m5 & 0x1C;
tmp = _m[tile].m5 & 3;
if (k < -8) {
/* snow_m2_down */
if (m5 != 0x10)
return;
if (tmp == 0)
m5 = 3;
} else if (k == -8) {
/* snow_m1 */
if (m5 != 0x10) {
m5 = 0x10;
} else if (tmp != 0) {
m5 = (tmp - 1) + 0x10;
} else
return;
} else if (k < 8) {
/* snow_0 */
if (m5 != 0x10) {
m5 = 0x10;
} else if (tmp != 1) {
m5 = 1;
if (tmp != 0)
m5 = tmp - 1;
m5 += 0x10;
} else
return;
} else if (k == 8) {
/* snow_p1 */
if (m5 != 0x10) {
m5 = 0x10;
} else if (tmp != 2) {
m5 = 2;
if (tmp <= 2)
m5 = tmp + 1;
m5 += 0x10;
} else
return;
} else {
/* snow_p2_up */
if (m5 != 0x10) {
m5 = 0x10;
} else if (tmp != 3) {
m5 = tmp + 1 + 0x10;
} else
return;
}
_m[tile].m5 = m5;
MarkTileDirtyByTile(tile);
}
static void TileLoopClearDesert(TileIndex tile)
{
if ((_m[tile].m5 & 0x1C) == 0x14) return;
if (GetMapExtraBits(tile) == 1) {
_m[tile].m5 = 0x17;
} else {
if (GetMapExtraBits(tile + TileDiffXY( 1, 0)) != 1 &&
GetMapExtraBits(tile + TileDiffXY(-1, 0)) != 1 &&
GetMapExtraBits(tile + TileDiffXY( 0, 1)) != 1 &&
GetMapExtraBits(tile + TileDiffXY( 0, -1)) != 1)
return;
_m[tile].m5 = 0x15;
}
MarkTileDirtyByTile(tile);
}
static void TileLoop_Clear(TileIndex tile)
{
byte m5,m3;
TileLoopClearHelper(tile);
if (_opt.landscape == LT_DESERT) {
TileLoopClearDesert(tile);
} else if (_opt.landscape == LT_HILLY) {
TileLoopClearAlps(tile);
}
m5 = _m[tile].m5;
if ((m5 & 0x1C) == 0x10 || (m5 & 0x1C) == 0x14) return;
if ((m5 & 0x1C) != 0xC) {
if ((m5 & 3) == 3) return;
if (_game_mode != GM_EDITOR) {
m5 += 0x20;
if (m5 >= 0x20) {
// Didn't overflow
_m[tile].m5 = m5;
return;
}
/* did overflow, so continue */
} else {
m5 = (GB(Random(), 0, 8) > 21) ? 2 : 6;
}
m5++;
} else if (_game_mode != GM_EDITOR) {
/* handle farm field */
m5 += 0x20;
if (m5 >= 0x20) {
// Didn't overflow
_m[tile].m5 = m5;
return;
}
/* overflowed */
m3 = _m[tile].m3 + 1;
assert( (m3 & 0xF) != 0);
if ( (m3 & 0xF) >= 9) /* NOTE: will not work properly if m3&0xF == 0xF */
m3 &= ~0xF;
_m[tile].m3 = m3;
}
_m[tile].m5 = m5;
MarkTileDirtyByTile(tile);
}
void GenerateClearTile(void)
{
uint i;
TileIndex tile;
/* add hills */
i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400);
do {
tile = RandomTile();
if (IsTileType(tile, MP_CLEAR)) SB(_m[tile].m5, 2, 2, 1);
} while (--i);
/* add grey squares */
i = ScaleByMapSize(GB(Random(), 0, 7) + 0x80);
do {
uint32 r = Random();
tile = RandomTileSeed(r);
if (IsTileType(tile, MP_CLEAR)) {
uint j = GB(r, 16, 4) + 5;
for(;;) {
TileIndex tile_new;
SB(_m[tile].m5, 2, 2, 2);
do {
if (--j == 0) goto get_out;
tile_new = tile + TileOffsByDir(GB(Random(), 0, 2));
} while (!IsTileType(tile_new, MP_CLEAR));
tile = tile_new;
}
get_out:;
}
} while (--i);
}
static void ClickTile_Clear(TileIndex tile)
{
/* not used */
}
static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode)
{
return 0;
}
static const StringID _clear_land_str[] = {
STR_080B_ROUGH_LAND,
STR_080A_ROCKS,
STR_080E_FIELDS,
STR_080F_SNOW_COVERED_LAND,
STR_0810_DESERT,
0,
0,
STR_080C_BARE_LAND,
STR_080D_GRASS,
STR_080D_GRASS,
STR_080D_GRASS,
};
static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
{
uint i = GB(_m[tile].m5, 2, 3);
if (i == 0) i = GB(_m[tile].m5, 0, 2) + 8;
td->str = _clear_land_str[i - 1];
td->owner = GetTileOwner(tile);
}
static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player)
{
return;
}
void InitializeClearLand(void)
{
_opt.snow_line = _patches.snow_line_height * 8;
}
const TileTypeProcs _tile_type_clear_procs = {
DrawTile_Clear, /* draw_tile_proc */
GetSlopeZ_Clear, /* get_slope_z_proc */
ClearTile_Clear, /* clear_tile_proc */
GetAcceptedCargo_Clear, /* get_accepted_cargo_proc */
GetTileDesc_Clear, /* get_tile_desc_proc */
GetTileTrackStatus_Clear, /* get_tile_track_status_proc */
ClickTile_Clear, /* click_tile_proc */
AnimateTile_Clear, /* animate_tile_proc */
TileLoop_Clear, /* tile_loop_clear */
ChangeTileOwner_Clear, /* change_tile_owner_clear */
NULL, /* get_produced_cargo_proc */
NULL, /* vehicle_enter_tile_proc */
NULL, /* vehicle_leave_tile_proc */
GetSlopeTileh_Clear, /* get_slope_tileh_proc */
};

View File

@@ -1,145 +0,0 @@
macro(_parse_arguments_with_multi_hack ORIGINAL_COMMAND_LINE)
# cmake_parse_arguments() put all the MULTIS in a single variable; you
# lose the ability to see for example multiple COMMANDs. To be able to
# passthrough multiple MULTIS, we add a marker after every MULTI. This
# allows us to reassemble the correct amount again before giving it to
# the wrapped command with _reassemble_command_line().
set(COMMAND_LINE "${ORIGINAL_COMMAND_LINE}")
foreach(MULTI IN LISTS MULTIS)
string(REPLACE "${MULTI}" "${MULTI};:::" COMMAND_LINE "${COMMAND_LINE}")
endforeach()
cmake_parse_arguments(PARAM "${OPTIONS}" "${SINGLES}" "${MULTIS}" ${COMMAND_LINE})
endmacro()
macro(_reassemble_command_line)
# Reassemble the command line as we original got it.
set(NEW_COMMAND_LINE ${PARAM_UNPARSED_ARGUMENTS})
foreach(OPTION IN LISTS OPTIONS)
if(PARAM_${OPTION})
list(APPEND NEW_COMMAND_LINE "${OPTION}")
endif()
endforeach()
foreach(SINGLE IN LISTS SINGLES)
if(PARAM_${SINGLE})
list(APPEND NEW_COMMAND_LINE "${SINGLE}" "${PARAM_${SINGLE}}")
endif()
endforeach()
foreach(MULTI IN LISTS MULTIS)
if(PARAM_${MULTI})
# Replace our special marker with the name of the MULTI again. This
# restores for example multiple COMMANDs again.
string(REPLACE ":::" "${MULTI}" PARAM_${MULTI} "${PARAM_${MULTI}}")
list(APPEND NEW_COMMAND_LINE "${PARAM_${MULTI}}")
endif()
endforeach()
endmacro()
# Generated files can be older than their dependencies, causing useless
# regenerations. This function replaces each file in OUTPUT with a .timestamp
# file, adds a command to touch it and move the original file in BYPRODUCTS,
# before calling add_custom_command().
#
# Note: Any add_custom_target() depending on files in original OUTPUT must use
# add_custom_target_timestamp() instead to have the correct dependencies.
#
# add_custom_command_timestamp(OUTPUT output1 [output2 ...]
# COMMAND command1 [ARGS] [args1...]
# [COMMAND command2 [ARGS] [args2...] ...]
# [MAIN_DEPENDENCY depend]
# [DEPENDS [depends...]]
# [BYPRODUCTS [files...]]
# [IMPLICIT_DEPENDS <lang1> depend1
# [<lang2> depend2] ...]
# [WORKING_DIRECTORY dir]
# [COMMENT comment]
# [VERBATIM] [APPEND] [USES_TERMINAL])
function(add_custom_command_timestamp)
set(OPTIONS VERBATIM APPEND USES_TERMINAL)
set(SINGLES MAIN_DEPENDENCY WORKING_DIRECTORY COMMENT)
set(MULTIS OUTPUT COMMAND DEPENDS BYPRODUCTS IMPLICIT_DEPENDS)
_parse_arguments_with_multi_hack("${ARGN}")
# Create a list of all the OUTPUTs (by removing our magic marker)
string(REPLACE ":::;" "" OUTPUTS "${PARAM_OUTPUT}")
# Reset the OUTPUT and BYPRODUCTS as an empty list (if needed).
# Because they are MULTIS, we need to add our special marker here.
set(PARAM_OUTPUT ":::")
if(NOT PARAM_BYPRODUCTS)
set(PARAM_BYPRODUCTS ":::")
endif()
foreach(OUTPUT IN LISTS OUTPUTS)
# For every output, we add a 'cmake -E touch' entry to update the
# timestamp on each run.
get_filename_component(OUTPUT_FILENAME ${OUTPUT} NAME)
string(APPEND PARAM_COMMAND ";:::;${CMAKE_COMMAND};-E;touch;${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp")
# We change the OUTPUT to a '.timestamp' variant, and make the real
# output a byproduct.
list(APPEND PARAM_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp)
list(APPEND PARAM_BYPRODUCTS ${OUTPUT})
# Mark this file as being a byproduct; we use this again with
# add_custom_target_timestamp() to know if we should point to the
# '.timestamp' variant or not.
set_source_files_properties(${OUTPUT} PROPERTIES BYPRODUCT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp)
endforeach()
# Reassemble and call the wrapped command
_reassemble_command_line()
add_custom_command(${NEW_COMMAND_LINE})
endfunction()
# Generated files can be older than their dependencies, causing useless
# regenerations. This function adds a .timestamp file for each file in DEPENDS
# replaced by add_custom_command_timestamp(), before calling add_custom_target().
#
# add_custom_target_timestamp(Name [ALL] [command1 [args1...]]
# [COMMAND command2 [args2...] ...]
# [DEPENDS depend depend depend ... ]
# [BYPRODUCTS [files...]]
# [WORKING_DIRECTORY dir]
# [COMMENT comment]
# [VERBATIM] [USES_TERMINAL]
# [SOURCES src1 [src2...]])
function(add_custom_target_timestamp)
set(OPTIONS VERBATIM USES_TERMINAL)
set(SINGLES WORKING_DIRECTORY COMMENT)
set(MULTIS COMMAND DEPENDS BYPRODUCTS SOURCES)
# ALL is missing, as the order is important here. It will be picked up
# by ${PARAM_UNPARSED_ARGUMENTS} when reassembling the command line.
_parse_arguments_with_multi_hack("${ARGN}")
# Create a list of all the DEPENDs (by removing our magic marker)
string(REPLACE ":::;" "" DEPENDS "${PARAM_DEPENDS}")
# Reset the DEPEND as an empty list.
# Because it is a MULTI, we need to add our special marker here.
set(PARAM_DEPENDS ":::")
foreach(DEPEND IN LISTS DEPENDS)
# Check if the output is produced by add_custom_command_timestamp()
get_source_file_property(BYPRODUCT ${DEPEND} BYPRODUCT)
if(BYPRODUCT STREQUAL "NOTFOUND")
# If it is not, just keep it as DEPEND
list(APPEND PARAM_DEPENDS "${DEPEND}")
else()
# If it is, the BYPRODUCT property points to the timestamp we want to depend on
list(APPEND PARAM_DEPENDS "${BYPRODUCT}")
endif()
endforeach()
# Reassemble and call the wrapped command
_reassemble_command_line()
add_custom_target(${NEW_COMMAND_LINE})
endfunction()

View File

@@ -1,175 +0,0 @@
# Macro which contains all bits to setup the compile flags correctly.
#
# compile_flags()
#
macro(compile_flags)
if(MSVC)
if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md")
# Switch to MT (static) instead of MD (dynamic) binary
# For MSVC two generators are available
# - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the
# configuration of the build tree
# - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to
# specify all configurations that will be available in the generated solution
list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}")
# Set usage of static runtime for all configurations
foreach(MSVC_CONFIG ${MSVC_CONFIGS})
string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS)
string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}")
endforeach()
endif()
# "If /Zc:rvalueCast is specified, the compiler follows section 5.4 of the
# C++11 standard". We need C++11 for the way we use threads.
add_compile_options(/Zc:rvalueCast)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(
/MP # Enable multi-threaded compilation.
/FC # Display the full path of source code files passed to the compiler in diagnostics.
)
endif()
endif()
# Add some -D flags for Debug builds. We cannot use add_definitions(), because
# it does not appear to support the $<> tags.
add_compile_options(
"$<$<CONFIG:Debug>:-D_DEBUG>"
"$<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>" # FORTIFY_SOURCE should only be used in non-debug builds (requires -O1+)
)
if(MINGW)
add_link_options(
"$<$<NOT:$<CONFIG:Debug>>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_compile_options(
"$<$<CONFIG:Debug>:-Wa,-mbig-obj>" # Switch to pe-bigobj-x86-64 as x64 Debug builds push pe-x86-64 to the limits (linking errors with ASLR, ...)
)
endif()
endif()
# Prepare a generator that checks if we are not a debug, and don't have asserts
# on. We need this later on to set some compile options for stable releases.
set(IS_STABLE_RELEASE "$<AND:$<NOT:$<CONFIG:Debug>>,$<NOT:$<BOOL:${OPTION_USE_ASSERTS}>>>")
if(MSVC)
add_compile_options(/W3)
if(MSVC_VERSION GREATER 1929 AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Starting with version 19.30, there is an optimisation bug, see #9966 for details
# This flag disables the broken optimisation to work around the bug
add_compile_options(/d2ssa-rse-)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_options(
-W
-Wall
-Wcast-qual
-Wextra
-Wsign-compare
-Wundef
-Wpointer-arith
-Wwrite-strings
-Wredundant-decls
-Wformat-security
-Wformat=2
-Winit-self
-Wnon-virtual-dtor
# Often parameters are unused, which is fine.
-Wno-unused-parameter
# We use 'ABCD' multichar for SaveLoad chunks identifiers
-Wno-multichar
# Compilers 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.
-fno-strict-aliasing
)
# When we are a stable release (Release build + USE_ASSERTS not set),
# assertations are off, which trigger a lot of warnings. We disable
# these warnings for these releases.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(
"$<${IS_STABLE_RELEASE}:-Wno-unused-variable>"
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-parameter>"
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-variable>"
)
else()
add_compile_options(
"$<${IS_STABLE_RELEASE}:-Wno-unused-variable>"
"$<${IS_STABLE_RELEASE}:-Wno-unused-parameter>"
)
endif()
# Ninja processes the output so the output from the compiler
# isn't directly to a terminal; hence, the default is
# non-coloured output. We can override this to get nicely
# coloured output, but since that might yield odd results with
# IDEs, we extract it to an option.
if(OPTION_FORCE_COLORED_OUTPUT)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_options (-fcolor-diagnostics)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-flifetime-dse=1" LIFETIME_DSE_FOUND)
add_compile_options(
# 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 its own optimized code in some places.
"-fno-strict-overflow"
# Prevent optimisation supposing enums are in a range specified by the standard
# For details, see http://gcc.gnu.org/PR43680
"-fno-tree-vrp"
# -flifetime-dse=2 (default since GCC 6) doesn't play
# well with our custom pool item allocator
"$<$<BOOL:${LIFETIME_DSE_FOUND}>:-flifetime-dse=1>"
)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if (NOT CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-mno-sse4" NO_SSE4_FOUND)
if(NO_SSE4_FOUND)
add_compile_options(
# Don't use SSE4 for general sources to increase compatibility.
-mno-sse4
)
endif()
endif()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
add_compile_options(
-Wall
# warning #873: function ... ::operator new ... has no corresponding operator delete ...
-wd873
# warning #1292: unknown attribute "fallthrough"
-wd1292
# warning #1899: multicharacter character literal (potential portability problem)
-wd1899
# warning #2160: anonymous union qualifier is ignored
-wd2160
)
else()
message(FATAL_ERROR "No warning flags are set for this compiler yet; please consider creating a Pull Request to add support for this compiler.")
endif()
if(NOT WIN32 AND NOT HAIKU)
# rdynamic is used to get useful stack traces from crash reports.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
endif()
endmacro()

View File

@@ -1,50 +0,0 @@
# Macro which contains all bits and pieces to create a single grf file based
# on NFO and PNG files.
#
# create_grf_command()
#
function(create_grf_command)
set(EXTRA_PNG_SOURCE_FILES ${ARGV})
get_filename_component(GRF_SOURCE_FOLDER_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
get_filename_component(GRF_BINARY_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${GRF_SOURCE_FOLDER_NAME}.grf ABSOLUTE)
file(GLOB_RECURSE GRF_PNG_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.png)
file(GLOB_RECURSE GRF_NFO_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nfo)
set(GRF_PNG_SOURCE_FILES ${GRF_PNG_SOURCE_FILES} ${EXTRA_PNG_SOURCE_FILES})
# Copy over all the PNG files to the correct folder
foreach(GRF_PNG_SOURCE_FILE IN LISTS GRF_PNG_SOURCE_FILES)
get_filename_component(GRF_PNG_SOURCE_FILE_NAME "${GRF_PNG_SOURCE_FILE}" NAME)
set(GRF_PNG_BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/sprites/${GRF_PNG_SOURCE_FILE_NAME}")
add_custom_command(OUTPUT ${GRF_PNG_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E copy
${GRF_PNG_SOURCE_FILE}
${GRF_PNG_BINARY_FILE}
MAIN_DEPENDENCY ${GRF_PNG_SOURCE_FILE}
COMMENT "Copying ${GRF_PNG_SOURCE_FILE_NAME} sprite file"
)
list(APPEND GRF_PNG_BINARY_FILES ${GRF_PNG_BINARY_FILE})
endforeach()
add_custom_command(OUTPUT ${GRF_BINARY_FILE}
COMMAND ${CMAKE_COMMAND}
-DGRF_SOURCE_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}
-DGRF_BINARY_FILE=${GRF_BINARY_FILE}
-DNFORENUM_EXECUTABLE=${NFORENUM_EXECUTABLE}
-DGRFCODEC_EXECUTABLE=${GRFCODEC_EXECUTABLE}
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
DEPENDS ${GRF_PNG_BINARY_FILES}
${GRF_NFO_SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating ${GRF_SOURCE_FOLDER_NAME}.grf"
)
# For conviance, if you want to only test building the GRF
add_custom_target(${GRF_SOURCE_FOLDER_NAME}.grf
DEPENDS
${GRF_BINARY_FILE}
)
endfunction()

View File

@@ -1,86 +0,0 @@
# Macro which contains all bits and pieces to create the regression tests.
# This creates both a standalone target 'regression', and it integrates with
# 'ctest'. The first is prefered, as it is more verbose, and takes care of
# dependencies correctly.
#
# create_regression()
#
macro(create_regression)
# Find all the files in the regression folder; they need to be copied to the
# build folder before we can run the regression
file(GLOB_RECURSE REGRESSION_SOURCE_FILES ${CMAKE_SOURCE_DIR}/regression/*)
foreach(REGRESSION_SOURCE_FILE IN LISTS REGRESSION_SOURCE_FILES)
string(REPLACE "${CMAKE_SOURCE_DIR}/regression/" "" REGRESSION_SOURCE_FILE_NAME "${REGRESSION_SOURCE_FILE}")
string(CONCAT REGRESSION_BINARY_FILE "${CMAKE_BINARY_DIR}/ai/" "${REGRESSION_SOURCE_FILE_NAME}")
if("${REGRESSION_SOURCE_FILE_NAME}" STREQUAL "regression.cfg")
continue()
endif()
add_custom_command(OUTPUT ${REGRESSION_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E copy
${REGRESSION_SOURCE_FILE}
${REGRESSION_BINARY_FILE}
MAIN_DEPENDENCY ${REGRESSION_SOURCE_FILE}
COMMENT "Copying ${REGRESSION_SOURCE_FILE_NAME} regression file"
)
list(APPEND REGRESSION_BINARY_FILES ${REGRESSION_BINARY_FILE})
endforeach()
# Copy the regression configuration in a special folder, so all autogenerated
# folders end up in the same place after running regression.
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/regression/regression.cfg
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/regression/regression.cfg
${CMAKE_BINARY_DIR}/regression/regression.cfg
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/regression/regression.cfg
COMMENT "Copying ${REGRESSION_SOURCE_FILE_NAME} regression file"
)
list(APPEND REGRESSION_BINARY_FILES ${CMAKE_BINARY_DIR}/regression/regression.cfg)
# Create a new target which copies all regression files
add_custom_target(regression_files
ALL # this is needed because 'make test' doesn't resolve dependencies, and otherwise this is never executed
DEPENDS
${REGRESSION_BINARY_FILES}
)
enable_testing()
# Find all the tests we have, and create a target for them
file(GLOB REGRESSION_TESTS ${CMAKE_SOURCE_DIR}/regression/*)
foreach(REGRESSION_TEST IN LISTS REGRESSION_TESTS)
get_filename_component(REGRESSION_TEST_NAME "${REGRESSION_TEST}" NAME)
if("${REGRESSION_TEST_NAME}" STREQUAL "regression.cfg")
continue()
endif()
add_custom_target(regression_${REGRESSION_TEST_NAME}
COMMAND ${CMAKE_COMMAND}
-DOPENTTD_EXECUTABLE=$<TARGET_FILE:openttd>
-DEDITBIN_EXECUTABLE=${EDITBIN_EXECUTABLE}
-DREGRESSION_TEST=${REGRESSION_TEST_NAME}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/Regression.cmake"
DEPENDS openttd regression_files
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running regression test ${REGRESSION_TEST_NAME}"
)
# Also make sure that 'make test' runs the regression
add_test(NAME regression_${REGRESSION_TEST_NAME}
COMMAND ${CMAKE_COMMAND}
-DOPENTTD_EXECUTABLE=$<TARGET_FILE:openttd>
-DEDITBIN_EXECUTABLE=${EDITBIN_EXECUTABLE}
-DREGRESSION_TEST=${REGRESSION_TEST_NAME}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/Regression.cmake"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
list(APPEND REGRESSION_TARGETS regression_${REGRESSION_TEST_NAME})
endforeach()
# Create a new target which runs the regression
add_custom_target(regression
DEPENDS ${REGRESSION_TARGETS})
endmacro()

View File

@@ -1,14 +0,0 @@
# Add the definitions to indicate which endian we are building for.
#
# add_endian_definition()
#
function(add_endian_definition)
include(TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
add_definitions(-DTTD_ENDIAN=TTD_BIG_ENDIAN)
else()
add_definitions(-DTTD_ENDIAN=TTD_LITTLE_ENDIAN)
endif()
endfunction()

View File

@@ -1,65 +0,0 @@
#[=======================================================================[.rst:
FindAllegro
-------
Finds the allegro library.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Allegro_FOUND``
True if the system has the allegro library.
``Allegro_INCLUDE_DIRS``
Include directories needed to use allegro.
``Allegro_LIBRARIES``
Libraries needed to link to allegro.
``Allegro_VERSION``
The version of the allegro library which was found.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``Allegro_INCLUDE_DIR``
The directory containing ``allegro.h``.
``Allegro_LIBRARY``
The path to the allegro library.
#]=======================================================================]
find_package(PkgConfig QUIET)
pkg_check_modules(PC_Allegro QUIET allegro<5)
find_path(Allegro_INCLUDE_DIR
NAMES allegro.h
PATHS ${PC_Allegro_INCLUDE_DIRS}
)
find_library(Allegro_LIBRARY
NAMES alleg
PATHS ${PC_Allegro_LIBRARY_DIRS}
)
set(Allegro_VERSION ${PC_Allegro_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Allegro
FOUND_VAR Allegro_FOUND
REQUIRED_VARS
Allegro_LIBRARY
Allegro_INCLUDE_DIR
VERSION_VAR Allegro_VERSION
)
if(Allegro_FOUND)
set(Allegro_LIBRARIES ${Allegro_LIBRARY})
set(Allegro_INCLUDE_DIRS ${Allegro_INCLUDE_DIR})
endif()
mark_as_advanced(
Allegro_INCLUDE_DIR
Allegro_LIBRARY
)

View File

@@ -1,30 +0,0 @@
# Autodetect editbin. Only useful for MSVC.
if(NOT EDITBIN_DIRECTORY)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
get_filename_component(MSVC_COMPILE_DIRECTORY ${CMAKE_CXX_COMPILER} DIRECTORY)
set(EDITBIN_DIRECTORY ${MSVC_COMPILE_DIRECTORY})
else()
# For clang-cl build
# find editbin.exe from environmental variable VCToolsInstallDir
set(EDITBIN_DIRECTORY "$ENV{VCToolsInstallDir}/bin/Hostx64/x64")
endif()
endif()
message(CHECK_START "Finding editbin.exe")
find_program(
EDITBIN_EXECUTABLE editbin.exe
HINTS ${EDITBIN_DIRECTORY}
)
if(EDITBIN_EXECUTABLE)
message(CHECK_PASS "found")
else()
message(CHECK_FAIL "not found , please manually specify EDITBIN_DIRECTORY")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Editbin
FOUND_VAR EDITBIN_FOUND
REQUIRED_VARS EDITBIN_EXECUTABLE
)

View File

@@ -1,65 +0,0 @@
#[=======================================================================[.rst:
FindFluidsynth
-------
Finds the fluidsynth library.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Fluidsynth_FOUND``
True if the system has the fluidsynth library.
``Fluidsynth_INCLUDE_DIRS``
Include directories needed to use fluidsynth.
``Fluidsynth_LIBRARIES``
Libraries needed to link to fluidsynth.
``Fluidsynth_VERSION``
The version of the fluidsynth library which was found.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``Fluidsynth_INCLUDE_DIR``
The directory containing ``fluidsynth.h``.
``Fluidsynth_LIBRARY``
The path to the fluidsynth library.
#]=======================================================================]
find_package(PkgConfig QUIET)
pkg_check_modules(PC_Fluidsynth QUIET fluidsynth)
find_path(Fluidsynth_INCLUDE_DIR
NAMES fluidsynth.h
PATHS ${PC_Fluidsynth_INCLUDE_DIRS}
)
find_library(Fluidsynth_LIBRARY
NAMES fluidsynth
PATHS ${PC_Fluidsynth_LIBRARY_DIRS}
)
set(Fluidsynth_VERSION ${PC_Fluidsynth_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fluidsynth
FOUND_VAR Fluidsynth_FOUND
REQUIRED_VARS
Fluidsynth_LIBRARY
Fluidsynth_INCLUDE_DIR
VERSION_VAR Fluidsynth_VERSION
)
if(Fluidsynth_FOUND)
set(Fluidsynth_LIBRARIES ${Fluidsynth_LIBRARY})
set(Fluidsynth_INCLUDE_DIRS ${Fluidsynth_INCLUDE_DIR})
endif()
mark_as_advanced(
Fluidsynth_INCLUDE_DIR
Fluidsynth_LIBRARY
)

View File

@@ -1,101 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindFontconfig
--------------
Find Fontconfig headers and library.
Imported Targets
^^^^^^^^^^^^^^^^
``Fontconfig::Fontconfig``
The Fontconfig library, if found.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables in your project:
``Fontconfig_FOUND``
true if (the requested version of) Fontconfig is available.
``Fontconfig_VERSION``
the version of Fontconfig.
``Fontconfig_LIBRARIES``
the libraries to link against to use Fontconfig.
``Fontconfig_INCLUDE_DIRS``
where to find the Fontconfig headers.
``Fontconfig_COMPILE_OPTIONS``
this should be passed to target_compile_options(), if the
target is not used for linking
#]=======================================================================]
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig QUIET)
pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
set(Fontconfig_COMPILE_OPTIONS ${PKG_FONTCONFIG_CFLAGS_OTHER})
set(Fontconfig_VERSION ${PKG_FONTCONFIG_VERSION})
find_path( Fontconfig_INCLUDE_DIR
NAMES
fontconfig/fontconfig.h
HINTS
${PKG_FONTCONFIG_INCLUDE_DIRS}
/usr/X11/include
)
find_library( Fontconfig_LIBRARY
NAMES
fontconfig
PATHS
${PKG_FONTCONFIG_LIBRARY_DIRS}
)
if(Fontconfig_INCLUDE_DIR AND NOT Fontconfig_VERSION)
file(STRINGS ${Fontconfig_INCLUDE_DIR}/fontconfig/fontconfig.h _contents REGEX "^#define[ \t]+FC_[A-Z]+[ \t]+[0-9]+$")
unset(Fontconfig_VERSION)
foreach(VPART MAJOR MINOR REVISION)
foreach(VLINE ${_contents})
if(VLINE MATCHES "^#define[\t ]+FC_${VPART}[\t ]+([0-9]+)$")
set(Fontconfig_VERSION_PART "${CMAKE_MATCH_1}")
if(Fontconfig_VERSION)
string(APPEND Fontconfig_VERSION ".${Fontconfig_VERSION_PART}")
else()
set(Fontconfig_VERSION "${Fontconfig_VERSION_PART}")
endif()
endif()
endforeach()
endforeach()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fontconfig
FOUND_VAR
Fontconfig_FOUND
REQUIRED_VARS
Fontconfig_LIBRARY
Fontconfig_INCLUDE_DIR
VERSION_VAR
Fontconfig_VERSION
)
if(Fontconfig_FOUND AND NOT TARGET Fontconfig::Fontconfig)
add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED)
set_target_properties(Fontconfig::Fontconfig PROPERTIES
IMPORTED_LOCATION "${Fontconfig_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${Fontconfig_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${Fontconfig_INCLUDE_DIR}"
)
endif()
mark_as_advanced(Fontconfig_LIBRARY Fontconfig_INCLUDE_DIR)
if(Fontconfig_FOUND)
set(Fontconfig_LIBRARIES ${Fontconfig_LIBRARY})
set(Fontconfig_INCLUDE_DIRS ${Fontconfig_INCLUDE_DIR})
endif()

View File

@@ -1,13 +0,0 @@
# Autodetect grfcodec and nforenum.
#
find_program(GRFCODEC_EXECUTABLE grfcodec)
find_program(NFORENUM_EXECUTABLE nforenum)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Grfcodec
FOUND_VAR GRFCODEC_FOUND
REQUIRED_VARS
GRFCODEC_EXECUTABLE
NFORENUM_EXECUTABLE
)

View File

@@ -1,69 +0,0 @@
# CMake provides a FindICU module since version 3.7.
# But it doesn't use pkgconfig, doesn't set expected variables,
# And it returns incomplete dependencies if only some modules are searched.
#[=======================================================================[.rst:
FindICU
-------
Finds components of the ICU library.
Accepted components are: uc, i18n, le, lx, io
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``ICU_FOUND``
True if components of ICU library are found.
``ICU_VERSION``
The version of the ICU library which was found.
``ICU_<c>_FOUND``
True if the system has the <c> component of ICU library.
``ICU_<c>_INCLUDE_DIRS``
Include directories needed to use the <c> component of ICU library.
``ICU_<c>_LIBRARIES``
Libraries needed to link to the <c> component of ICU library.
#]=======================================================================]
find_package(PkgConfig QUIET)
set(ICU_KNOWN_COMPONENTS "uc" "i18n" "le" "lx" "io")
foreach(MOD_NAME IN LISTS ICU_FIND_COMPONENTS)
if(NOT MOD_NAME IN_LIST ICU_KNOWN_COMPONENTS)
message(FATAL_ERROR "Unknown ICU component: ${MOD_NAME}")
endif()
pkg_check_modules(PC_ICU_${MOD_NAME} QUIET icu-${MOD_NAME})
# Check the libraries returned by pkg-config really exist.
unset(PC_LIBRARIES)
foreach(LIBRARY IN LISTS PC_ICU_${MOD_NAME}_LIBRARIES)
unset(PC_LIBRARY CACHE)
find_library(PC_LIBRARY NAMES ${LIBRARY})
if(NOT PC_LIBRARY)
unset(PC_ICU_${MOD_NAME}_FOUND)
endif()
list(APPEND PC_LIBRARIES ${PC_LIBRARY})
endforeach()
unset(PC_LIBRARY CACHE)
if(${PC_ICU_${MOD_NAME}_FOUND})
set(ICU_COMPONENT_FOUND TRUE)
set(ICU_${MOD_NAME}_FOUND TRUE)
set(ICU_${MOD_NAME}_LIBRARIES ${PC_LIBRARIES})
set(ICU_${MOD_NAME}_INCLUDE_DIRS ${PC_ICU_${MOD_NAME}_INCLUDE_DIRS})
set(ICU_VERSION ${PC_ICU_${MOD_NAME}_VERSION})
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ICU
FOUND_VAR ICU_FOUND
REQUIRED_VARS ICU_COMPONENT_FOUND
VERSION_VAR ICU_VERSION
HANDLE_COMPONENTS
)

View File

@@ -1,133 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindIconv
---------
This module finds the ``iconv()`` POSIX.1 functions on the system.
These functions might be provided in the regular C library or externally
in the form of an additional library.
The following variables are provided to indicate iconv support:
.. variable:: Iconv_FOUND
Variable indicating if the iconv support was found.
.. variable:: Iconv_INCLUDE_DIRS
The directories containing the iconv headers.
.. variable:: Iconv_LIBRARIES
The iconv libraries to be linked.
.. variable:: Iconv_IS_BUILT_IN
A variable indicating whether iconv support is stemming from the
C library or not. Even if the C library provides `iconv()`, the presence of
an external `libiconv` implementation might lead to this being false.
Additionally, the following :prop_tgt:`IMPORTED` target is being provided:
.. variable:: Iconv::Iconv
Imported target for using iconv.
The following cache variables may also be set:
.. variable:: Iconv_INCLUDE_DIR
The directory containing the iconv headers.
.. variable:: Iconv_LIBRARY
The iconv library (if not implicitly given in the C library).
.. note::
On POSIX platforms, iconv might be part of the C library and the cache
variables ``Iconv_INCLUDE_DIR`` and ``Iconv_LIBRARY`` might be empty.
#]=======================================================================]
include(CMakePushCheckState)
if(CMAKE_C_COMPILER_LOADED)
include(CheckCSourceCompiles)
elseif(CMAKE_CXX_COMPILER_LOADED)
include(CheckCXXSourceCompiles)
else()
# If neither C nor CXX are loaded, implicit iconv makes no sense.
set(Iconv_IS_BUILT_IN NO)
endif()
# iconv can only be provided in libc on a POSIX system.
# If any cache variable is already set, we'll skip this test.
if(NOT DEFINED Iconv_IS_BUILT_IN)
if(UNIX AND NOT DEFINED Iconv_INCLUDE_DIR AND NOT DEFINED Iconv_LIBRARY)
cmake_push_check_state(RESET)
# We always suppress the message here: Otherwise on supported systems
# not having iconv in their C library (e.g. those using libiconv)
# would always display a confusing "Looking for iconv - not found" message
set(CMAKE_FIND_QUIETLY TRUE)
# The following code will not work, but it's sufficient to see if it compiles.
# Note: libiconv will define the iconv functions as macros, so CheckSymbolExists
# will not yield correct results.
set(Iconv_IMPLICIT_TEST_CODE
"
#include <stddef.h>
#include <iconv.h>
int main() {
char *a, *b;
size_t i, j;
iconv_t ic;
ic = iconv_open(\"to\", \"from\");
iconv(ic, &a, &i, &b, &j);
iconv_close(ic);
}
"
)
if(CMAKE_C_COMPILER_LOADED)
check_c_source_compiles("${Iconv_IMPLICIT_TEST_CODE}" Iconv_IS_BUILT_IN)
else()
check_cxx_source_compiles("${Iconv_IMPLICIT_TEST_CODE}" Iconv_IS_BUILT_IN)
endif()
cmake_pop_check_state()
else()
set(Iconv_IS_BUILT_IN NO)
endif()
endif()
if(NOT Iconv_IS_BUILT_IN)
find_path(Iconv_INCLUDE_DIR
NAMES "iconv.h"
DOC "iconv include directory")
set(Iconv_LIBRARY_NAMES "iconv" "libiconv")
else()
set(Iconv_INCLUDE_DIR "" CACHE FILEPATH "iconv include directory")
set(Iconv_LIBRARY_NAMES "c")
endif()
find_library(Iconv_LIBRARY
NAMES ${Iconv_LIBRARY_NAMES}
DOC "iconv library (potentially the C library)")
mark_as_advanced(Iconv_INCLUDE_DIR)
mark_as_advanced(Iconv_LIBRARY)
include(FindPackageHandleStandardArgs)
if(NOT Iconv_IS_BUILT_IN)
find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR)
else()
find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY)
endif()
if(Iconv_FOUND)
set(Iconv_INCLUDE_DIRS "${Iconv_INCLUDE_DIR}")
set(Iconv_LIBRARIES "${Iconv_LIBRARY}")
if(NOT TARGET Iconv::Iconv)
add_library(Iconv::Iconv INTERFACE IMPORTED)
endif()
set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Iconv_INCLUDE_DIRS}")
set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_LINK_LIBRARIES "${Iconv_LIBRARIES}")
endif()

View File

@@ -1,89 +0,0 @@
#[=======================================================================[.rst:
FindLZO
-------
Finds the LZO library.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``LZO_FOUND``
True if the system has the LZO library.
``LZO_INCLUDE_DIRS``
Include directories needed to use LZO.
``LZO_LIBRARIES``
Libraries needed to link to LZO.
``LZO_VERSION``
The version of the LZO library which was found.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``LZO_INCLUDE_DIR``
The directory containing ``lzo/lzo1x.h``.
``LZO_LIBRARY``
The path to the LZO library.
#]=======================================================================]
find_package(PkgConfig QUIET)
pkg_check_modules(PC_LZO QUIET lzo2)
find_path(LZO_INCLUDE_DIR
NAMES lzo/lzo1x.h
PATHS ${PC_LZO_INCLUDE_DIRS}
)
find_library(LZO_LIBRARY
NAMES lzo2
PATHS ${PC_LZO_LIBRARY_DIRS}
)
# With vcpkg, the library path should contain both 'debug' and 'optimized'
# entries (see target_link_libraries() documentation for more information)
#
# NOTE: we only patch up when using vcpkg; the same issue might happen
# when not using vcpkg, but this is non-trivial to fix, as we have no idea
# what the paths are. With vcpkg we do. And we only official support vcpkg
# with Windows.
#
# NOTE: this is based on the assumption that the debug file has the same
# name as the optimized file. This is not always the case, but so far
# experiences has shown that in those case vcpkg CMake files do the right
# thing.
if(VCPKG_TOOLCHAIN AND LZO_LIBRARY)
if(LZO_LIBRARY MATCHES "/debug/")
set(LZO_LIBRARY_DEBUG ${LZO_LIBRARY})
string(REPLACE "/debug/lib/" "/lib/" LZO_LIBRARY_RELEASE ${LZO_LIBRARY})
else()
set(LZO_LIBRARY_RELEASE ${LZO_LIBRARY})
string(REPLACE "/lib/" "/debug/lib/" LZO_LIBRARY_DEBUG ${LZO_LIBRARY})
endif()
include(SelectLibraryConfigurations)
select_library_configurations(LZO)
endif()
set(LZO_VERSION ${PC_LZO_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZO
FOUND_VAR LZO_FOUND
REQUIRED_VARS
LZO_LIBRARY
LZO_INCLUDE_DIR
VERSION_VAR LZO_VERSION
)
if(LZO_FOUND)
set(LZO_LIBRARIES ${LZO_LIBRARY})
set(LZO_INCLUDE_DIRS ${LZO_INCLUDE_DIR})
endif()
mark_as_advanced(
LZO_INCLUDE_DIR
LZO_LIBRARY
)

View File

@@ -1,3 +0,0 @@
if(NOT EXISTS ${PANDOC_EXECUTABLE})
find_program(PANDOC_EXECUTABLE pandoc)
endif()

View File

@@ -1,17 +0,0 @@
# Autodetect if SSE4.1 can be used. If so, the assumption is, so can the other
# SSE version (SSE 2.0, SSSE 3.0).
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_REQUIRED_FLAGS "-msse4.1")
endif()
check_cxx_source_compiles("
#include <xmmintrin.h>
#include <smmintrin.h>
#include <tmmintrin.h>
int main() { return 0; }"
SSE_FOUND
)

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