Commit Graph

68 Commits

Author SHA1 Message Date
tron e272b03fee (svn r3365) Staticise 36 functions 2006-01-05 12:40:50 +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 b06b3e2ca2 (svn r3313) Remove GPMI related changes from trunk
Revisions in detail: 2542, 3226 (partial), 3229, 3231, 3232, 3238, 3242-3245, 3251, 3253, 3260, 3263, 3265, 3266, 3269, 3277, 3278, 3279, 3283 (partial), 3304, 3305, 3306
2005-12-18 12:10:46 +00:00
truelight 531073bea0 (svn r3305) -Rename: Changed all instances of ottd_ related to the AI to ttai_ 2005-12-14 15:54:23 +00:00
truelight 8733f49e88 (svn r3232) -Add: implemented the event-system for AIs
-Add: added several hooks (event-callbacks) for road-related-stuff
2005-11-23 15:08:29 +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
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 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 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
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
Darkvater c930f8f8c0 (svn r2959) - Fix: [ 1266036 ] Fix [ 1236317 ] Vehicles with and TRANSFER order don't have that order restored (i_dachev). Also disallow non-train type vehicles to have non-stop orders. 2005-09-16 16:03:18 +00:00
tron 03e860d06d (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c 2005-08-06 17:40:21 +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 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
ludde 718307ffa4 (svn r2599) Fix: Road vehicle multistop handling used NPF even if NPF was off????
- Also simplified/optimized the code.
 - Now it uses manhattan distance as an approximation instead of actual distance to find the distance. Much faster.
2005-07-17 12:29:33 +00:00
celestar 9b8cb17831 (svn r2441) -Feature: You can now give transfer order to set up feeder systems 2005-06-15 16:58:15 +00:00
Darkvater b438b1248c (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files. 2005-06-02 19:30:21 +00:00
hackykid f7dcd2e834 (svn r2390) - Codechange: Fix some warnings on GCC 4.0.0 2005-06-01 11:52:44 +00:00
Darkvater 55423efb06 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
- Fix: also fix an unnoticed error in SlSaveLoadConv() due to wrong types.
2005-05-30 22:16:05 +00:00
tron fea5965679 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes. 2005-05-15 18:50:55 +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 921cc4e94a (svn r2297) - CodeChange: server-check the next batch of commands.
- CodeChange: since only the server will be able to modify difficulty settings, leave the checking of correct values besides, and trust users will join legit servers.
- CodeChange: for renaming signs, only check if GetDParam(); eg _decode_parameters is empty ('\0') or not, instead of the extra check of players, etc. That basically does the same thing. Also dirty sign two times when renaming, once before, once after the action. Because if the name becomes shorter and you update only after, garbage remains on the screen.
- CodeChange: made GetMaskOfTownActions() available to the town-cmd to double-check if the action was available to the player. For this purpose the hardcoded _local_player has been removed from the function and is now passed as a parameter.
2005-05-12 00:11:37 +00:00
Darkvater aa4f2d2db2 (svn r2293) - Fix (regression): You couldn't modify commands anymore; fixed. (|| and && are kinda confusing with !=) :P 2005-05-11 15:31:10 +00:00
Darkvater 5e6923e936 (svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
- CodeChange: To correctly accept engine-prototypes, the best-player checking has been moved to its own function, I hope it functions the same as before.
- CodeChange: Added symbolic types of PlayerID, OrderID and EngineID. For engines also added GetEngine() and IsEngineIndex(), similar to the other such functions.
- CodeChange: To correctly build industries, some tables have been moved to build_industry.h. The only way to find out currently if an industry is valid in a climate is by looping all industries and checking if it matches. Also to comply with the patch setting build_rawmaterial_industries, it is assumed that these industries do not accept any cargo of any type. This can and probably should changed in the future to some flag in their struct. Also use _opt_ptr instead of _opt.
- CodeChange: implemented the HQ checking code inspired by MarkR2 in "[ 1190944 ] Many commands not checked for security".  Unfortunately it is impossible to prevent only deleting a HQ by a modified client atm.
- CodeChange: For insert order and modify order their parameters are implicitely truncated to 8 bits, instead of the 16 bits said in the comments.
2005-05-11 00:00:27 +00:00
matthijs 95c040b723 (svn r2264) - Fix: [ 1060686 1187655 ] Changing the full-load flag on the current order doesn't take effect immediately. (glx) 2005-05-03 22:18:40 +00:00
matthijs 6eb094c726 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
- Add: GetVehicleTrackdir() helper function.
- Codechange: Moved SortStruct from vehicle_gui.h to ttd.h, so the dependency from vehicle.h on vehicle_gui.h could be removed.
- Codechange: Typedeffed the VehicleTypes struct so it can be used as the type for Vehicle.type instead of "byte".
- Codechange: Removed prototype for VehicleSorter(), which had no implementation anymore and was never called.
2005-05-02 23:59:11 +00:00
matthijs 2ab5eee78b (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
Buoys will now try to get within 3 tiles of a buoy instead of a the actual buoy tile. This gets ships to got past buoys in a realistic (IMO) way instead of barging right through them.
- Fix: [NPF] Trains get curves penalties sometimes even when the track is straight.
- Add: [NPF] Ships get a penalty for going over buoys now, so they will try to go around.
- Add: [NPF] Ships get a penalty for curves too, yay for straight lines.
- Add: TrackdirToTrack(), TrackToTrackdir(), IsDiagonalTrack() and IsDiagonalTrackdir() helper functions.
- Add: IsBuoy() and IsBuoyTile() helper functions.
- Codechange: Rearranged part of the control flow of ShipController(), removing a goto.
2005-05-02 22:13:20 +00:00
Darkvater cdb896b790 (svn r2237) - Fix (regression): [ 1192284 ] Bug: Ship refuses to add buoy to its orders (init100) 2005-04-30 10:49:47 +00:00
tron 6ceeedfd3c (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
- Check if the vehicle exists
- Check if the vehicle belongs to the correct player
- Check if the new order is valid (type, destination, flags) (CmdInsertOrder)
2005-04-22 05:41:09 +00:00
Darkvater 2397ff86e6 (svn r2184) - CodeChange: remove the copy of ClearSlot(), which is now also called for CmdSkipOrder(). This also fixes the involuntary crash introduced 2 revisions ago 2005-04-11 20:54:25 +00:00
Darkvater e82f724e9a (svn r2178) Postprevcommitaddendum: add debug.h if you use DEBUG() 2005-04-10 21:54:29 +00:00
Darkvater 9876fb54bd (svn r2177) - Fix: Fix a slot desync with setting the invalid slot to the correct value 2005-04-10 21:51:11 +00:00
truelight 020c1e9b6c (svn r1818) -Add: Dynamic orders (up to 64k orders) 2005-02-06 10:24:57 +00:00
celestar 0ec4ee5963 (svn r1801) -Fix [Multistop] Fixed a crash that occured when copying orders due to not checking a pointer to be non-NULL 2005-02-05 15:05:52 +00:00
truelight ab3ed5c431 (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
(and should be an uint16, not uint8)
2005-02-02 16:16:43 +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
celestar 752b3f0dd6 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
a single station.
Thanks to: Truelight for the saveload code, Darkvater and Hackykid for
network testing and Tron for proof-reading 1500 lines of diff.
2005-01-29 19:41:44 +00:00
truelight bb276ef5a9 (svn r1612) -Fix: made sure that ->next pointers are set to NULL 2005-01-23 13:30:02 +00:00
truelight 8fe9bc6439 (svn r1607) -Fix: When deleting an order, the next pointer was not cleared,
resulting in some unusual behavoir from time to time
2005-01-23 11:37:27 +00:00
tron 189ca73707 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile 2005-01-22 20:23:18 +00:00
Celestar 5bcf3d2bc0 (svn r1556) -Fix: Vehicle list updates should now really work 2005-01-18 09:35:31 +00:00
celestar e0471187d0 (svn r1554) -Fix: [ 1103187 ] Order Check messages are now validated before
displayed, so that there are no stray error messages any more.
-Feature/Fix: Order Checking is only execute for ONE vehicle in an
order-share system
2005-01-17 21:54:45 +00:00
truelight 8e404a26f6 (svn r1544) -Fix: SwapOrder did not use AssignOrder, which caused the saveroutine to
crash from time to time
-Codechange: added const before 'Order *' where possible
2005-01-16 14:42:53 +00:00
truelight d275109e79 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
-Codechange: renamed all 'schedule' stuff to 'order(list)'
-Codechange: moved all order-stuff to order_cmd.c / order.h
-Codechange: vehicles that share orders are now linked to eachother
  with next_shared/prev_shared in Vehicle

  Developers: please use AssignOrder to assign data to an order. If not, 
   you _WILL_ make the save-routine to assert!
2005-01-15 19:06:22 +00:00
celestar 02ed8410a2 (svn r1521) -Fix: Ship Vehicle Lists are now redrawn correctly
-Codechange: added some const to last commit
-Codechange: Ship and Aircraft lists are now update on order change, not
on new day
2005-01-15 09:28:08 +00:00
truelight 63e97754fb (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
(in prepare of dynamic arrays):
  - DEREF_XXX is changed into GetXXX
  - All direct call are directed via GetXXX
  - struct Industry has now an index-field
  - ENUM'd some stuff
  - Replaced home built loops with FOR_ALL_XXX
  - Added _stations_size, _vehicles_size, ... which gives the length of the
    array (which will be dynamic in the near future)
  - Changed lengtof(XXX) to _XXX_size (e.g. _stations_size)
  - Removed all endof(XXX) (because mostly it was part of a FOR_ALL_XXX)
  - Made the sort-functions of all 4 dynamic
  - Made all 4 Initialize functions more of the same
  - Some minor tab-fixing and stuff
  (tnx to Tron for proof-reading my 100kb patch ;))

  Note for all: please do NOT directly call _stations, _vehicles, _towns and
  _industries, but use the right wrapper to access them. Thank you.
  Ps: please also do not use 'v++', where v is of type Vehicle *.
2005-01-06 22:31:58 +00:00