Commit Graph

283 Commits

Author SHA1 Message Date
bjarni 246e53d206 (svn r4599) -Fix: [Cloning, autoreplace] FS#141 clone service-interval
now cloned vehicles get the same service interval as the original vehicle
	I applied this to autoreplace as well even though it's not mentioned in the bug report (autorenew should not alter service interval)
2006-04-27 23:11:43 +00:00
tron 18ad0ae50e (svn r4572) Remove vehicle_leave_tile_proc
There's exactly one implemented function (unbarring a level crossing) and one place where it can be triggered (a train leaves a level crossing)
It's a bit overkill, so just handle this one case where it can happen
2006-04-25 07:32:33 +00:00
tron c1dc517dab (svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE} 2006-04-23 19:35:36 +00:00
tron 0347fb2ab6 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums 2006-04-23 13:48:16 +00:00
peter1138 ae7ec5cd0d (svn r4471) - Pools: Add a facility for calling a custom function during pool block clean up. 2006-04-18 18:48:50 +00:00
tron 81e6d68f95 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
Remove DoCommandByTile(), because now it does the same as DoCommand()
2006-04-10 07:15:58 +00:00
celestar 6926bd55fd (svn r4341) -Fix (FS#101) When a player got bankrupt, slots were not cleared, because vehicles got deleted directly by DeleteVehicle 2006-04-09 18:35:24 +00:00
celestar 5931b34aff (svn r4259) -[multistop] Fix/Feature/Codechange:
1) Improved the road vehicle allocation (aka slotting) for multistop. Stops can now accept unlimited, er... 256, vehicles.
2) Removed the "wait for stop" feature, because it did not work in practise.
3) Slotting now ignores unreachable stations. Uses NPF at the moment because the old pathfinder cannot do it (yet)
4) Now matter how many vehicles approach a station, they will always be distributed evenly over existing stops.
5) Hopefully the last fundamental change to multistop
2006-04-03 14:25:32 +00:00
peter1138 9d5e052bbc (svn r4256) - Codechange: Replace lone map access in vehicle.c with its map accessor. 2006-04-03 12:41:31 +00:00
celestar cc87f682b9 (svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty 2006-04-03 09:07:21 +00:00
celestar 3aa1e38be6 (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE 2006-04-03 05:32:11 +00:00
bjarni 7c64aa4142 (svn r4228) -Fix: [autoreplace] allow replacement of wagons even when the engine fails to be replaced 2006-04-01 15:11:30 +00:00
peter1138 96288ee39a (svn r4227) - Fix: Wagon replace nows checks if the cargo types are the same before seeing if it can refit. 2006-04-01 14:53:38 +00:00
celestar 446493149c (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency 2006-03-31 19:10:54 +00:00
peter1138 cd0a67dc65 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness. 2006-03-31 12:59:43 +00:00
bjarni 0151ab0379 (svn r4159) added missing comments about refitting in CmdCloneVehicle 2006-03-29 20:57:17 +00:00
bjarni 0c64cecc66 (svn 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-03-29 20:41:15 +00:00
celestar a7d8ad0004 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas. 2006-03-29 16:30:26 +00:00
belugas 26a5b62865 (svn r4092) CodeChange : Named sprites instead of magic numbers plus create/use helper macro/enum for recoloring scheme 2006-03-24 18:16:39 +00:00
Darkvater d9ee10d3b8 (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
- Also add this capability to settings
2006-03-16 00:20:33 +00:00
tron 12d252d9bd (svn r3831) Add and use GetRailDepotDirection() 2006-03-12 16:13:16 +00:00
tron 929fae7b68 (svn r3816) Use existing accessors 2006-03-11 09:10:46 +00:00
bjarni 96641f462e (svn r3811) -Fix: [autoreplace]: (FS#67) autoreplacing trains now keep their tile length instead of their pixel length 2006-03-10 10:01:56 +00:00
peter1138 9c7f09322e (svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai) 2006-03-09 20:37:51 +00:00
tron 2181a72e9e (svn r3787) Use DirToDiagDir() instead of >> 1 2006-03-08 08:28:48 +00:00
tron ecabf8a5f0 (svn r3784) Add a type and functions to handle direction changes 2006-03-08 07:48:56 +00:00
tron fbe939b31f (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends 2006-03-08 06:55:33 +00:00
tron 4270026b42 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
This is used to delete
- all news about a vehicle, when it gets deleted
- "vehicle has stopped in depot" news, when it gets started
- "vehicle has invalid orders" news, when the orders get changed
2006-03-04 11:01:35 +00:00
tron 40fd4377b0 (svn r3747) Change HASBIT() to return 0/1 instead of 0/value of tested bit, because the name suggests it does the former and current behavior broke in some places in very subtle ways (for example HASBIT(x, 0) != HASBIT(y, 1) doesn't work, returning a bool after HASBIT(x, 9) neither) 2006-03-03 19:42:09 +00:00
peter1138 741fc26522 (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour. 2006-03-01 23:14:03 +00:00
peter1138 24217d5c8d (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions 2006-03-01 17:35:01 +00:00
Darkvater 45e85d2eb2 (svn r3627) - Change all hardcoded 255 max-saveload versions with the define SL_MAX_VERSION 2006-02-20 19:43:26 +00:00
peter1138 4f9ea7640a (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles. 2006-02-20 09:26:07 +00:00
Darkvater 4c8c1e8f6a (svn r3619) - Codechange: Simplify a NullStruct initialization in the vehicle array (merge the two together to avoid confusion) 2006-02-20 01:36:48 +00:00
truelight 0068f19605 (svn r3598) -Fix: suppress invalid warning by assigning value to variable 2006-02-13 21:47:02 +00:00
peter1138 efe76c22e6 (svn r3589) - Rename u.road.unk2 to u.road.blocked_ctr 2006-02-11 10:45:20 +00:00
peter1138 f4215cf6a0 (svn r3579) v->u.rail.first_engine holds an engine type, not a vehicle index, so use INVALID_ENGINE. 2006-02-08 19:06:46 +00:00
peter1138 2265915e6c (svn r3576) - Allow unused wagons have their ->first set. This fixes the faulty cache warning message, and noticably speeds up depot operations in large games. 2006-02-08 08:18:29 +00:00
peter1138 9dba135f79 (svn r3573) - Replace assert(0) with NOT_REACHED(). This commit sponsored by "giving Darkvater credit for the last three". 2006-02-07 19:11:51 +00:00
peter1138 59333131a5 (svn r3572) - 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. 2006-02-07 19:01:01 +00:00
peter1138 66fcdc5e6d (svn r3571) - 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. 2006-02-07 18:57:16 +00:00
bjarni 78b51cbec2 (svn r3535) -Feature: [autoreplace] allow autoreplacing of train wagons
currently ALL available wagons are displayed in the right menu in the replace window
	however the replacement will only be done if the new wagon can be refitted to carry same cargo as the old one is currently carrying

	Since the standard vehicles do not have any valid wagon replacements, this feature can only be used when using newgrf sets
2006-02-04 18:25:07 +00:00
tron 84fb96fe85 (svn r3511) More whitespace ([FS#46] by Rubidium) 2006-02-01 07:36:15 +00:00
tron 22dc05faf2 (svn r3510) Fiddle with whitespace and parentheses 2006-02-01 06:32:03 +00:00
tron 4e2bb34be3 (svn r3498) Fix the edge case for r3419/r3488: when a vehicle just enters a tile, the height difference can be 8 2006-01-31 19:06:02 +00:00
tron 7d03773383 (svn r3488) Simplify the check in r3419 2006-01-30 16:57:47 +00:00
Darkvater e6d16d17dc (svn r3482) - Fix: since multiheaded links are not saved anymore do NOT save them anymore at all, return the extra space. Since Bjarni's fix for this was abominable, the weird situation arises of 2 NULL structs of free space, of which the first isn't usable. 2006-01-29 22:40:51 +00:00
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 188352ea3e (svn r3419) - Fix: [FS#40] (Possible) game crash on removing track/road under bridge. This was caused by a wrong tile-occupancy testing where it was assumed that a vehicle's height is only a multitude of 8 (a single height-difference). This is incorrect as a vehicle on a slope will assume all height levels between the lower-and upper-bounds. The crash is still possible as seen in the Flyspray bugreport but this has a different cause. 2006-01-22 17:17:11 +00:00
bjarni e35a131153 (svn r3403) -Codechange: [multiheaded engines] the references between the front and rear engines are no longer saved
instead the pointers are generated on load
2006-01-18 15:05:01 +00:00
peter1138 90aff7a026 (svn r3396) - Autoreplace changes:
- Change fixed array per player to a single pool. This avoids future problems
    with vehicle numbers and decreases savegame size. Engine replacements from
    previous savegames will be lost.
  - Move engine replacement code from players.c to engine.c.
                                      (thanks to blathijs for rewriting this)
2006-01-12 15:52:18 +00:00
bjarni 4bf1741783 (svn r3390) -Fix: [autoreplace] fixed issue where autoreplace failed to attach the cars if the front engine was replaced
and the front engine was multiheaded and the first vehicle after it was the rear part of that engine
2006-01-08 12:20:13 +00:00
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
2006-01-05 21:35:54 +00:00
tron e272b03fee (svn r3365) Staticise 36 functions 2006-01-05 12:40:50 +00:00
peter1138 4b464093e7 (svn r3362) Fix issue with loading old (TTD) savegames:
- move call to convert from old to new train subtypes.
 - ensure AI is started for AI players.
2006-01-04 20:18:39 +00:00
peter1138 911a8aa08d (svn r3361) - Clone Vehicle: Disallow cloning of crashed rail vehicles after starting removal process. 2006-01-04 16:53:00 +00:00
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 2005-12-29 12:42:59 +00:00
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. 2005-12-28 22:29:59 +00:00
tron fa78c057ee (svn r3339) Remove unnecessary includes 2005-12-24 20:54:31 +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 414481cdd8 (svn r3261) - Autoreplace: If a replaced vehicle had a custom name, transfer it to the new vehicle. Fixes "[ 1370039 ] Autoreplaced vehicles lose their names" 2005-12-05 16:48:07 +00:00
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. 2005-11-29 22:29:59 +00:00
peter1138 87f54ebf92 (svn r3239) - Codechange: Introduce and use helper functions for engine replacement code. 2005-11-26 16:41:14 +00:00
truelight 4845ff063b (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version. 2005-11-22 19:33:29 +00:00
bjarni c7f3192f6b (svn r3223) -Fix: [autoreplace] fixed crash when replacing a train engine without any cars (introduced in r3220) 2005-11-19 22:39:16 +00:00
bjarni 24eda23b80 (svn r3220) -Fix: [autoreplace] Autoreplaced trains now replace their cargo to the train instead of just the new engine
This applies to wagon removal during autoreplace too
2005-11-19 10:28:02 +00:00
bjarni e472fed85a (svn r3219) -Codechange: removed the now obsolite code in the build train command to make half multiheaded engines 2005-11-19 00:10:20 +00:00
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
2005-11-18 23:41:03 +00:00
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 2005-11-16 14:07:34 +00:00
tron 62b2b4613f (svn r3193) Staticise the vehicle position hash 2005-11-16 11:50:40 +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 833032adc0 (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT 2005-11-14 08:09:57 +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
tron ee15e3de13 (svn r3172) static, const 2005-11-13 13:43:55 +00:00
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
2005-11-07 23:20:47 +00:00
peter1138 bc25cd89bf (svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes. 2005-11-06 13:42:26 +00:00
bjarni b6d1f81635 (svn r3143) -Codechange: greatly increased speed when allocating vehicles
This increases the speed greatly when allocating more than one at a time
        (planes, artic engines, cloning...) and when adding another block of 
        vehicles to the vehicle pool (adding 512 vehicles each time)
2005-11-05 19:58:16 +00:00
peter1138 267314b4d0 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders. 2005-11-05 16:07:26 +00:00
bjarni d86829d0e0 (svn r3138) -Fix: [clone vehicles] fixed assert when it was possible to allocate some vehicles to clone a train, but not for all cars
Now it gives "too many vehicles" error message instead
	To make this work, AllocateVehicles() needed to be moved to vehicle.c (from aircraft_cmd.c) and made non-static
2005-11-05 14:01:00 +00:00
bjarni 7d4d13df35 (svn r3137) -Fix: [autoreplace] fixed assert that was triggerable when a vehicle entered a depot even though the goto depot was canceled
this assert could be reached by clicking on the goto depot button to cancel goto depot from the orders and the vehicle
	still entered the depot. The flags in that case would not be "normal" anymore. An additional check is added to prevent this
2005-11-04 22:10:49 +00:00
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
2005-11-04 20:52:03 +00:00
bjarni ea720689a3 (svn r3129) -Fix: [autoreplace] fixed bug that made the player pay twice for autoreplacing and could end up with negative money
this is not the same bug as in rev 3128, which means you actually paid 3 times. Now it pays correctly
2005-11-03 21:22:38 +00:00
bjarni b950fee119 (svn r3128) -Fix: [autoreplace] fixed bug that made the player pay twice for autoreplacing and could end up with negative money 2005-11-03 20:19:15 +00:00
bjarni 80af1ebca8 (svn r3127) -Fix: [autoreplace] fixed a condition where a vehicle could fail to stop when autoreplacing
this would result in the construction of a new vehicle while the old one just continued
	added an assert to make sure it's always stopped before trying to sell the old vehicle
2005-11-03 19:51:28 +00:00
bjarni 59913ae719 (svn r3116) -Fix: [autoreplace] fixed issue where autorenewing/autoreplacing a plane could lock up an airport
this will not fix already locked up airports
        this bug was introduced in rev 3111
2005-11-01 17:20:06 +00:00
bjarni 35217570a9 (svn r3112) -Feature: [autoreplace] profit counters are now remembered too (request by Darkvater) 2005-10-31 14:30:45 +00:00
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)
2005-10-31 12:59:47 +00:00
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()
2005-10-29 21:54:28 +00:00
bjarni 76f4c5b6f9 (svn r3100) -Codechange [Clone vehicles] Major change to clone vehicles
removed duplicated code and added DoCommand, which used the define build commands added with autoreplace
	This should not affect gameplay at all
2005-10-29 20:58:26 +00:00
bjarni 1cc5379706 (svn r3093) -Fix: [autoreplace] fixed issue where the money limit message showed up in some cases when no replace was needed 2005-10-27 19:30:40 +00:00
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
2005-10-24 19:40:48 +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 3397e202c8 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants 2005-10-07 07:35:15 +00:00
tron ce1c72cf6e (svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate 2005-09-28 19:35:36 +00:00
peter1138 5f3bb18eb7 (svn r2993) Fix: Reset aircraft images differently. Fixes assertion introduced in r2991. 2005-09-27 19:16:37 +00:00
peter1138 50f1a93664 (svn r2991) Reset vehicle images on game load. Allows savegames with NewGRFs saved prior to r2868 to load. 2005-09-26 20:32:13 +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
bjarni 864cb3fa11 (svn r2912) -Fix: [autorenew]: fixed issue where autorenewed vehicles didn't get all stats updated (peter1138) 2005-09-03 19:22:56 +00:00