(svn r2147) - Add: [NPF] Give red presignal exit signals a different (higher) penalty, to discourage trains from waiting at presignal exits.
This commit is contained in:
		
							
								
								
									
										8
									
								
								npf.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								npf.c
									
									
									
									
									
								
							| @@ -373,7 +373,13 @@ int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* parent) { | ||||
| 			if (!NPFGetFlag(current, NPF_FLAG_SEEN_SIGNAL)) { | ||||
| 				/* Penalize the first signal we | ||||
| 				 * encounter, if it is red */ | ||||
| 				cost += _patches.npf_rail_firstred_penalty; | ||||
|  | ||||
| 				/* Is this a presignal exit or combo? */ | ||||
| 				if ((_map3_hi[tile] & 0x3) == 0x2 || (_map3_hi[tile] & 0x3) == 0x3) | ||||
| 					/* Penalise exit and combo signals differently (heavier) */ | ||||
| 					cost += _patches.npf_rail_firstred_exit_penalty; | ||||
| 				else | ||||
| 					cost += _patches.npf_rail_firstred_penalty; | ||||
| 			} | ||||
| 			/* Record the state of this signal */ | ||||
| 			NPFSetFlag(current, NPF_FLAG_LAST_SIGNAL_RED, true); | ||||
|   | ||||
							
								
								
									
										15
									
								
								settings.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								settings.c
									
									
									
									
									
								
							| @@ -937,15 +937,18 @@ const SettingDesc patch_settings[] = { | ||||
| 	* again, just because the sign at the right side was red. If we take | ||||
| 	* a typical 5 length station, this detour is 10 or 11 tiles (not | ||||
| 	* sure), so we set the default penalty at 10 (the station tile | ||||
| 	* penalty will further prevent this */ | ||||
| 	{"npf_rail_firstred_penalty",		SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH),	&_patches.npf_rail_firstred_penalty,		NULL}, | ||||
| 	* penalty will further prevent this. | ||||
| 	* We give presignal exits (and combo's) a different (larger) penalty, because we really | ||||
| 	* don't want trains waiting in front of a presignal exit. */ | ||||
| 	{"npf_rail_firstred_penalty",   SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH),  &_patches.npf_rail_firstred_penalty,		NULL}, | ||||
| 	{"npf_rail_firstred_exit_penalty", SDT_UINT32, (void*)(100 * NPF_TILE_LENGTH),	&_patches.npf_rail_firstred_exit_penalty,		NULL}, | ||||
| 	/* This penalty is for when the last signal before the target is red. | ||||
| 	 * This is useful for train stations, where there are multiple | ||||
| 	 * platforms to choose from, which lie in different signal blocks. | ||||
| 	 * Every target in a occupied signal block (ie an occupied platform) | ||||
| 	 * will get this penalty. | ||||
| 	 */ | ||||
| 	{"npf_rail_lastred_penalty",		SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH),	&_patches.npf_rail_lastred_penalty,		NULL}, | ||||
| 	{"npf_rail_lastred_penalty",    SDT_UINT32, (void*)(10 * NPF_TILE_LENGTH),  &_patches.npf_rail_lastred_penalty,		NULL}, | ||||
| 	/* When a train plans a route over a station tile, this penalty is | ||||
| 	* applied. We want that trains plan a route around a typical, 4x5 | ||||
| 	* station, which means two tiles to the right, and two tiles back to | ||||
| @@ -953,9 +956,9 @@ const SettingDesc patch_settings[] = { | ||||
| 	* a penalty of 1 tile for every station tile passed, the route will | ||||
| 	* be around it. | ||||
| 	*/ | ||||
| 	{"npf_rail_station_penalty",		SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH),		&_patches.npf_rail_station_penalty, 		NULL}, | ||||
| 	{"npf_rail_slope_penalty",			SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH),		&_patches.npf_rail_slope_penalty,				NULL}, | ||||
| 	{"npf_rail_curve_penalty",			SDT_UINT32, (void*)(1),		&_patches.npf_rail_curve_penalty,				NULL}, | ||||
| 	{"npf_rail_station_penalty",    SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH),   &_patches.npf_rail_station_penalty, 		NULL}, | ||||
| 	{"npf_rail_slope_penalty",      SDT_UINT32, (void*)(1 * NPF_TILE_LENGTH),   &_patches.npf_rail_slope_penalty,				NULL}, | ||||
| 	{"npf_rail_curve_penalty",      SDT_UINT32, (void*)(1),                     &_patches.npf_rail_curve_penalty,				NULL}, | ||||
|  | ||||
| 	{NULL,									0,					NULL,					NULL,																						NULL} | ||||
| }; | ||||
|   | ||||
| @@ -195,7 +195,8 @@ typedef struct Patches { | ||||
| 	/* New Path Finding */ | ||||
| 	bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */ | ||||
|  | ||||
| 	uint32 npf_rail_firstred_penalty; /* The penalty for when the first signal is red */ | ||||
| 	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 */ | ||||
| 	uint32 npf_rail_station_penalty; /* The penalty for station tiles */ | ||||
| 	uint32 npf_rail_slope_penalty; /* The penalty for sloping upwards */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 matthijs
					matthijs