pathfind.c
changeset 2952 58522ed8f0f1
parent 2782 c7190cbfd309
child 3017 a75caf4efa2d
equal deleted inserted replaced
2951:2de6d3a59743 2952:58522ed8f0f1
   183 		if (!(bits & 1)) continue;
   183 		if (!(bits & 1)) continue;
   184 		rd = tpf->rd;
   184 		rd = tpf->rd;
   185 
   185 
   186 		// Change direction 4 times only
   186 		// Change direction 4 times only
   187 		if ((byte)i != tpf->rd.pft_var6) {
   187 		if ((byte)i != tpf->rd.pft_var6) {
   188 			if(++tpf->rd.depth > 4) {
   188 			if (++tpf->rd.depth > 4) {
   189 				tpf->rd = rd;
   189 				tpf->rd = rd;
   190 				return;
   190 				return;
   191 			}
   191 			}
   192 			tpf->rd.pft_var6 = (byte)i;
   192 			tpf->rd.pft_var6 = (byte)i;
   193 		}
   193 		}
   220 	x = TileX(tile) * 16;
   220 	x = TileX(tile) * 16;
   221 	y = TileY(tile) * 16;
   221 	y = TileY(tile) * 16;
   222 
   222 
   223 	z = GetSlopeZ(x+8, y+8);
   223 	z = GetSlopeZ(x+8, y+8);
   224 
   224 
   225 	for(;;) {
   225 	for (;;) {
   226 		flotr.length++;
   226 		flotr.length++;
   227 
   227 
   228 		x += _get_tunlen_inc[direction];
   228 		x += _get_tunlen_inc[direction];
   229 		y += _get_tunlen_inc[direction+1];
   229 		y += _get_tunlen_inc[direction+1];
   230 
   230 
   607 		return length == (head >> 2);
   607 		return length == (head >> 2);
   608 	}
   608 	}
   609 
   609 
   610 	// else it's a linked list of many tiles
   610 	// else it's a linked list of many tiles
   611 	offs = tpf->hash_tile[hash];
   611 	offs = tpf->hash_tile[hash];
   612 	for(;;) {
   612 	for (;;) {
   613 		link = NTP_GET_LINK_PTR(tpf, offs);
   613 		link = NTP_GET_LINK_PTR(tpf, offs);
   614 		if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
   614 		if (tile == link->tile && (uint)(link->typelength & 0x3) == dir) {
   615 			assert( (uint)(link->typelength >> 2) <= length);
   615 			assert( (uint)(link->typelength >> 2) <= length);
   616 			return length == (uint)(link->typelength >> 2);
   616 			return length == (uint)(link->typelength >> 2);
   617 		}
   617 		}
   688 	si.depth = 0;
   688 	si.depth = 0;
   689 	si.state = 0;
   689 	si.state = 0;
   690 	si.first_track = 0xFF;
   690 	si.first_track = 0xFF;
   691 	goto start_at;
   691 	goto start_at;
   692 
   692 
   693 	for(;;) {
   693 	for (;;) {
   694 		// Get the next item to search from from the priority queue
   694 		// Get the next item to search from from the priority queue
   695 		do {
   695 		do {
   696 			if (tpf->nstack == 0)
   696 			if (tpf->nstack == 0)
   697 				return; // nothing left? then we're done!
   697 				return; // nothing left? then we're done!
   698 			si = tpf->stack[0];
   698 			si = tpf->stack[0];
   732 		}
   732 		}
   733 
   733 
   734 		// This is a special loop used to go through
   734 		// This is a special loop used to go through
   735 		// a rail net and find the first intersection
   735 		// a rail net and find the first intersection
   736 		tile_org = tile;
   736 		tile_org = tile;
   737 		for(;;) {
   737 		for (;;) {
   738 			assert(direction <= 3);
   738 			assert(direction <= 3);
   739 			tile += TileOffsByDir(direction);
   739 			tile += TileOffsByDir(direction);
   740 
   740 
   741 			// too long search length? bail out.
   741 			// too long search length? bail out.
   742 			if (si.cur_length >= tpf->maxlength) {
   742 			if (si.cur_length >= tpf->maxlength) {