Commit Graph

284 Commits (da428dca703d9c5e8c948bbab9adbb6e7b10d29f)

Author SHA1 Message Date
bjarni b87b5f1187 (svn r3402) -Fix: [building/cloning] added a string telling if build failed due to not being able to build a vehicle. Triggered when cloning a retired design 19 years ago
peter1138 7c5a58bbad (svn r3392) Train depot fixes:
- Only count the parts from the source train that will be moved, not the whole train.
 - Don't count articulated parts of an engine. This alleviates issues with autoreplacing very long trains.
19 years ago
peter1138 e81c316134 (svn r3388) - NewGRF: Allow train running cost class to differ from engine class. Also fix typo in r3384. 19 years ago
truelight e8c871a603 (svn r3381) -Fix: r3374 left one bug: allow moving around wagons in a 100 long train 19 years ago
peter1138 79ce0def50 (svn r3378) - NewGRF Fix: Use order status to determine whether a vehicle is loading instead
of speed, and get that state from first vehicle in a train consist.
19 years ago
truelight b542f784f9 (svn r3374) -Fix: [ FS#36 ] Don't allow trains to get bigger than 100 via drag and drop 19 years ago
truelight 54501dc6df (svn r3373) -Fix: don't link a wagon to itself, which resulted in a wagon disapearing, and a depot which was unable to remove 19 years ago
tron af70b49bf7 (svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
As side effect this is a
-Fix: The default AI tried to change the service intervals of vehicles via the CMD_CHANGE_TRAIN_SERVICE_INT command - regardless of the type of the vehicle - which of course failed for non-trains
19 years ago
tron e272b03fee (svn r3365) Staticise 36 functions 19 years ago
tron 246c126d25 (svn r3353) Simplify the automatic length adjustment algorithm for replacing trains: Use the length of the train before the replacement as reference length 19 years ago
peter1138 1ffc700797 (svn r3352) - NewGRF: Move initialization of vehicle random_bits to DC_EXEC blocks to allow use of Random() instead of InteractiveRandom(), which will alleviate some possible network desyncs. 19 years ago
peter1138 f6330faead (svn r3303) Change #if PF_BENCHMARK to #ifdef PF_BENCHMARK 19 years ago
tron 23bfc03054 (svn r3297) Staticise 19 years ago
peter1138 fde99748c0 (svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved. 19 years ago
bjarni e472fed85a (svn r3219) -Codechange: removed the now obsolite code in the build train command to make half multiheaded engines 19 years ago
bjarni 22a4679837 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
This means that any user attempt to remove a rear engine will tell the user to move the front engine instead
	This fixes the assert when moving multiheaded engines (introduced in r3144)
	Note: to make old savegames use this feature, some engines might be turned around in order to link engines in pairs

-Codechange: train subtype is now a bitmask
	This allows fast access to info like if it is a wagon or engine and if it is in front and so on
	Note: savegame version bump
19 years ago
tron 89cfe202b8 (svn r3208) Don't explicitly pass the engine type to look for to GetRearEngine(), because it's the engine type of the vehicle which gets passed as first parameter 19 years ago
tron 8cebe2f607 (svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection 19 years ago
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
19 years ago
tron 5fa6b7eb06 (svn r3179) - RandomRange() and RandomTile() instead of home brewed versions
- CHANCE*() instead of mumbling strange numbers
19 years ago
tron 833032adc0 (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT 19 years ago
tron 357aba7475 (svn r3176) Use proper types, not some variants of int 19 years ago
tron ee15e3de13 (svn r3172) static, const 19 years ago
bjarni 5e278b7ec3 (svn r3156) -Fix: removed some cases where autoreplace windows were redrawn when nothing was changed
due to the FOR_ALL_VEHICLES(), redrawing those windows are slow
19 years ago
bjarni 5481dcd191 (svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
-Trains will now remember the length of stations it visits and sell cars
        when being autoreplaced if they became too long
        -If it needs to remove cars, then it starts from the front and sells
        all it can find until the train is short enough
        -This only works for trains, that knows the station length of the route
        so a full uninterrupted run is needed
        -a train needs 1-2 runs to detect if the shortest station is expanded
        -This feature can be turned on and off in the train replace window
        and each company can have it's own setting
        -NOTE: minor savegame version bump
19 years ago
peter1138 8bcfa23d29 (svn r3150) Unify some code duplication in HandleLocomotiveSmokeCloud() 19 years ago
peter1138 220b4c27c1 (svn r3147) Fix crash when building dual-head rail vehicles... 19 years ago
peter1138 b58cfc36da (svn r3146) Avoid use of variable size declared arrays when allocating articulated rail vehicles. 19 years ago
peter1138 de76933337 (svn r3145) Fix two off-by-one errors in building articulated rail vehicles. 19 years ago
bjarni 63842939ed (svn r3144) -Fix: a new train is now made if the front unit is an engine and the former front engine is moved away (Meush) 19 years ago
peter1138 267314b4d0 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders. 19 years ago
bjarni c8ea743e47 (svn r3136) -Fix: [autoreplace] all cargo in engines that consists of more than one vehicle will try to move cargo from all vehicles
currently this applies to planes and multiheaded train engines (no more lost airmail)
	added GetNextEnginePart() that returns the next vehicle in an engine nomatter what type it is
	when more types of multivehicle engines are added, they will have to be added here too or autoreplace will not remove all cargo
19 years ago
peter1138 081bae03d9 (svn r3132) -NewGRF: support positioning of rail vehicle visual effects. 19 years ago
peter1138 e80d448478 (svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train. 19 years ago
bjarni 682b9ee8e4 (svn r3111) -Fix: [autoreplace] [ 1341783 ] Assertion failure in vehicle.c line 378
running MaybeReplaceVehicle() is now delayed until after the loop in CallVehicleTicks()
	This avoids selling the vehicle the loop currently works with (and continues to work with afterwards)
19 years ago
peter1138 1a2ad83b00 (svn r3107) -NewGRF: Move train y-position offset adjustment to remove code duplication, and make it apply only to vehicles with a custom image. 19 years ago
bjarni 6d41c23cf2 (svn r3101) -Codechange: added _new_vehicle_id
this var works like _new_train_id and the rest of that kind of vars, except it is set each time a vehicle is build, nomatter what type
	this is a nice tool to code vehicle independent code, which in turn can reduce code duplication
	Right now it's used in ReplaceVehicle() and CmdCloneVehicle()
19 years ago
tron 9e957ff80b (svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI 19 years ago
bjarni bf467bd99c (svn r3081) -Codechange: [autoreplace] complete rewrite of autoreplace
this is a complete rewrite, that makes use of existing commands like build and sell
        this means that multiheaded train engines are replaced correctly
19 years ago
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
19 years ago
tron d4752ba0da (svn r3058) The default AI may not build dual headed trains under certain circumstances.
Simplify this check by testing the rail vehicle info flags instead of passing a global variable around.
Note: This is not exactly the original behaviour, because the Lev4 was always allowed to be built, but i guess that was a glitch.
19 years ago
tron 9314ea877f (svn r3052) Fix last commit *grml* 19 years ago
tron 0834a88a12 (svn r3051) Remove the unused function RemoteSubsidyAdd() 19 years ago
tron ab657338ec (svn r3048) Replace 0/1/2 by RAILTYPE_RAIL/MONO/MAGLEV where appropriate 19 years ago
tron d37639ac3e (svn r3036) Use IsCompatibleRail() to check the rail type of level crossings (not a fix, because the old == method works so far) 19 years ago
tron ae4a1f3675 (svn r3019) -Codechange: Replace explicit shifting/anding/oring with GB and SB 19 years ago
tron db3b1228bf (svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them 19 years ago
Darkvater a3d40a29fc (svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Fix warning in graph_gui.c with const problem
19 years ago
tron 0cc45ecd8e (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts) 19 years ago
tron ed8c9c91d6 (svn r3001) s/Player*/const Player*/
s/byte/PlayerID/
s/int/PlayerID/
and related changes
19 years ago
peter1138 fbf06041ca (svn r2990) Remove _engine_original_sprites and replace all uses with references to our (new) original engine/vehicle tables. 19 years ago
peter1138 2314431a59 (svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data. 19 years ago
peter1138 c02b1d555d (svn r2982) Newgrf: Added patch option for wagon speed limits. This is enabled by default. 19 years ago
hackykid d5d8d29c9f (svn r2977) - CodeChange: [pbs] Use a check to see if a rail segment is a pbs segment, instead of letting the pathfinder determine this. 19 years ago
peter1138 4d8c903d62 (svn r2967) Fix: newgrf: Wagon speed limits don't apply for wagons with livery overrides. Fixes max speed in dbsetxl etc. 19 years ago
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
19 years ago
Darkvater 2131f68ae2 (svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
- Add IsLocalPlayer() which substitutes _local_player == _current_player
19 years ago
tron b45aeb5c36 (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
ludde 29564f9fcf (svn r2781) Fix some of the issues with variables in .h files. 19 years ago
bjarni 546c34f2e5 (svn r2764) -Feature: Clone vehicles
-This allows a player to clone an excisting vehicle of his own
  -[fix]: this uncovered an excisting bug in CmdBuildRailVehicle() where depots could build trains of the wrong track type. This is fixed
  -Thanks to Celestar for drawing the sprites and _luca_ for including them in openttd.grf
19 years ago
celestar 21ed40bc53 (svn r2732) -Codechange: Cleaned the order flags some more. Hit some inconsistencies while trying to locate bug 1244167 19 years ago
tron a227065ab7 (svn r2701) Insert Id tags into all source files 19 years ago
tron 23c20173b1 (svn r2696) Remove stray semicolons 19 years ago
hackykid aa29ee6eda (svn r2674) - CodeChange: [pbs] Generalise the PSBISPbsDepot function so it can check if an arbitrary junction is a pbs junction. Preparations for making pbs more safe. 19 years ago
tron 559babcdc9 (svn r2673) Include functions.h directly, not globally via openttd.h 19 years ago
tron d71788c402 (svn r2660) Get rid of some more shifting/anding/casting 19 years ago
tron ac66e3e28f (svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read 19 years ago
Darkvater 2379c59ab8 (svn r2645) Fix (useless)warning in graph_gui and add brackets around HASBIT in an if statement 19 years ago
ludde 3e97dda275 (svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
- Benchmark shows that NTP is now around 10x faster than NPF.
  - Made IsTunnelTile macro to determine if a tile is a tunnel.
  - Added some useful debugging functions for making tiles red / getting accurate timestamps.
  - Remove old depot finding algorithm.
  - Disable warning for signed/unsigned comparisons.
19 years ago
hackykid 1d11bbb34d (svn r2625) - Fix: [pbs] Store the end of a train's reserved path explicitly. Prevents trains from unreserving eachothers paths in some cases.
- CodeChange: Use the TrackdirToTrack function instead of &7, and remove an unneeded variable.
19 years ago
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. 19 years ago
ludde f523be81d4 (svn r2553) - Fix: [pathfinding] Remove old-old train pathfinder. Enhanced old pathfinder.
- Penalties for red signals and for slopes. 
  - Increased the search depth to work better with large train networks.
19 years ago
celestar b45eee3157 (svn r2541) -Feature: Modified IsCompatibleRail so that an engine can move on more
than one railtype (like Diesel engines on electrified rail).
-Codechange: Use IsCompatibleRail where it should be used
19 years ago
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.
19 years ago
matthijs fb8e5f61b1 (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
- Codechange: [NPF] Check the railtype along a route against the engine type instead of against the previouse tile. This clears the way for electriefied rails.
- Add: [NPF] [ 1209644 ] A penalty for crossings (peter1138)
19 years ago
tron b64c9b8b1f (svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies 19 years ago
tron ab7b8b50e3 (svn r2492) Remove some pointless casts and fix some nearby indentation 19 years ago
tron 61f6f07edd (svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY 19 years ago
tron 3154e7148d (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile" 19 years ago
celestar 56f3bc9e69 (svn r2475) -Fix: [ 1214982 & 1217473 ] realistic acceleration problem. (glx) 19 years ago
hackykid e2df1d71d5 (svn r2467) - Fix: [newgrf] Prevent trains with shorter wagons breaking apart when reversing in some cases. (Therax) 19 years ago
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.
19 years ago
celestar 9b8cb17831 (svn r2441) -Feature: You can now give transfer order to set up feeder systems 19 years ago
hackykid 85fae22fa8 (svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
- Fix: [newgrf] Too short wagons could break the 'follow next vehicle' code used in the traincontroller. Clamp better to prevent this.
19 years ago
Darkvater 0171aae109 (svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138) 19 years ago
tron fa8f46c0b7 (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[] 19 years ago
hackykid d0cdb45b6c (svn r2431) - Fix: [newgrf] clamp() instead of assert() on the result of the vehicle length calculation, as it can depend on external input. (thanks tron) 19 years ago
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)
19 years ago
hackykid 4184611d3a (svn r2427) - Fix: CmdMoveRailVehice; Prevent possible assertion failure when moving vehicles within one chain. 19 years ago
hackykid 2d19785e43 (svn r2423) - CodeChange: Include first_engine in the train cache, instead of calculating it all over the place.
- Fix: Also recalculate the train cache values for 'wagon chains' (in the depot without an engine), to avoid possible desyncs later.
 - Fix: Make CmdMoveRailVehicle update the caches of the correct trains in all cases.
19 years ago
hackykid 2fbb96bfa5 (svn r2415) - Fix: [newgrf] Powered Wagons - Don't assume an undefined callback will fail. 19 years ago
hackykid 1018d3b786 (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it. 19 years ago
hackykid eb173099e9 (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
- Fix: Station ratings now depends on the max speed of a consist, without being affected by other speed limits from realistic acceleration.
19 years ago
tron 0c4ecbe9ec (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner 19 years ago
hackykid ad2eef0a30 (svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct. 19 years ago
Darkvater b438b1248c (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files. 19 years ago
hackykid 351d7aaa9f (svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
- Feature: [newgrf] Implement the 'refit capacity' callback.
19 years ago
hackykid d1c1a7cba7 (svn r2388) - Fix: [realistic accel] Very slow trains no longer get an increase in maximum speed when part of them is in a depot. 19 years ago
hackykid d90948abb7 (svn r2365) - Change: [refitting] Make refitting capacities for trains newgrf compatible. Train vehicles can now carry twice as much mail/goods as other cargo, and four times as much passengers.
- Fix: [refitting] The refit window now shows the correct refit options for the entire consist. Only if at least one of the vehicles in the train can be refitted to a certain cargo, it is shown in the list.
 - Fix: [refitting] When refitting to a cargo which is already carried by some vehicles in the consist, the capacities of those vehicles are taken into account when calculating the new capacity of the train in the refit window.
19 years ago
Darkvater 9fb4b2ef55 (svn r2347) - Fix (regression): depot window did not get redrawn when a non-train-engine was sold. 19 years ago