npf.c
changeset 4077 d4d440dd8925
parent 4048 5d653b47d349
child 4346 66105d4f6e83
equal deleted inserted replaced
4076:a6650b616430 4077:d4d440dd8925
   211  * Mark tiles by mowing the grass when npf debug level >= 1.
   211  * Mark tiles by mowing the grass when npf debug level >= 1.
   212  * Will not work for multiplayer games, since it can (will) cause desyncs.
   212  * Will not work for multiplayer games, since it can (will) cause desyncs.
   213  */
   213  */
   214 static void NPFMarkTile(TileIndex tile)
   214 static void NPFMarkTile(TileIndex tile)
   215 {
   215 {
   216 #ifdef NO_DEBUG_MESSAGES
   216 #ifndef NO_DEBUG_MESSAGES
   217 	return;
       
   218 #else
       
   219 	if (_debug_npf_level < 1 || _networking) return;
   217 	if (_debug_npf_level < 1 || _networking) return;
   220 	switch (GetTileType(tile)) {
   218 	switch (GetTileType(tile)) {
   221 		case MP_RAILWAY:
   219 		case MP_RAILWAY:
   222 			/* DEBUG: mark visited tiles by mowing the grass under them ;-) */
   220 			/* DEBUG: mark visited tiles by mowing the grass under them ;-) */
   223 			if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
   221 			if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
   804 	/* Initialize procs */
   802 	/* Initialize procs */
   805 	_npf_aystar.CalculateH = NPFCalcStationOrTileHeuristic;
   803 	_npf_aystar.CalculateH = NPFCalcStationOrTileHeuristic;
   806 	_npf_aystar.EndNodeCheck = NPFFindStationOrTile;
   804 	_npf_aystar.EndNodeCheck = NPFFindStationOrTile;
   807 	_npf_aystar.FoundEndNode = NPFSaveTargetData;
   805 	_npf_aystar.FoundEndNode = NPFSaveTargetData;
   808 	_npf_aystar.GetNeighbours = NPFFollowTrack;
   806 	_npf_aystar.GetNeighbours = NPFFollowTrack;
   809 	if (type == TRANSPORT_RAIL)
   807 	switch (type) {
   810 		_npf_aystar.CalculateG = NPFRailPathCost;
   808 		default: NOT_REACHED();
   811 	else if (type == TRANSPORT_ROAD)
   809 		case TRANSPORT_RAIL:  _npf_aystar.CalculateG = NPFRailPathCost;  break;
   812 		_npf_aystar.CalculateG = NPFRoadPathCost;
   810 		case TRANSPORT_ROAD:  _npf_aystar.CalculateG = NPFRoadPathCost;  break;
   813 	else if (type == TRANSPORT_WATER)
   811 		case TRANSPORT_WATER: _npf_aystar.CalculateG = NPFWaterPathCost; break;
   814 		_npf_aystar.CalculateG = NPFWaterPathCost;
   812 	}
   815 	else
       
   816 		assert(0);
       
   817 
   813 
   818 	/* Initialize target */
   814 	/* Initialize target */
   819 	target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
   815 	target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
   820 	_npf_aystar.user_target = &target;
   816 	_npf_aystar.user_target = &target;
   821 
   817