(svn r2646) Change: [ntp] Fix uninitialized variable and add some more asserts to be able to debug an assert error.
This commit is contained in:
		
							
								
								
									
										10
									
								
								pathfind.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								pathfind.c
									
									
									
									
									
								
							@@ -664,11 +664,14 @@ static void NTPEnum(NewTrackPathFinder *tpf, TileIndex tile, uint direction)
 | 
				
			|||||||
	FindLengthOfTunnelResult flotr;
 | 
						FindLengthOfTunnelResult flotr;
 | 
				
			||||||
	int estimation;
 | 
						int estimation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Need to have a special case for the start.
 | 
						// Need to have a special case for the start.
 | 
				
			||||||
	// We shouldn't call the callback for the current tile.
 | 
						// We shouldn't call the callback for the current tile.
 | 
				
			||||||
	si.cur_length = 1; // Need to start at 1 cause 0 is a reserved value.
 | 
						si.cur_length = 1; // Need to start at 1 cause 0 is a reserved value.
 | 
				
			||||||
	si.depth = 0;
 | 
						si.depth = 0;
 | 
				
			||||||
	si.state = 0;
 | 
						si.state = 0;
 | 
				
			||||||
 | 
						si.first_track = 0xFF;
 | 
				
			||||||
	goto start_at;
 | 
						goto start_at;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for(;;) {
 | 
						for(;;) {
 | 
				
			||||||
@@ -690,7 +693,9 @@ callback_and_continue:
 | 
				
			|||||||
		if (tpf->enum_proc(tile, tpf->userdata, si.first_track, si.cur_length))
 | 
							if (tpf->enum_proc(tile, tpf->userdata, si.first_track, si.cur_length))
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							assert(si.track <= 13);
 | 
				
			||||||
		direction = _tpf_new_direction[si.track];
 | 
							direction = _tpf_new_direction[si.track];
 | 
				
			||||||
 | 
							assert(direction <= 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
start_at:
 | 
					start_at:
 | 
				
			||||||
		// If the tile is the entry tile of a tunnel, and we're not going out of the tunnel,
 | 
							// If the tile is the entry tile of a tunnel, and we're not going out of the tunnel,
 | 
				
			||||||
@@ -715,6 +720,7 @@ start_at:
 | 
				
			|||||||
		// a rail net and find the first intersection
 | 
							// a rail net and find the first intersection
 | 
				
			||||||
		tile_org = tile;
 | 
							tile_org = tile;
 | 
				
			||||||
		for(;;) {
 | 
							for(;;) {
 | 
				
			||||||
 | 
								assert(direction <= 3);
 | 
				
			||||||
			tile += TileOffsByDir(direction);
 | 
								tile += TileOffsByDir(direction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// too long search length? bail out.
 | 
								// too long search length? bail out.
 | 
				
			||||||
@@ -812,7 +818,7 @@ start_at:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			// continue with the next track
 | 
								// continue with the next track
 | 
				
			||||||
			direction = _tpf_new_direction[track];
 | 
								direction = _tpf_new_direction[track];
 | 
				
			||||||
			assert(direction != 0xFF);
 | 
								assert(direction <= 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// safety check if we're running around chasing our tail... (infinite loop)
 | 
								// safety check if we're running around chasing our tail... (infinite loop)
 | 
				
			||||||
			if (tile == tile_org) {
 | 
								if (tile == tile_org) {
 | 
				
			||||||
@@ -850,7 +856,9 @@ start_at:
 | 
				
			|||||||
		si.depth++;
 | 
							si.depth++;
 | 
				
			||||||
		si.tile = tile;
 | 
							si.tile = tile;
 | 
				
			||||||
		do {
 | 
							do {
 | 
				
			||||||
 | 
								assert(direction <= 3);
 | 
				
			||||||
			si.track = _new_track[FIND_FIRST_BIT(bits)][direction];
 | 
								si.track = _new_track[FIND_FIRST_BIT(bits)][direction];
 | 
				
			||||||
 | 
								assert(si.track <= 13);
 | 
				
			||||||
			si.priority = si.cur_length + estimation;
 | 
								si.priority = si.cur_length + estimation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// out of stack items, bail out?
 | 
								// out of stack items, bail out?
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user