diff options
author | matthijs <matthijs@openttd.org> | 2005-04-15 15:28:01 +0000 |
---|---|---|
committer | matthijs <matthijs@openttd.org> | 2005-04-15 15:28:01 +0000 |
commit | c6f40b469677ae83edf61b8979c8375eee130bbd (patch) | |
tree | cfc007fd56ab1bff8677aaacda9b708846b81a3c | |
parent | 7b673ec0cb372b9a300a81c687850b0c5d9e559d (diff) | |
download | openttd-c6f40b469677ae83edf61b8979c8375eee130bbd.tar.xz |
(svn r2204) - Add: [NPF] NPF now has a maximum number of nodes it will search. The default value is 5000 for now, which is an educated guess. Probably needs some finetuning. Hopefully this "feature" can be removed later on, when more sophisticated means of limiting the pathfinder have been implemented. This should make ships and larger networks playable for now, though.
-rw-r--r-- | npf.c | 5 | ||||
-rw-r--r-- | settings.c | 3 | ||||
-rw-r--r-- | variables.h | 12 |
3 files changed, 18 insertions, 2 deletions
@@ -785,7 +785,10 @@ void InitializeNPF(void) init_AyStar(&_npf_aystar, NPFHash, NPF_HASH_SIZE); _npf_aystar.loops_per_tick = 0; _npf_aystar.max_path_cost = 0; - _npf_aystar.max_search_nodes = 0; + //_npf_aystar.max_search_nodes = 0; + /* We will limit the number of nodes for now, until we have a better + * solution to really fix performance */ + _npf_aystar.max_search_nodes = _patches.npf_max_search_nodes; #if 0 init_AyStar(&_train_find_station, NTPHash, 1024); init_AyStar(&_train_find_depot, NTPHash, 1024); diff --git a/settings.c b/settings.c index 02085cb96..0c285a2c0 100644 --- a/settings.c +++ b/settings.c @@ -926,6 +926,9 @@ const SettingDesc patch_settings[] = { /* New Path Finding */ {"new_pathfinding_all", SDT_BOOL, (void*)false, &_patches.new_pathfinding_all, NULL}, + /* The maximum number of nodes to search */ + {"npf_max_search_nodes", SDT_UINT32, (void*)10000, &_patches.npf_max_search_nodes, NULL}, + /* When a red signal is encountered, a small detour can be made around * it. This specifically occurs when a track is doubled, in which case * the detour is typically 2 tiles. It is also often used at station diff --git a/variables.h b/variables.h index 32432f28d..5a705214f 100644 --- a/variables.h +++ b/variables.h @@ -192,9 +192,19 @@ typedef struct Patches { byte drag_signals_density; // many signals density bool ainew_active; // Is the new AI active? - /* New Path Finding */ + /* + * New Path Finding + */ bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */ + /** + * The maximum amount of search nodes a single NPF run should take. This + * limit should make sure performance stays at acceptable levels at the cost + * of not being perfect anymore. This will probably be fixed in a more + * sophisticated way sometime soon + */ + uint32 npf_max_search_nodes; + uint32 npf_rail_firstred_penalty; /* The penalty for when the first signal is red (and it is not an exit or combo signal) */ uint32 npf_rail_firstred_exit_penalty; /* The penalty for when the first signal is red (and it is an exit or combo signal) */ uint32 npf_rail_lastred_penalty; /* The penalty for when the last signal is red */ |