Example #1
0
static void visit_coords(map_t *m,int startX, int startY, int x, int y, int dx, int dy,
                         TCOD_list_t active_views, bool light_walls) {
    // top left
    int tlx=x, tly=y+STEP_SIZE;
    // bottom right
    int brx=x+STEP_SIZE, bry=y;
    view_t *view=NULL;
    while (current_view != (view_t **)TCOD_list_end(active_views)) {
        view=*current_view;
        if ( ! BELOW_OR_COLINEAR(&view->steep_line,brx,bry) ) {
            break;
        }
        current_view++;
    }
    if ( current_view == (view_t **)TCOD_list_end(active_views) || ABOVE_OR_COLINEAR(&view->shallow_line,tlx,tly)) {
        // no more active view
        return;
    }
    if ( !is_blocked(m,view,startX,startY,x,y,dx,dy,light_walls) ) return;
    if (  ABOVE(&view->shallow_line,brx,bry)
            && BELOW(&view->steep_line,tlx,tly)) {
        // view blocked
        // slow !
        TCOD_list_remove_iterator(active_views,(void **)current_view);
    } else if ( ABOVE(&view->shallow_line,brx,bry)) {
        // shallow bump
        add_shallow_bump(tlx,tly,view);
        check_view(active_views,current_view);
    } else if (BELOW(&view->steep_line,tlx,tly)) {
        // steep bump
        add_steep_bump(brx,bry,view);
        check_view(active_views,current_view);
    } else {
        // view splitted
        int offset=startX+x*dx/STEP_SIZE + (startY+y*dy/STEP_SIZE)*m->width;
        view_t *shallower_view= & views[offset];
        int view_index=current_view - (view_t **)TCOD_list_begin(active_views);
        view_t **shallower_view_it;
        view_t **steeper_view_it;
        *shallower_view=**current_view;
        // slow !
        shallower_view_it = (view_t **)TCOD_list_insert_before(active_views,shallower_view,view_index);
        steeper_view_it=shallower_view_it+1;
        current_view=shallower_view_it;
        add_steep_bump(brx,bry,shallower_view);
        if (!check_view(active_views,shallower_view_it)) steeper_view_it--;
        add_shallow_bump(tlx,tly,*steeper_view_it);
        check_view(active_views,steeper_view_it);
        if ( view_index > TCOD_list_size(active_views)) current_view=(view_t **)TCOD_list_end(active_views);
    }
}
Example #2
0
/*
 +-----------------------------------------------------------+
 * @desc	FIXME
 +-----------------------------------------------------------+
 */
static void
visit_coords(RLFL_map_t *m,int startX, int startY, int x, int y, int dx, int dy,
			 RLFL_list_t active_views, bool light_walls)
{
	// top left
	int tlx = x, tly = (y+1);

	// bottom right
	int brx = (x+1), bry = y;

	int realX = (x*dx), realY = (y*dy);
	int offset;
	view_t *view = NULL;

	while (current_view != (view_t **)RLFL_list_end(active_views))
	{
		view = *current_view;
		if ( !BELOW_OR_COLINEAR(&view->steep_line, brx, bry) ) {
			break;
		}
		current_view++;
	}
	if(current_view == (view_t **)RLFL_list_end(active_views)
			|| ABOVE_OR_COLINEAR(&view->shallow_line, tlx, tly)) {
		return;
	}

	offset = (startX + realX + ((startY+realY) * m->width));
	if (light_walls || RLFL_has_flag(m->mnum, startX+realX, startY+realY, CELL_OPEN)) {
		RLFL_set_flag(m->mnum, startX+realX, startY+realY, CELL_FOV);
	}

	if (RLFL_has_flag(m->mnum, startX+realX, startY+realY, CELL_OPEN))
		return;

	if ( ABOVE(&view->shallow_line, brx, bry)
		&& BELOW(&view->steep_line, tlx, tly)) {
		// slow !
		RLFL_list_remove_iterator(active_views, (void **)current_view);
	}
	else if( ABOVE(&view->shallow_line, brx, bry))
	{
		add_shallow_bump(tlx, tly, view);
		check_view(active_views, current_view);
	}
	else if(BELOW(&view->steep_line, tlx, tly))
	{
		add_steep_bump(brx,bry,view);
		check_view(active_views,current_view);
	}
	else
	{
		view_t *shallower_view = &views[offset];
		int view_index = (current_view - (view_t **)RLFL_list_begin(active_views));
		view_t **shallower_view_it;
		view_t **steeper_view_it;
		*shallower_view = **current_view;
		// slow !
		shallower_view_it = (view_t **)RLFL_list_insert(active_views, shallower_view, view_index);
		steeper_view_it = shallower_view_it+1;
		current_view = shallower_view_it;
		add_steep_bump(brx, bry, shallower_view);
		if (!check_view(active_views,shallower_view_it)) {
			steeper_view_it--;
		}
		add_shallow_bump(tlx, tly, *steeper_view_it);
		check_view(active_views, steeper_view_it);
		if ( view_index > RLFL_list_size(active_views)) {
			current_view = (view_t **)RLFL_list_end(active_views);
		}
	}
}