Commit Graph

38 Commits (80760b4f69bc4f552ff22593d19365662e62caf3)

Author SHA1 Message Date
matthijs c074f4e935 (svn r2473) - Add: VehicleMayEnterTile(), which checks if the tile owner of a tile is correct for a vehicle to enter it. Based upon glx's code.
- Fix: [ 1203769 ] [NPF] NPF tries to plan over bridges, through tunnels, over level crossings of other players. (glx)
- Codechange: Renamed TRANSPORT_MAX to TRANSPORT_END and added INVALID_TRANSPORT.
- Codechange: Moved IsLevelCrossing() from tile.h to rail.h
- Add: GetCrossingTransportType(), which returns the transport type (road, rail) of both tracks on a level crossing.
- Removed old TODO that was fulfilled already.
19 years ago
matthijs bf761af163 (svn r2471) - Fix: [ 1221249 ] [NPF] Vehicles try to drive into a tunnel entrance from above. 19 years ago
matthijs 84655ddb15 (svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
* Moved GetTileRailType() from npf.c to rail.[ch].
19 years ago
matthijs 13b7f222f3 (svn r2451) * Fix: Assertion caused by passing a trackdir where a track was expected. 19 years ago
matthijs a63a84ef5d (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
* Codechange: Made npf.c use some map array accessing wrappers instead of direct access.
* Codechange/Fix: Named every enum in tile.h. Fixes a nasty bug on MSVC where arrays would be initialised with zeroes (tnx Asterix_)
* Removed magic numbers from tables in tile.c.
* Added some explicit casts in tile.h.
19 years ago
matthijs 1876744744 (svn r2448) General cleanup of rail related code, more to follow.
* Add: rail.[ch] for rail-related enums and wrapper functions.
* Codechange: Removed dozens of magic numbers with below enums.
* Codechange: Rewrote CheckTrackCombination().
* Add: TILE_SIZE, TILE_PIXELS and TILE_HEIGHT constants.
* Add: enums RailTileType, RailTileSubtype, SignalType to mask against the map arrays.
* Add: enums Track, TrackBits, Trackdir, TrackdirBits for railway track data. (Note that the old RAIL_BIT constants are replaced by TRACK_BIT ones).
* Add: enums Direction and DiagDirection
* Codechange: Moved a bunch of track(dir) related lookup arrays from npf.[ch] to rail.[ch].
* Codechange: move RailType enum from tile.h to rail.h.
* Add: Wrapper functions for masking signal status in the map arrays: SignalAlongTrackdir, SignalAgainstTrackdir and SignalOnTrack.
* Add: Wrapper functions to access rail tiles, using above enums
* Add: Wrapper functions to modify tracks, trackdirs, directions, etc.
* Add: Wrapper functions for all lookup arrays in rail.[ch] (Arrays are still used in parts of the code)
* Codechange: Renamed some variables and arguments to better represent what they contain (railbit -> track, bits -> trackdirbits, etc.). 
* Codechange: Don't use FindLandscapeHeight() in CmdRemoveSingleRail(), since it returns way too much info. Use GetTileSlope() instead.
* Codechange: [NPF] Removed some unused globals and code from npf.c.
19 years ago
matthijs 65de40f547 (svn r2447) * Add: [NPF] Penalty for road vehicles making turns. 19 years ago
Darkvater c37cf285ce (svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138) 19 years ago
Darkvater ba8c649fac (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files. 19 years ago
matthijs ea0f4757c6 (svn r2363) - Codechange: [NPF] Removed caching the endnode check. The code for this was buggy, fundamentally flawed and barely useful. (Hackykid) 19 years ago
matthijs 3081316c69 (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
- Add: [NPF] Reversing inside of depots now has a penalty. It also applies to trains only, other vehicles shouldn't bother reversing.
- Fix: [NPF] When checking whether to reverse a train, the trackdir of the first loc was used instead of the last vehicle as a starting node for pathfindig.
	This might have caused some trains not reversing when they should have (or vice versa). Typo introduced when converting to GetVehicleTrackdir() in r2256.
- CodeChange: [NPF] Removed duplicate code by letting NPFRouteTjoStationOrTile() call NPFRouteToStationOrTileTwoWay().
- Add: [NPF] NPFRouteToDepotBreadthFirstTwoWay() to find a depot while also looking backwards.
- Add: It is now possibly to specify a path cost for aystar starting nodes.
19 years ago
matthijs 64d7dbe4ca (svn r2257) - Fix: [NPF] NPF debug markings modify _map2 instead of _map3_hi for street tiles, corrupting them.
Some info got moved around in r1768 for street tiles, but NPF did not get updated.
19 years ago
matthijs ba733c005d (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
Buoys will now try to get within 3 tiles of a buoy instead of a the actual buoy tile. This gets ships to got past buoys in a realistic (IMO) way instead of barging right through them.
- Fix: [NPF] Trains get curves penalties sometimes even when the track is straight.
- Add: [NPF] Ships get a penalty for going over buoys now, so they will try to go around.
- Add: [NPF] Ships get a penalty for curves too, yay for straight lines.
- Add: TrackdirToTrack(), TrackToTrackdir(), IsDiagonalTrack() and IsDiagonalTrackdir() helper functions.
- Add: IsBuoy() and IsBuoyTile() helper functions.
- Codechange: Rearranged part of the control flow of ShipController(), removing a goto.
19 years ago
matthijs a2d7015248 (svn r2253) - Fix: [ 1190896 1184378 ] [NPF] Trains ignoring their railtype (mono, maglev) (glx) 19 years ago
matthijs c6f40b4696 (svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though. 19 years ago
matthijs 1858c37346 (svn r2182) - Add: [NPF] There is now a debug class for NPF. Use -d npf<level> to enable debugging printouts from npf.
- Codechange: [NPF] Removed NPF_MARKROUTE macro, to mark routes just specify a npf debugging level >= 1 on the commandline.
20 years ago
matthijs 81fd47ac28 (svn r2181) - Add: DistanceTrack() to calculate the distance over optimally laid out tracks.
- Codechange: [NPF] Removed unused heuristic function NPFCalcTileHeuristic().
- Codechange: [NPF] Use DistanceTrack() instead of DistanceManhattan() for ship and train heuristic.
- Codechange: Renamed variables x and y to dx and dy in some of the distance calculation functions.
20 years ago
matthijs ad5c6a1ecd (svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
- Codechange: [NPF] Improved the NPF hash calculation slightly.
- Codechange: [NPF] Increased hash size, should speed up somewhat.
20 years ago
matthijs 62b1e657c9 (svn r2159) - Fix: [NPF] Road vehicles never found their target station or depots (introduced in r2154)
- Fix: [NPF] Trains still tried to go through the back of depots.
20 years ago
matthijs d08dfa84a4 (svn r2154) - Fix: [NPF] Vehicles should no longer try to drive through the back of depots and road stations.
- Add: GetDepotDirection() wrapper function.
- Fix: [NPF] Ships can now actually reach buoys.
20 years ago
matthijs bb67c4f356 (svn r2148) - Add: [NPF] Trains can now plan taking into account that they can reverse in depots. This makes forced servicing tracks work with NPF. 20 years ago
matthijs cee1a5d1b2 (svn r2147) - Add: [NPF] Give red presignal exit signals a different (higher) penalty, to discourage trains from waiting at presignal exits. 20 years ago
truelight 3177525871 (svn r2121) -Fix: changed the 2nd param of AyStar_EndNodeCheck back to what it should be 20 years ago
matthijs 7d0eff175a (svn r2007) - Fix: [NPF] Slope penalties did not work correctly with foundations. (HackyKid)
- Fix: [NPF] Stations penalties were not applied correctly, since stations had no base cost. (HackyKid)
- Fix: [NPF] Lastred penalty was applied multiple times for every red signal, instead of just the last one. (HackyKid)
20 years ago
matthijs 6367bda0bf (svn r2006) - Fix: [NPF] Wrong signal detection for last signal red detection. Multiple tracks per tile with only one signal were detected wrong. (HackyKid) 20 years ago
matthijs 82e55eb591 (svn r1968) - Fix: [NPF] Mixed declarations and statements 20 years ago
pasky 05455047a1 (svn r1967) Codechange: A mix of mostly indentation-related tidyups. 20 years ago
matthijs e7af60594b (svn r1964) - Add: [NPF] Added a penalty 20 years ago
matthijs 6a5495f83c (svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
- Add: [NPF] NPFGetFlag() and NPFSetFlag() to wrap NPF node flag handling
20 years ago
pasky 2002aaead1 (svn r1957) Compilation fix. 20 years ago
matthijs 26c4e9e931 (svn r1956) -Fix: [NPF] New target tile for heuristic should perform better with larger stations (HackyKid) 20 years ago
matthijs a3d2b0e66d (svn r1843) - Codechange: [NPF] Removed some unused code. 20 years ago
tron 4867f6b234 (svn r1842) Fix another typo made in r1834 20 years ago
matthijs cc0966405b (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
- Add: asserts to find the v->u.rail.track == 0 problem.
- Add: IsValidDepot(), IsValidTown(), IsValidSign(), IsValidVehicle(), IsValidStation()
- Add: GetTileOwner(), IsTileOwner()
- Codechange: Replaced IsShipDepotTile(), IsTrainDepotTile(), IsRoadDepotTile() by IsTileDepotType().
- Codechange: typedeffed the MAP_OWNERS as Owner. Should be used as variable type.
- Codechange: Replaced a few uint by TileIndex.
20 years ago
truelight bd7f37d592 (svn r1817) -Codechange: Moved depot-functions to depot.c
-Codechange: Added wrappers around depot-access (GetDepot no exists)
-Codechange: Made depot-functions a bit more logic (no longer 
GetDepotByTile crashes your game when you request it on a non-depot tile)
-Add: made depots dynamic (yes, 64k depots are possible now)
20 years ago
tron 36c9758c94 (svn r1803) Move debugging stuff into files of it's own 20 years ago
darkvater 870f28a76e (svn r1752) - Fix: MSVC acting up once again, as well as project file updates for the missing files. 20 years ago
matthijs eb78cdb2d4 (svn r1751) - Feature: New PathFinder (NPF).
- Supports trains, road vehicles and ships.
	- Uses A* pathfinding (same codebase as the new ai).
	- Currently unlimited search depth, so might perform badly on large maps/networks (especially ships).
	- Will always find a route if there is one.
	- Allows custom penalties for obstacles to be set in openttd.cfg (npf_ values).
	- With NPF enabled, ships can have orders that are very far apart. Be careful, this will break (ships get lost) when the old pathfinder is used again.
- Feature: Disabling 90 degree turns for trains and ships.
	- Requires NPF to be enabled.
	- Ships and trains can no longer make weird 90 degree turns on tile borders.
- Codechange: Removed table/directions.h.
	- table/directions.h contained ugly static tables but was included more than once. The tables, along with a few new ones are in npf.[ch] now. Better suggestions for a location?
- Fix: Binary heap in queue.c did not allocate enough space, resulting in a segfault.
- Codechange: Rewritten FindFirstBit2x64, added KillFirstBit2x64.
- Codechange: Introduced constant INVALID_TILE, to replace the usage of 0 as an invalid tile. Also replaces TILE_WRAPPED.
- Codechange: Moved TileAddWrap() to map.[ch] 
- Add TileIndexDiffCByDir(), TileIndexDiffCByDir(). 
- Codechange: Moved IsTrainStationTile() to station.h
- Add: IsRoadStationTile() and GetRoadStationDir().
20 years ago