/*========================================== * attach/adjust path if neccessary *------------------------------------------*/ static int add_path(int *heap,struct tmp_path *tp,int16 x,int16 y,int dist,int before,int cost) { int i; i = calc_index(x,y); if( tp[i].x == x && tp[i].y == y ) { if( tp[i].dist > dist ) { tp[i].dist = dist; tp[i].before = before; tp[i].cost = cost; if( tp[i].flag ) push_heap_path(heap,tp,i); else update_heap_path(heap,tp,i); tp[i].flag = 0; } return 0; } if( tp[i].x || tp[i].y ) return 1; tp[i].x = x; tp[i].y = y; tp[i].dist = dist; tp[i].before = before; tp[i].cost = cost; tp[i].flag = 0; push_heap_path(heap,tp,i); return 0; }
/*========================================== * 必要ならpathを追加/修正する *------------------------------------------ */ static int add_path(int *heap, struct tmp_path *tp, int x, int y, int dist, DIR dir, int before, int x1, int y1) { int i; nullpo_ret(heap); nullpo_ret(tp); i = calc_index(x, y); if (tp[i].x == x && tp[i].y == y) { if (tp[i].dist > dist) { tp[i].dist = dist; tp[i].dir = dir; tp[i].before = before; tp[i].cost = calc_cost(&tp[i], x1, y1); if (tp[i].flag) push_heap_path(heap, tp, i); else update_heap_path(heap, tp, i); tp[i].flag = 0; } return 0; } if (tp[i].x || tp[i].y) return 1; tp[i].x = x; tp[i].y = y; tp[i].dist = dist; tp[i].dir = dir; tp[i].before = before; tp[i].cost = calc_cost(&tp[i], x1, y1); tp[i].flag = 0; push_heap_path(heap, tp, i); return 0; }