Commit Graph

169 Commits

Author SHA1 Message Date
tron
4eebeff58c (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
b43331c931 (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
Darkvater
6d349b6284 (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
- CodeChange: changed the airport gui airport-type checking. Added function GetValidAirports() that returns bitmasked availibility, is also used for checking.
- CodeChange: to check tree-planting, 2 const arrays have been moved to table/tree_land.h (type and count)
- CodeChange: added IsTownIndex() in following of IsStationIndex(), etc.
- Fix (regression): road tunnels did not work anymore, forgot that their type was 0x200 (documented now)
2005-05-09 22:33:00 +00:00
Darkvater
84b0d2d19d (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
da1a7587af (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
419af5cece (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
af42781042 (svn r2278) When renaming a station, check if the station exists and belongs to the correct player 2005-05-07 08:14:06 +00:00
matthijs
ba733c005d (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
4e580d2ade (svn r2210) - Fix: When a road-station is deleted, also delete the assigned slots of all vehicles headed to that station. This fixes an assertion, thanks go to Tron for finding the cause. 2005-04-16 20:10:24 +00:00
tron
53d30138b2 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
This should prevent trains, which are longer than the station, to turn around without stopping under certain circumstances and fix speed limit for trains entering a station, when realistic accerlation is used
2005-04-12 10:31:26 +00:00
tron
8b1d334927 (svn r2176) Revise CheckOprhanedSlot():
- Don't assert the vehicle type, as it can be anything
- Don't touch the slot information of the vehicle, because it's possible that it is not a road vehicle anymore and even if it is, it has nothing to to with that slot
- Trim the debug printout, because the information about the vehicle is arbitrary
(Joint effort with Darkvater)
2005-04-10 20:48:43 +00:00
Darkvater
8f4583b161 (svn r2168) - Fix: Various stages of invisible trains, and wrong v->u.rail.track combinations. When a vehicle was sold its (possibly) assigned road slot for multislot was not cleared, thus resulting in a bug confusion. This should fix [ 1178520 ] Assertion failure in ai.c (invalid v->u.rail.track). With big thanks to TrueLight for the demo-recording patch, BJH for the wonderful savegame, Hackykid for his brilliant suggestions of the problem and Celestar for... ehm, making it all possible ;p 2005-04-08 22:44:06 +00:00
celestar
b505d1782f (svn r2097) -Codechange: [Multistop] Prettified the previous commit 2005-03-28 08:17:35 +00:00
celestar
b0aa584794 (svn r2096) -Codechange: [Multistop] Modfied some debug stuff 2005-03-28 08:12:21 +00:00
celestar
0cec257797 (svn r2055) -CodeChange: Begun introducting StationID 2005-03-25 10:40:58 +00:00
celestar
879513b1b2 (svn r2031) -Fix: Station #256 now gets cargo delivered as well 2005-03-19 23:17:59 +00:00
darkvater
d0ea6bcdf0 (svn r2011) - Fix: [ 1162209 ] Fix OS/2 build (orudge) #2 2005-03-15 12:21:59 +00:00
tron
ca3ccff729 (svn r1981) Typedef some structs and enums 2005-03-10 07:01:43 +00:00
tron
9d1526e0a4 (svn r1976) Cleanups - mostly indentation and fiddling with loops 2005-03-09 19:09:04 +00:00
Darkvater
5ee5ec1770 (svn r1961) - Fix: [ 1158618 ] Segmentation fault when loading savegame, out of bounds array check. 2005-03-08 17:32:34 +00:00
pasky
99499094a9 (svn r1958) GenerateStationName() tidyup. 2005-03-08 00:26:30 +00:00
tron
f126e6022c (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness) 2005-03-05 18:44:26 +00:00
tron
f5cb663ddf (svn r1927) Replace implementation of UpdateStationAcceptance(). The new one doesn't malloc() and calculates the station area in one pass instead of 3 2005-03-05 17:41:51 +00:00
tron
4099a85743 (svn r1921) -Fix: Out of bounds array access which caused oil rigs to accept other cargo types besides passengers and mail 2005-03-03 19:54:46 +00:00
celestar
3608788f6b (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/ 2005-02-13 21:51:47 +00:00
tron
830565514c (svn r1867) Include tables/sprites.h only in files which need it 2005-02-13 11:18:02 +00:00
tron
7d56d1d841 (svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters 2005-02-07 10:41:45 +00:00
tron
6984d6cd31 (svn r1832) Next byte -> char iteration: custom names 2005-02-06 20:53:31 +00:00
truelight
79d1ed2c66 (svn r1818) -Add: Dynamic orders (up to 64k orders) 2005-02-06 10:24:57 +00:00
truelight
bd7f37d592 (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
tron
36c9758c94 (svn r1803) Move debugging stuff into files of it's own 2005-02-05 15:58:59 +00:00
celestar
ff39c260f7 (svn r1799) -Codechange: [ Multistop ] Added debug class "ms" and more debugging
output for multistops
2005-02-05 12:10:09 +00:00
truelight
52ce9d21cc (svn r1789) -Fix: there is no need to save the index, it is done for us 2005-02-04 15:39:10 +00:00
truelight
d3aa3043e3 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops. 2005-02-04 15:31:30 +00:00
truelight
3eda5e61f7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations 2005-02-03 17:22:35 +00:00
truelight
0668a6b485 (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
tron
c51ed8465d (svn r1769) Don't compute the same value twice, remove one function call 2005-02-02 15:45:53 +00:00
matthijs
eb78cdb2d4 (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
bb680056b1 (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
337de948c1 (svn r1743) -Fix: Multistop: Added some debug output and made sure that orphaned slots are cleared. 2005-01-30 22:04:14 +00:00
celestar
9a3089b403 (svn r1735) -Fix: [ 1112285 ] Fixed an assertion error with stations where stops
were deleted, the assertions were just plain wrong at that place. Used a
more graceful handling. Todo: What happens if ALL stations in a schedule
have no suitable stop?
2005-01-30 17:46:57 +00:00
celestar
3c82a2b3c7 (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
tron
38587b60f7 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
This makes it necessary to rename TileType() to GetTileType() because a type and a function may not share the same name.
2005-01-29 15:12:40 +00:00
tron
39858e696b (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
celestar
558dcd8ee0 (svn r1694) -Fix: Forgot to remove a DEBUG statement :( 2005-01-27 11:25:32 +00:00
Celestar
0a531338e9 (svn r1693) -Fix: [ 1108618 ] A wrong error message was displayed when trying to
expand railroad stations beyond maximum spread
2005-01-27 09:43:24 +00:00
tron
07cb3068ae (svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
WARNING: If i made any mistake here it WILL lead to corrupted savegames!
2005-01-25 21:43:57 +00:00
tron
94d5aeabb2 (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
dominik
274b4f01ee (svn r1579) Fix: [ 1105963 ] Buoys can now only be removed if no ship has it in their schedule.
This makes buoys more useable in multiplayer games again, as buoys can't be deleted by other players if they are used.
2005-01-20 22:19:34 +00:00
bjarni
467e4b82bf (svn r1568) made an enum of train subtypes to make the code more readable 2005-01-19 19:15:03 +00:00
tron
90cafa9b15 (svn r1560) Introduce SetTileType() and SetTileHeight()
Replace direct references to _map_type_and_height with these
2005-01-18 18:41:56 +00:00
tron
61a6bc544d (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts 2005-01-16 11:24:58 +00:00
tron
58484ce6ee (svn r1533) Turn an if cascade into a switch and move a const array to the only location where it is used 2005-01-16 09:51:56 +00:00
truelight
7cafdf3b0b (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
tron
412cf98eb4 (svn r1512) Replace probably incorrect test of loading_count with probably correct test of loaded_count 2005-01-14 21:58:48 +00:00
darkvater
4734a0e690 (svn r1472) -Fix: correct error message for when trying to build a railroad station over a bus/truck/etc-station. 2005-01-10 21:52:35 +00:00
Celestar
91a75191a2 (svn r1467) Fixed a nasty bug where one could build one station OVER the other 2005-01-10 16:35:20 +00:00
celestar
e0a8b21404 (svn r1441) Fixed a couple of warnings, and removed a pointless assert 2005-01-09 10:04:30 +00:00
tron
414ac3286b (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY] 2005-01-07 17:02:43 +00:00
truelight
b450603437 (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
tron
d3c6855320 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff 2005-01-06 11:39:00 +00:00
tron
e4cf2ba1b3 (svn r1386) Move TileIndexDiff to map.h
Move _tileoffs_by_dir to map.[ch] and encapsulate it in TileOffsByDir()
2005-01-05 13:32:03 +00:00
darkvater
fc52b512aa (svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky. 2005-01-04 17:11:03 +00:00
tron
bcff0ab932 (svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY] 2005-01-03 18:59:58 +00:00
tron
181e9b6cf9 (svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
While here replace one erroneous TILE_MAX_X with MapMaxY()
2005-01-03 12:56:22 +00:00
tron
df1f0010f9 (svn r1328) Turn loop with explicit terminator element into loop using endof() 2005-01-03 08:33:04 +00:00
truelight
2f9e0b8e0c (svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
an uint8 till the savegame version is bumped to version 5. Then it works 
automaticly as a fully uint16. So _stations[] can not be increased till 
after the bump!!
2004-12-28 11:51:31 +00:00
darkvater
452db59121 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized 2004-12-21 23:27:58 +00:00
tron
e33a63ee8d (svn r1161) Don't make redundant GetAirport() calls, use the cached value 2004-12-18 18:19:49 +00:00
truelight
c2fd88b9b6 (svn r1153) -Fix: FindCatchmentRadius is now a function that uses the enums instead
of magic numbers (tnx to Stumo)
2004-12-18 13:38:27 +00:00
tron
0cdcb1d6c7 (svn r1151) Fix last commit |: 2004-12-18 12:46:29 +00:00
tron
11d477044c (svn r1150) Fixes:
- Don't crash when building or destroying airport without depots (bugs were latent before r1149)
- Delete all hangar windows when destroying an airport, not just the first one (before r1149 none where deleted)
2004-12-18 12:40:34 +00:00
tron
a148ff4e0d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h 2004-12-15 22:18:54 +00:00
Celestar
969d07925a (svn r1017) Solved a Segfault if a station was built too close to the northern corner 2004-12-11 12:12:51 +00:00
Celestar
945ceb06fc (svn r979) Allow more realistically sized catchment areas 2004-12-08 15:46:13 +00:00
tron
b8e83ca03f (svn r955) Replace uint16 for orders with struct Order
This adds no functionality, but is a stepping stone for future improvement (like 16bit order indices) and is easier to read.
This changes preserves binary compatibility wrt savegames.
2004-12-05 12:43:04 +00:00
truelight
d6a1f3e412 (svn r942) -Merged branch/network back into the trunk 2004-12-04 17:54:56 +00:00
tron
ecf1c35849 (svn r907) Sprinkle holy ANSI water:
- "inline" must before the return type (and after "static")
- Initialise all struct members, not just some of them
- Remove (one) spurious semicolon
2004-12-03 07:43:00 +00:00
tron
265ac67183 (svn r901) Small step in the process to clean up the DPARAM mess:
- reduce to 2 sizes (*DParam64 for 64bit values, *DParam for the rest)
- use inline functions instead of macros
- add assert()s to check for buffer overruns
2004-12-02 22:53:07 +00:00
tron
acbd1801c7 (svn r815) Include strings.h only in the files which need it.
This should reduce the compile time after altering english.txt by about 1/3, because "only" 62 instead of 90 .c files must be recompiled.
2004-11-25 10:47:30 +00:00
tron
fca55e3741 (svn r793) Merge INLINE -> inline replacement (revision 376) 2004-11-24 13:19:48 +00:00
tron
e8537f5512 (svn r787) Invert the sense of the DO_TRANS_BUILDINGS flag to be consistent with its own name and all other DO_* flags.
Now it is active-true.
2004-11-23 22:36:11 +00:00
tron
c5b0ecac4f (svn r780) Always report a bus/lorry station as unpassable.
The current behavior just causes bugs and the pathfinder does the necessary magic to handle stations as destinations and enter them anyway.
This fixes [ 1058809 ]
2004-11-23 18:04:04 +00:00
tron
57adc97733 (svn r724) Remove restriction that a tile can only accept 3 cargo types.
This especially enables houses to accept passengers, mail, goods AND food.
Add string templates for up to 5 cargo types for the tile info window. If more are needed just add them.
Simplify (de-uglify) the logic for cargo acceptence for houses and split the goods/food table into two. The acceptance is unmodified, but accepting goods AND food is now trivially possible. The exact amounts have to be decided.
This is based on Celestar's changes in the map branch plus some further bits that will be merged there soon.
2004-11-21 10:49:40 +00:00
tron
83ffb9c7fa (svn r667) Fix bug in rendering stations from savegames
Also don't pitch custom station sprites by railtype
(pasky)
2004-11-17 21:11:16 +00:00
dominik
4612dcdb48 (svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h 2004-11-17 18:49:55 +00:00
tron
3a7abc2a35 (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky) 2004-11-17 18:03:33 +00:00
tron
13f0b6c0cf (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky) 2004-11-17 08:52:47 +00:00
miham
86d19cb577 (svn r647) Cleanup custom station classes handling. (pasky) 2004-11-17 00:52:54 +00:00
tron
b65bda506c (svn r635) Fix choosing a spritegroup from deterministic variational spritegroups if there is no structure to search (i.e. in purchase lists) (pasky) 2004-11-15 20:52:11 +00:00
tron
2f35fea097 (svn r625) Almost complete support for deterministic variational vehicle spritegroups. (pasky) 2004-11-15 11:54:35 +00:00
darkvater
ec434b208e (svn r610) -newgrf: Support for some basic deterministical spritegroups regarding stations. Waypoints look changes based on year now :^) (pasky). 2004-11-14 20:50:38 +00:00
darkvater
183c33931d (svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky). 2004-11-14 18:18:28 +00:00
darkvater
e656a91736 (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky) 2004-11-14 16:42:08 +00:00
darkvater
5fcd71cf28 (svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky). 2004-11-14 16:11:48 +00:00
darkvater
5847317526 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky). 2004-11-14 14:53:15 +00:00
darkvater
ccc496ba2c (svn r591) -newgrf: Store whole struct StationSpec in SetCustomStation(), not just the rendering data. This will be needed for variational stationspecs (pasky). 2004-11-14 14:10:03 +00:00
celestar
eb50427670 (svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
the first custom one can be placed (no selector GUI, coming soon). This
also moves some global variables to {struct GRFFile} and reorders which
actions are processed in what stage, to get it all working together --
(pasky)
2004-11-14 09:07:15 +00:00
darkvater
7930faace9 (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky) 2004-11-14 01:25:05 +00:00
tron
65058d0d57 (svn r542) -Fix: Display correct rail type in "build railway station" window
Thanks, ln--
2004-11-11 23:10:22 +00:00