예제 #1
0
파일: walker.c 프로젝트: hvds/seq
int mbh_compare_wr(void* context, void* left, void* right) {
	whp wh = P2I(context);
	walker* w = DWP(wh);
	wrhp wlh = P2I(left);
	wrhp wrh = P2I(right);
	walk_result* wl = DWRP(wh, wlh);
	walk_result* wr = DWRP(wh, wrh);
	return w->cmper(wr_next_discard(w, wl), wr_next_discard(w, wr));
}
예제 #2
0
 void AddWaypoint(uint32 id, float x, float y, float z)
 {
     WayPoints DWP(id, x, y, z);
     WayPointList.push_back(DWP);
 }
예제 #3
0
파일: walker.c 프로젝트: hvds/seq
wrhp walker_findnext(whp wh) {
	walker* w = DWP(wh);
	walk_result* next;
	walk_result* split;
	wrhp nexth;
	int limitbit, i;

	while (1) {
		if (mbh_size(w->heap) == 0)
			return (wrhp)0;

		/* pick_arena first, since arena may move */
		w_pick_arena(w, split);
		next = pop_heap(w);
		limitbit = next->nextbit;
		mpx_set(wr_discard_direct(w, split), w->numsize,
				wr_next_discard(w, next), w->numsize);
		split->invsum = next->invsum;
		memcpy(wr_vec_direct(w, split), wr_vec_direct(w, next),
				w->vecsize * sizeof(int));

		if (next->nextbit == w->pp->valsize) {
			/* first */
			--next->nextbit;
			w->adder(wr_next_discard(w, next), wr_discard_direct(w, next),
					ppv_mpx(pp_value_i(w->pp, next->nextbit)));
			if (!qualify(w, next)) {
				w_free_arena(w, next);
			} else {
				push_heap(w, next);
			}
			w_free_arena(w, split);
			goto found_line;
		}

		--next->nextbit;
		if (next->nextbit < 0) {
			w_free_arena(w, next);
		} else if (wr_testbit(w, next, next->nextbit)) {
			w_free_arena(w, next);
		} else {
			w->adder(wr_next_discard(w, next), wr_discard_direct(w, next),
					ppv_mpx(pp_value_i(w->pp, next->nextbit)));
			if (!qualify(w, next)) {
				w_free_arena(w, next);
			} else {
				push_heap(w, next);
			}
		}

		split->invsum = (split->invsum + pp_value_i(w->pp, limitbit)->inv)
				% w->pp->p;
		wr_setbit(w, split, limitbit);

		for (i = w->pp->valsize - 1; i > limitbit; --i) {
			if (!wr_testbit(w, split, i))
				break;
		}
		if (i <= limitbit) {
			w_free_arena(w, split);
		} else {
			split->nextbit = i;
			w->adder(wr_next_discard(w, split), wr_discard_direct(w, split),
					ppv_mpx(pp_value_i(w->pp, i)));
			if (!qualify(w, split)) {
				w_free_arena(w, split);
			} else {
				push_heap(w, split);
			}
		}
		next = split;
	  found_line:
		nexth = WRHP(w, next);
		if (next->invsum != w->invsum)
			continue;
		if (w->have_previous
				&& w->cmper(wr_discard_direct(w, next), w_previous(w)) == 0)
			continue;
		w->have_previous = 1;
		mpx_set(w_previous(w), w->numsize,
				wr_discard_direct(w, next), w->numsize);
		return nexth;
	}
}