Commit Graph

196 Commits

Author SHA1 Message Date
bjarni 00a08601c9 (svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
To do this, the player struct contains an array, that contains the count of each engine type that the player owns
   Those arrays are updated each time a vehicle is build or deleted and is calculated on load (it's not saved)
   It's possible to access the arrays outside of the autoreplace GUI, so feel free to read from them in other patches as well
2006-09-08 10:47:39 +00:00
bjarni 347a3f9a43 (svn r6418) -Fix: [autoreplace] now multiheaded engines and other locomotives consisting of more than one unit will only be counted once
This also cleaned up the counting loop alot and it will also (hopefully) be faster (didn't benchmark it)
2006-09-07 15:00:47 +00:00
rubidium 63687763e9 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
-Cleanup: whitespace alignment of a few tables.
2006-09-04 20:40:33 +00:00
Darkvater 56d06ba0a7 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'. 2006-09-04 15:44:28 +00:00
Darkvater b7f36808ac (svn r6378) -Codechange: Rename VLW_FLAGS to VLW_MASK as it is a mask 2006-09-04 15:16:58 +00:00
Darkvater a40d6951d1 (svn r6377) -Codechange: Set up the widgets in the WE_CREATE instead of on every WE_PAINT
-Codechange: Initialize sorting-type on WE_CREATE instead of checking every time.
-Codechange: Update custom vehiclelist_d with standard list_d struct, more static
2006-09-04 15:13:49 +00:00
Darkvater 794cc6d55e (svn r6372) -Codechange: static, unneeded decleration in headers, superfluous header includes
-Codechange: Unify the Sorting struct both for vehicle-lists and network-lists.
2006-09-03 23:27:38 +00:00
bjarni e42d819b6a (svn r6370) -Codechange: moved all the remaining setup for PlayerVehWndProc() into WE_CREATE 2006-09-03 23:14:39 +00:00
bjarni 0fc0586bbf (svn r6350) -Codechange: moved some setup stuff into WE_CREATE in PlayerVehWndProc()
This is possible now that the window number is known when running WE_CREATE and it's a nicer solution
2006-09-02 21:16:46 +00:00
bjarni d7e1d08d53 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
-Codechange: unified the code for mass goto depot to avoid duplicated code
-Fix: Vehicles already on the way to depots will not be cancelled by mass goto depot (made it really hard to send all vehicles at once)
2006-09-01 10:24:15 +00:00
bjarni 3235b7407f (svn r6283) -Code cleanup: fixed wrong indent in PlayerVehWndProc() 2006-08-31 18:33:05 +00:00
bjarni 3367b2a95b (svn r6282) -Codechange: made a function to create the vehicle list for vehicle list windows
this list is also used by mass goto depot to ensure that they use the same vehicles
	right now only the list of all vehicles use this for goto depot, but eventually all the types will use this
2006-08-31 17:42:27 +00:00
tron 78f9d19d2d (svn r6271) Remove stale comment 2006-08-31 13:37:25 +00:00
tron 659e09e5bc (svn r6270) Remove the "unsorted" vehicle sorter, because it's plain useless 2006-08-31 13:33:25 +00:00
bjarni 68e0703226 (svn r6269) -Fix r6240: fixed incorrect row count in vehicle lists when resizing to smaller windows (AsterixMG) 2006-08-31 13:28:59 +00:00
bjarni c3900434b5 (svn r6261) -Fix r6246: fixed sprite related crash related to other player's vehicle list windows (spotted by Darkvater) 2006-08-31 09:40:10 +00:00
bjarni 7922c9ff84 (svn r6249) -Fix: fixed assert when pressing goto depot in an empty list (forgot to disable the button in this condition)
-Code cleanup r6246: simplified SendAllVehiclesToDepot() and moved an { in PlayerVehWndProc()
2006-08-30 23:01:45 +00:00
bjarni 744840c3da (svn r6246) -Feature: added the many times requested "send all vehicle to depot" button
it's located in the vehicle list screen and does the same as in the shared orders window (send all vehicles in list to a depot)
	it will still not inform the player if a vehicle failed to find a depot, so don't take for granted that all of them go
2006-08-30 21:39:01 +00:00
bjarni 1983c07955 (svn r6243) -Codechange: made SortVehicleList() static as well since that one is not used in any other files either (Thanks Tron for pointing this out) 2006-08-30 19:49:46 +00:00
bjarni 2a07ed9d46 (svn r6242) -Codechange: made BuildVehicleList static as it is not used in any other files anymore
added window_type to arguments and used it to replace an if cascade with a switch case
2006-08-30 19:42:20 +00:00
bjarni 8f102334ff (svn r6241) -Fix r6240: missed altering one line in last commit 2006-08-30 19:10:12 +00:00
bjarni ced2972c74 (svn r6240) -Code cleanup: in PlayerVehWndProc: replaced size_of_row with w->resize.step_height
it was only used twice, so there was no reason to calculate it for each event
2006-08-30 18:35:02 +00:00
bjarni 6cc29d5daf (svn r6239) -Code cleanup: cleaned up PlayerVehWndProc
code to delete an empty shared orders list is now much simpler
	cleaned up the code to handle button clicks
	fixed an assert if widget 9 was pressed on a list with vehicles for another company
2006-08-30 16:32:00 +00:00
bjarni 15f9208302 (svn r6229) -Feature: Shared order lists now got a "goto depot" button
this will try to send all vehicles in the list to depots/hangars
	currently if one fails to find a depot, it will not tell the player
2006-08-29 23:39:57 +00:00
bjarni b85a5d8cc8 (svn r6228) -Fix: redrawing an empty list of shared vehicles will now close the window
Since the order is no more, the player will not need that particular window anymore
	this could happen if the player opened the window and then sold all the vehicles (or crashed them)
	A crash could happen if a new order gets the same (now freed) OrderID and the vehicle using it is not of the same type as the window expect
2006-08-29 22:47:38 +00:00
bjarni a73b07561e (svn r6227) -Codechange: added window type flags to use with PlayerVehWndProc
this makes the list type detection much easier and allowed an if cascade to be turned into a switch case
	this also makes it easier to add more list types
2006-08-29 21:36:39 +00:00
bjarni 92582f0960 (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
Those 4 unified functions were really much alike, so there was no reason to have so much dublicated code
2006-08-29 17:41:13 +00:00
rubidium 27cee58ab8 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc. 2006-08-28 18:53:03 +00:00
rubidium bee83fb3e4 (svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments. 2006-08-28 10:14:37 +00:00
bjarni 27534b3521 (svn r6167) -Code cleanup r6161: replaced some uint16 with OrderID and (1 << 8) with SHARE_FLAG 2006-08-27 09:55:54 +00:00
bjarni d576f799d5 (svn r6161) -Feature: List of vehicles with the same shared orders
the list is available in the orders window and looks like the list buttons from the station windows (small vehicle)
   The button is disabled if the vehicle do not have any shared orders or it got shared orders, but an empty order list
   based on a patch by nycom, thought it ended up getting heavily modified
   Thanks to TrueLight for proofreading and suggestions
2006-08-26 22:28:40 +00:00
truelight db8dfcd6e9 (svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
-Codechange: introduced DestinationID, which is in fact an union of several types
  Used in Order struct, so no longer StationID is abused for all targets.
  Hangars are a big exception, as they use a station-id with GOTO_DEPOT (go figure)
2006-08-26 16:34:03 +00:00
truelight 5fd9aeb12b (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
It isn't the best name, but we couldn't find any better.
  This unifies the pool-system even more.
2006-08-22 20:41:26 +00:00
rubidium 480af9c917 (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. 2006-08-22 14:38:37 +00:00
Darkvater b13a60db42 (svn r5910) Fix some more warnings on MSVC by using (void*) casts. Followup of r5907. 2006-08-15 09:28:27 +00:00
tron 4ad8d1c7a2 (svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts 2006-08-15 07:07:17 +00:00
tron c16d77874e (svn r5895) Remove dead code 2006-08-14 20:37:15 +00:00
tron ba14683912 (svn r5894) Remove a totally unnecessary indirection in the vehicle sorter code. Less code, less data, simply better 2006-08-14 20:25:29 +00:00
rubidium 243872b4fd (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
-Cleanup: fix whitespace related coding style issues in date.[ch]
-Cleanup: make original comments doxygen compatible and remove/change outdated comments
2006-08-14 14:21:15 +00:00
peter1138 e0d8223355 (svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships. 2006-08-09 21:02:06 +00:00
tron 6302469aa8 (svn r5399) Simplify a conditional expression: (a && b) || (!a && !b) -> a == b 2006-06-28 06:21:03 +00:00
tron d2f6cb9e2d (svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers 2006-06-14 11:05:30 +00:00
peter1138 efd0d2d2b7 (svn r4561) - NewGRF: implement most of callback 0x23: additional text in vehicle purchase windows. 2006-04-23 22:33:10 +00:00
peter1138 4fcd2f0643 (svn r4343) [Autoreplace] Fix drawing of train list for outdated engines. Fixes FS#106 2006-04-10 11:14:33 +00:00
peter1138 2039471d3c (svn r4229) [elrail & autoreplace] Always show compatible rail vehicles in the left list, and only the selected rail type in the right list, to
allow converting electric engines to non-electric.
2006-04-01 15:19:16 +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
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
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
tron 480ce3d931 (svn r3610) And one more (see r3608/r3609) 2006-02-17 16:42:08 +00:00
tron 04d350aa9a (svn r3609) Some more simplification in the same function as r3608 2006-02-17 16:39:24 +00:00
tron 6cde2661c5 (svn r3608) No functional change, just make some code more comprehensible: Reduce variable scope, remove write-only variables, turn do-while-loops with multiple induction variables into canonical for-loops 2006-02-17 16:24:56 +00:00
peter1138 fe7267ca91 (svn r3605) - Remove silly macro and fix indenting in DrawVehicleRefitWindow() 2006-02-14 09:31:05 +00:00
tron 453b30e387 (svn r3564) Several smaller changes:
- Don't treat non-booleans as booleans
- Reduce variable scope
- Bracing
- Use DeMorgan's law to make conditionals easier to read
- if cascade -> switch
- Replace some magic numbers by symbolic names
- Avoid assignments within other statements
2006-02-06 09:18:04 +00:00
peter1138 500a7e6627 (svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list) 2006-02-04 21:48:46 +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
peter1138 6dd2affaad (svn r3528) - Feature: Allow sorting of vehicle lists by model or value (based on meush's work) 2006-02-03 18:32:59 +00:00
peter1138 b88904f345 (svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files. 2006-02-03 12:55:21 +00:00
tron 22dc05faf2 (svn r3510) Fiddle with whitespace and parentheses 2006-02-01 06:32:03 +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
tron 5ac1a89f92 (svn r3366) Make an unnecessarily global variable local 2006-01-05 16:51:10 +00:00
peter1138 eeeebf9f6d (svn r3359) - Autoreplace GUI: When starting or stopping a replacement, redraw the replace window after the command has completed, rather than after calling the command. 2006-01-02 19:55:09 +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
tron bf98086de8 (svn r3298) Remove unused and write-only variables 2005-12-14 06:28:48 +00:00
peter1138 560a4a9c4a (svn r3292) - Autoreplace: Disallow replacing to an engine type that already has a replacement set up; this stops loops being set up. 2005-12-13 12:31:48 +00:00
peter1138 04f39ef749 (svn r3291) - Codechange, Autoreplace: Replace int with EngineID and -1 with INVALID_ENGINE, as appropriate. 2005-12-13 09:57:07 +00:00
peter1138 1c57091230 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing. 2005-12-07 15:48:52 +00:00
peter1138 87f54ebf92 (svn r3239) - Codechange: Introduce and use helper functions for engine replacement code. 2005-11-26 16:41:14 +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 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 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
peter1138 328158395b (svn r3106) -Autoreplace feature: Continue to show old vehicles in replace window after all player's vehicles of that type have been replaced. This allows the replacement to be removed. These vehicles are shown in grey instead of the player's colour. 2005-10-30 21:35:48 +00:00
peter1138 b97473e874 (svn r3089) Fix possible issue with out-of-bounds array access in replace vehicle gui, and add brief commenting. 2005-10-25 19:52:25 +00:00
bjarni 7cace07e01 (svn r3082) made ChangeVehicleViewWindow() more readable (added in last commit) 2005-10-24 20:12:39 +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 f3de172560 (svn r3059) Use bitfields to encode railtype and climates of engines instead of manual shifting/anding 2005-10-18 11:23:58 +00:00
tron 66bf4f863d (svn r3049) Replace byte/int/uint by RailType where appropriate 2005-10-16 09:13:04 +00:00
tron ab657338ec (svn r3048) Replace 0/1/2 by RAILTYPE_RAIL/MONO/MAGLEV where appropriate 2005-10-16 07:58:15 +00:00
tron 0cc45ecd8e (svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts) 2005-10-01 12:43:34 +00:00
tron ff30404170 (svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1 2005-09-27 18:51:04 +00:00
tron c76f01b6ff (svn r2988) static where static is due 2005-09-26 13:38:12 +00:00
peter1138 9c2700b14c (svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
-Separate disabled and hidden masks in drop downs to support both hidden and disabled items.
2005-09-23 07:44:03 +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 74f0c8b55a (svn r2901) Refix 'replace window' with wrong string-etc. coordinates. Also clean up, and make window-title a bit more meaningful (specify vehicle type replaced) 2005-08-29 22:27:22 +00:00
Darkvater 7a184a0ea3 (svn r2880) Fix graphical glitch in replace window (text at wrong coordinates) 2005-08-20 21:16:46 +00:00
bjarni ed8e2bac04 (svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
-This means that one company can only have one setting for renew and replacing
    more clients will not fight due to different settings anymore
  -This is a needed step in the line to fix autoreplacing dualheaded locomotives
  NOTE: savegame revision bump (peter1138 + me in coop)
2005-08-06 16:07:22 +00:00
tron 747a0f6a55 (svn r2812) Move variables, which only vehicle_gui.c needs to know about, there 2005-08-05 20:22:06 +00:00
bjarni 6f74bbaeec (svn r2724) -Fix: [Autoreplace] made the pulldown menu read GetPlayer(_local_player)->avail_railtypes - this removes the need for updating this code if we add more railtypes and it also allows the menu to show maglev when monorail is not available 2005-07-27 10:11:45 +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
tron 0762aa9ec9 (svn r2669) Shuffle some more stuff around to reduce dependencies 2005-07-21 22:15:02 +00:00
tron e53c4db866 (svn r2664) Remove depedency on player.h from variables.h 2005-07-21 19:36:43 +00:00
tron fa8f46c0b7 (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[] 2005-06-07 18:13:49 +00:00
hackykid 0d926eee37 (svn r2429) - Fix: Oops, forgot to increase the size of the autoreplace window to fit the extra info from powered wagons. 2005-06-07 01:21:56 +00:00
hackykid 09aadafda1 (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
- Add: In the purchase details for trains display "(refittable)" after the capacity if the vehicle is refittable.
2005-06-05 23:01:10 +00:00
Darkvater b438b1248c (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files. 2005-06-02 19:30:21 +00:00
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.
2005-05-26 16:31:32 +00:00
Darkvater 5174d3adfe (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks" 2005-05-14 12:36:16 +00:00