Commit Graph

201 Commits

Author SHA1 Message Date
Darkvater 4e09974975 (svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
- The only change is that the nsignalsw.grf file is kept and that existing nightlies with PBS signals get those signals converted to combo-signals.
2006-01-29 18:57:26 +00:00
Darkvater f4e7d3203a (svn r3466) - Codechange: Some changes to increase readability of signals code. 2006-01-29 10:50:27 +00:00
tron de34ab97a2 (svn r3389) -Fix: No fence was placed when placing fences and the neighbouring tile is a rail configuration which permits a fence but has a signal
(Per request of peter1138 the above line does not contain any commas)
2006-01-07 17:26:37 +00:00
tron 18de531671 (svn r3387) Restructure the code, which places fences along railroad tracks.
This includes no functional changes, just some cleanup before some bugfix
2006-01-07 16:30:49 +00:00
matthijs 08a3e346cd (svn r3369) - Codechange: Replace tables _signals_table, _signals_table_other and _signals_table_both by the equivalent calls to rail.h functions.
- Codechange: Add a few constants.
2006-01-06 00:08:00 +00:00
tron e272b03fee (svn r3365) Staticise 36 functions 2006-01-05 12:40:50 +00:00
tron bf98086de8 (svn r3298) Remove unused and write-only variables 2005-12-14 06:28:48 +00:00
tron 23bfc03054 (svn r3297) Staticise 2005-12-14 06:20:23 +00:00
peter1138 809b03c81a (svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed() 2005-12-10 12:05:39 +00:00
peter1138 754d26407e (svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
- Waypoints: Until now stat_id was saved but never assigned to. Instead we now save the GRFID/local index of the custom graphics so that GRF file changes can leave graphics intact.
2005-11-16 22:20:15 +00:00
truelight c1b012171d (svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
-Codechange: IsRailWaypoint should take 'tile', not 'm5'
2005-11-16 14:41:01 +00:00
peter1138 b739674307 (svn r3209) In TileLoop_Track(), use names based on function rather than their place in the map array. 2005-11-16 14:30:24 +00:00
tron 24f857ed5e (svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing 2005-11-15 09:47:25 +00:00
tron 1b0091e0d2 (svn r3184) GB/SB 2005-11-15 08:49:46 +00:00
tron f7abff5f96 (svn r3181) -Bracing
-Indentation
-Whitespace
-DeMorgan's Law
-Test with NULL or 0 for non-booleans
-'\0' instead of 0 for chars
-Remove redundantly redundant comments (like DoFoo(); // Do foo)
-Join multiple short lines with a single statement
-Split single lines with multiple statements
-Avoid assignments in if
2005-11-14 19:48:04 +00:00
tron 4a14a586e2 (svn r3173) Use the trinary operator and switch to improve readability
Also align short cases nicely
2005-11-13 14:54:09 +00:00
peter1138 a7fe1495cd (svn r3168) - NewGRF: Fix "typo" in waypoint drawer :/ 2005-11-12 00:29:13 +00:00
peter1138 b1075ca7a4 (svn r3166) Constify read-only accesses of custom stations 2005-11-11 20:34:16 +00:00
peter1138 49335b4daa (svn r3141) Replace incorrect railtype bitmask in CmdRailTrackHelper with appropriate GB() 2005-11-05 18:21:28 +00:00
tron 47137cefb7 (svn r3078) Some more stuff, which piled up:
- const, whitespace, indentation, bracing, GB/SB, pointless casts
- use the trinary operator where appropriate
- data types (uint[] -> AcceptedCargo, ...)
- if cascade -> switch
- if (ptr) -> if (ptr != NULL)
- DeMorgan's Law
- Fix some comments
- 0 -> '\0', change magic numbers to symbolic constants
2005-10-23 13:04:44 +00:00
tron 2cc2154ad2 (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
2005-10-22 06:39:32 +00:00
tron 2b91f55b32 (svn r3073) int/byte -> EngineID/PlayerID/VehicleID
0/-1 -> INVALID_ENGINE
0x10 -> OWNER_NONE
2005-10-20 17:43:13 +00:00
tron ece9b9b2b6 (svn r3066) Constify the parameter of GetSlopeZ_*() 2005-10-19 14:49:46 +00:00
tron 66bf4f863d (svn r3049) Replace byte/int/uint by RailType where appropriate 2005-10-16 09:13:04 +00:00
tron 76db75d81a (svn r3028) s/255/OWNER_SPECTATOR/ 2005-10-10 10:36:37 +00:00
Darkvater 9134e19d7e (svn r3025) -Fix: Rail convert issue introduced in r3019 2005-10-07 15:53:33 +00:00
tron ae4a1f3675 (svn r3019) -Codechange: Replace explicit shifting/anding/oring with GB and SB 2005-10-05 07:20:26 +00:00
peter1138 f8d1267d71 (svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?) 2005-09-29 20:20:34 +00:00
Darkvater 8e6a911700 (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
2005-09-18 20:56:44 +00:00
Darkvater 2131f68ae2 (svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
- Add IsLocalPlayer() which substitutes _local_player == _current_player
2005-09-14 18:03:38 +00:00
truelight 2e87864d0b (svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
abilities you really don't want to know about (free bridges, etc..)
       I removed this flag some revisions ago, but the Aircraft part
       depends on it, so I re-enabled it again..
2005-09-13 12:19:27 +00:00
tron f914a7eca6 (svn r2890) Fix some signed/unsigned comparison warnings (tokai) 2005-08-25 16:53:51 +00:00
ludde 29564f9fcf (svn r2781) Fix some of the issues with variables in .h files. 2005-08-01 16:31:19 +00:00
celestar fcf5ace08f (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo 2005-07-31 22:53:57 +00:00
ludde 24986e9144 (svn r2756) Renamed railtypes into _railtypes
Renamed railtypes.c into railtypes.h, all other tables are in .h files. (It should be in the tables dir but I couldn't figure out how to get it there without deleting it first).
Added const and extern.
2005-07-29 22:13:04 +00:00
celestar 1736566e22 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes. 2005-07-29 21:36:02 +00:00
celestar 238e47cd42 (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
by enums. There remains work in gfx.c to move the "transparency" and
"recolor" bits around to make space for more sprites. However, 2800
additional sprites can now be loaded. There also remains cleanup and
Doxygen work on many of the header files.
2005-07-24 15:56:31 +00:00
tron a227065ab7 (svn r2701) Insert Id tags into all source files 2005-07-24 14:12:37 +00:00
tron 559babcdc9 (svn r2673) Include functions.h directly, not globally via openttd.h 2005-07-22 07:02:20 +00:00
celestar 85f06d6e7b (svn r2658) -Codechange: Use MAKE_TRANSPARENT to display a transparented sprite 2005-07-20 22:05:13 +00:00
tron ac66e3e28f (svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read 2005-07-20 15:29:28 +00:00
hackykid edbe969d23 (svn r2621) - Fix: [pbs] When removing tracks, clear their reserved status. 2005-07-17 18:48:45 +00:00
celestar 9ca761b065 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
(i.e. spans two height levels) and use it throughout the code.
-Codechange: Add CanBuildDepotByTileh to find if a tile is suitable to
build a depot on it. Wraps some bitmagic which seems quite unreadable at
first glance
2005-07-16 23:47:37 +00:00
tron 8c1d74162f (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. 2005-07-13 18:04:01 +00:00
Darkvater 480ced43c9 (svn r2529) - Fix: PBS signals showed up as normal signals with the query tool
- Update landscape_grid.html to show busy bits used by PBS.
2005-07-07 22:15:34 +00:00
hackykid 60ddaf95f0 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
- Feature: [pbs] Implement autoplacement of pbs blocks, when a block has an entry and an exit pbs signal, covert the entire block to pbs. Can be turned off in the patch settings.
 - Feature: [pbs] Allow showing of reserved status by making the tracks darker, when the pbs debug level is at least 1.
2005-07-04 14:58:55 +00:00
celestar b872cf7f7b (svn r2515) -Codechange: Removed a good deal of magic sprite numbers in the rail drawing code, and placed neatly into arrays and enums. This also makes way to implement more railtypes without having to do tons of ugly hacks. 2005-07-04 10:01:06 +00:00
tron 229fbefc03 (svn r2505) Remove some unnecessary #includes 2005-07-01 15:46:27 +00:00
celestar 27e61cbd84 (svn r2499) -Codechange: Moved the semaphore bit from bit 2 to bit 3 in _map_hi for rails, in order to make way for pbs 2005-06-30 13:24:17 +00:00
tron ab7b8b50e3 (svn r2492) Remove some pointless casts and fix some nearby indentation 2005-06-27 06:57:24 +00:00
tron bec5e4fb4c (svn r2487) Replace TILE_XY by TileXY/TileDiffXY 2005-06-25 16:44:57 +00:00
tron 61f6f07edd (svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY 2005-06-25 06:15:43 +00:00
tron 3154e7148d (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile" 2005-06-24 12:38:35 +00:00
hackykid 5119cce2a8 (svn r2469) - Add: When removing tracks with the 'remove' tool, have it automatically remove signals on the tracks. 2005-06-21 19:45:05 +00:00
hackykid 4754dad0d6 (svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
- CodeChange: Remove unused variable in CmdSignalTrackHelper.
2005-06-19 11:56:07 +00:00
tron 8c6fa13faa (svn r2452) Fix defect in r2448 which caused building tracks unexpectedly fail or succeed 2005-06-17 07:35:10 +00:00
matthijs 9cb58e0bb3 (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.
2005-06-16 18:04:02 +00:00
tron ea0f21fbcc (svn r2434) Fix some defects in r2433 2005-06-08 09:03:29 +00:00
Darkvater 0171aae109 (svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138) 2005-06-07 21:37:00 +00:00
hackykid 6d78b70075 (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
- Codechange: Remove some magic numbers (PALETTE_CRASH)
2005-06-06 22:44:11 +00:00
tron c2e977a0b8 (svn r2409) Missed one _map_owner -> IsTileOwner() 2005-06-04 12:14:51 +00:00
tron 74541c1dcc (svn r2408) Introduce SetTileOwner() and use it 2005-06-04 12:13:24 +00:00
tron 0c4ecbe9ec (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner 2005-06-04 11:56:32 +00:00
Darkvater b438b1248c (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files. 2005-06-02 19:30:21 +00:00
Darkvater 3fd39ec630 (svn r2322) - CodeChange: doxygen commented the tunnel-crash fix. Also if (bla) {return;} else {return;} is not proper code. It's if (bla) {return;} return; ;) 2005-05-15 16:30:02 +00:00
matthijs 2151550631 (svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid) 2005-05-15 13:48:23 +00:00
Darkvater 0ddf93956e (svn r2317) - Fix: [ 1193048 ] Pre-signal stays red when there is only a single exit signal (dinno) 2005-05-15 10:23:42 +00:00
Darkvater 033995ec6e (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
- CodeChange: remove cmd-misuses CmdStartScenario() and CmdDestroyCompanyHQ()
- Fix (invisible): when parameter checking CmdRestoreOrderIndex() the vehicle did not have its orders yet, so it would fail. So move doing this until AFTER the orders have been added back in RestoreVehicleOrders()
2005-05-12 23:46:01 +00:00
Darkvater edd8c87502 (svn r2286) - CodeChange: paramcheck the next batch of commands.
- Fix (regression): fix up terraform land where every player can terraform land (towns, map generation), and player can terraform different corners; used for building tunnels
2005-05-09 16:37:40 +00:00
Darkvater 2b96754673 (svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
- Fix: [ 1197256 ] max station spread patch < 7 does not work. Station spread was not taking into account when not using drag&drop. Fix this up, and add a callback to the settings window to immediately reflect the changes.
2005-05-09 13:26:15 +00:00
Darkvater 3ad11e0ad4 (svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed() 2005-05-07 10:26:12 +00:00
tron 566df8dc65 (svn r2223) When adding tracks to a railway tile reset the ground to bare land, fix for a glitch in r2131 2005-04-24 07:56:18 +00:00
tron cada1e24b5 (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed. 2005-04-14 11:17:36 +00:00
celestar 91d44ef577 (svn r2173) -Fix: [ 1179380 ] Rail now builds on reserved land. Cause by the problem that CMD_ERROR is just the highest bit of the return value, but CMD_CLEAR_LANDSCAPE returns a negative value for owned land. So the highest bit is set as well. Note to self: Finish Command Patch 2005-04-09 06:20:03 +00:00
tron 0f830b79e1 (svn r2134) Return the correct error message if rail is already under a bridge, fix for r2131 2005-04-02 22:04:43 +00:00
tron 10e4c9bfab (svn r2132) Fix copy&paste bug in r2131 2005-04-02 19:45:52 +00:00
tron ad7f157ac4 (svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
- Check input parameters for validity
- Adhere patch settings - you were able to build foundations under bridges even if foundations where deactivated
- Charge for foundations in all cases - foundations under bridges were for free
- Make the control flow more clear
2005-04-02 18:33:53 +00:00
truelight c6f56edcff (svn r2113) -Fix: first check if a vehicle is a train, before accessing u.rail 2005-03-31 12:39:18 +00:00
tron 9d2406729e (svn r2102) Fix bug introduced in r2038, which gave you money for clearing occupied railway tiles ([1171926]) 2005-03-28 18:59:33 +00:00
tron bba102e624 (svn r2095) In CheckTrackCombination(): if () cascade -> switch, improve readability 2005-03-28 07:25:36 +00:00
tron ae359d0d02 (svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch 2005-03-28 07:02:51 +00:00
truelight 6d75cce924 (svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
are checked against the vehicle-position-hash, instead all vehicles to 
the PF-position-hash. Big speed increase (function usages drops from 9% 
to 0.5%!) for maps with a lot of trains.
2005-03-25 13:37:37 +00:00
truelight 83637d164e (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
-Codechange: rewrote some functions while moving waypoint-stuff
-Add: added support for 64k waypoints
-Fix: made the waypoint struct a bit more logic (no bit-fucking)
2005-03-24 17:03:37 +00:00
tron ccd6a0614f (svn r2040) Readd check that got accidently removed in r2022 2005-03-24 07:48:04 +00:00
tron bfc1d43a27 (svn r2039) IS_RAIL_DEPOT -> IsRailDepot, IS_RAIL_WAYPOINT -> IsRailWaypoint
remove now unused enums and remove a redundant condition in one if
2005-03-23 21:57:10 +00:00
tron 71dba5f511 (svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
While here rewrite parts of the function to (hopefully) increase clarity
2005-03-23 20:02:28 +00:00
tron e5036891f6 (svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function 2005-03-18 07:37:32 +00:00
tron 4bf173e9c1 (svn r1981) Typedef some structs and enums 2005-03-10 07:01:43 +00:00
tron 20b8c48440 (svn r1903) Replace some casts and macro magic with proper typing, similar to r1902 2005-02-22 18:27:57 +00:00
tron 204d08140a (svn r1867) Include tables/sprites.h only in files which need it 2005-02-13 11:18:02 +00:00
matthijs c5c5c9b17c (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.
2005-02-06 22:36:08 +00:00
tron 27dc506a03 (svn r1832) Next byte -> char iteration: custom names 2005-02-06 20:53:31 +00:00
truelight e9c93f9c0c (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)
2005-02-06 10:18:47 +00:00
matthijs a2dec6c32a (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().
2005-01-31 11:23:10 +00:00
tron 7bbcf5875c (svn r1749) Move the functions which calculate distances to map.[ch] and give the more meaningful names 2005-01-31 07:23:15 +00:00
darkvater 8580e73b65 (svn r1733) - Fix: oops "| 1" is SETBIT(x, 0), not 1 :(. Now you can remove signals again 2005-01-30 16:08:19 +00:00
darkvater abf2ae3f80 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid! 2005-01-30 15:57:38 +00:00
tron 5885b31bb4 (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 2005-01-29 12:19:05 +00:00
darkvater 660f130d2b (svn r1624) -Fix: [1106930] BugFix: placing signals with 2x1 drags is treated as placing a single signal thus providing an easy fix for a nasty problem. 2005-01-23 20:40:49 +00:00
tron 44f48ce915 (svn r1610) Remove trailing whitespace (last time ever, i hope) 2005-01-23 13:09:35 +00:00