OpenTTD

Tasklist

FS#1843 - Facades for ship pathfinders

Attached to Project: OpenTTD
Opened by Noldo (Noldo) - Monday, 10 March 2008, 21:30 GMT
Last edited by Remko Bijker (Rubidium) - Tuesday, 05 January 2010, 14:41 GMT
Type Work in progress
Category Vehicles
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Why??
Wouldn't it be nice if all the pathfinders for specific vehicle type has a clean interface?

Added:
-abstract class ShipPf that is the interface common to all ship pathfinders.
-derived classes for each current ship pathfinder.
-files pathfinder_front.{h|cpp}

Moved:
-this and that from ship_cmd.cpp to pathfinder_front.cpp to make the original ChooseShipTrack look the way it looks.

Collateral Damage / Nice Bonus:
OPF/NPF code got removed from ship_cmd.cpp

Problems:
-Some of the static variables and functions that were needed in the pathfinder_front.cpp were also needed in non-related
contexts elsewhere in ship_cmd.cpp so I left those in ship_cmd.cpp too which is ugly code and data duplication and needs a solution.
-Also the Depot finding function is duplicated in ShipPf_Yapf and ShipPf_Opf, deriving one from the other would solve that,
but maybe there's some better solution.

Development ideas:
-The switch/case construct could propably be replaced with some kind of array-like thing that is indexed with the patch setting.

This task depends upon

Closed by  Remko Bijker (Rubidium)
Tuesday, 05 January 2010, 14:41 GMT
Reason for closing:  Implemented
Additional comments about closing:  Although differently and without classes
Comment by Zdeněk Sojka (SmatZ) - Monday, 10 March 2008, 21:45 GMT
I see a lot of "new", but no "delete".
(generally, I don't think this is a good idea... or maybe it IS a good idea, but done wrong)

Loading...