Commit Graph

49 Commits (f9f6b5f341b8b296e58fa33a719bfd1ede5ebd05)

Author SHA1 Message Date
belugas 392fc3a45b (svn r7198) -Codechange: Implement a circular tile search function.
Just provide the number of tiles per side, a pointer to a test function, the tile to start searching and voila.
Fixes [FS#364] by removing a lengthy and suboptimal random search pattern.
Thanks Rubidium.
18 years ago
Darkvater 2380bb56cd (svn r6775) -Codechange: Use some more proper types, especially Owner and PlayerID as
these are used intermixed often.
18 years ago
Darkvater a85d679f54 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
put it into player.h where it belongs (instead of map.h)
18 years ago
Darkvater 227cebb0be (svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
the minimap. This also saves us from having this huge _owner_colors table.
18 years ago
glx 431c22029b (svn r6408) -Fix(r6406): compilation was broken
-Codechange: Rename TileIndexDiffCByDir to TileIndexDiffCByDiagDir because it accepts DiagDirections
18 years ago
Darkvater 7e4d0f112e (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
DiagDirections, and add TileOffsByDir that handles Directions.
-Codechange: Make the treeloop use TileOffsByDir().
18 years ago
rubidium 908d3bcfe6 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct. 18 years ago
tron a2362674e3 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc. 18 years ago
tron 05ed2a8d8c (svn r3342) Remove some cruft 19 years ago
tron 0b936c3222 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
nothing spectacular, just some stuff, which piled up
19 years ago
Darkvater 4a58250cb9 (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
- change a lot of byte player types to PlayerID
- beautify header files, same "#endif /* filename */" ending
19 years ago
matthijs 6f45959d1e (svn r2929) * Move DistanceTrack from map.c to npf.c and rename to NPFDistanceTrack.
* Make NPFDistanceTrack return the distance multiplied by NPF_TILE_LENGTH to prevent rounding
  This should make ship and train pathfinding more accurate and faster.
* Update IsEndOfLine to prevent trains from trying to go off a slope onto a tunnel entrance.
19 years ago
tron 8b74a95d36 (svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing. 19 years ago
tron 647cbd6bdd (svn r2701) Insert Id tags into all source files 19 years ago
tron 71140a5768 (svn r2669) Shuffle some more stuff around to reduce dependencies 19 years ago
ludde 2123deff13 (svn r2560) Fix: various minor code changes.
Added RandomTile/RandomTileSeed functions to generate a random tile.
Changed landscape routines so they don't assume that the Y map side is a power of two. (support for this is not complete, though)
Changed some frequently used map macros to not compute the values each time.
Silence some warnings on MSVC.
19 years ago
tron a4bf608d40 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes. 19 years ago
tron 9617614b04 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY 19 years ago
tron 2b73dec567 (svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY 19 years ago
tron a733fede9b (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile" 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 78eeb84d6b (svn r2183) - Fix: Removed brackets from around STRAIGHT_TRACK_LENGTH, they caused preliminary rounding... 19 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.
19 years ago
tron cec0261223 (svn r1937) TILE_FROM_XY() returns a TileIndex, not an int 20 years ago
tron a370af76d2 (svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers 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
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
tron bb680056b1 (svn r1749) Move the functions which calculate distances to map.[ch] and give the more meaningful names 20 years ago
tron 001aa8e453 (svn r1722) -Feature: Bigger maps - anyone? 20 years ago
tron 3515b670d2 (svn r1714) Add missing include 20 years ago
tron 39858e696b (svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h 20 years ago
tron 400f07fdb8 (svn r1706) Implement ScaleByMapSize() and ScaleByMapSize1D()
These scale a number relative to the map size/circumference.
Use them to scale the amount of map objects.
Of course at the moment they return just the input, because there are no bigger/smaller maps yet.
20 years ago
tron 07cb3068ae (svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
WARNING: If i made any mistake here it WILL lead to corrupted savegames!
20 years ago
tron 90cafa9b15 (svn r1560) Introduce SetTileType() and SetTileHeight()
Replace direct references to _map_type_and_height with these
20 years ago
tron 27057ae4b0 (svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
Replace some direct references to _map_type_and_height with TileHeight()/IsTileType()
20 years ago
tron ca8eb44828 (svn r1542) Rename TileHeight to TilePixelHeight, because this is what it actually returns 20 years ago
tron 61a6bc544d (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts 20 years ago
tron f0be7b6192 (svn r1475) Fix some more signed/unsigned comparison warnings 20 years ago
tron 7ee55362c5 (svn r1447) Move TILE_ADD(), TILE_ADDXY() and SafeTileAdd() to map.[ch] and make the latter map size agnostic 20 years ago
tron 872c51f134 (svn r1415) Move TILE_FROM_XY and TILE_XY to map.h and push TILE_[XY] bits from map.h into map.c.
Now the whole source except map.c is independent of TILE_[XY]_BITS!
20 years ago
tron 414ac3286b (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY] 20 years ago
tron d3c6855320 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff 20 years ago
tron e4cf2ba1b3 (svn r1386) Move TileIndexDiff to map.h
Move _tileoffs_by_dir to map.[ch] and encapsulate it in TileOffsByDir()
20 years ago
tron bcff0ab932 (svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY] 20 years ago
tron 181e9b6cf9 (svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
While here replace one erroneous TILE_MAX_X with MapMaxY()
20 years ago
truelight 2f9e0b8e0c (svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
an uint8 till the savegame version is bumped to version 5. Then it works 
automaticly as a fully uint16. So _stations[] can not be increased till 
after the bump!!
20 years ago
tron 6318ba9598 (svn r1144) Don't rely on sizeof() to determine the map size, use MapSize() instead 20 years ago
tron b976a349c6 (svn r1130) Add helper functions to query map size 20 years ago
tron a148ff4e0d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h 20 years ago