Beispiel #1
0
int			move(t_list *list)
{
	t_list		*link;
	int			ret;

	ret = 0;
	link = list;
	clean_end(list);
	while (link != NULL)
	{
		if (((t_salle *)link->content)->status == END)
		{
			if (link->next != NULL)
				link = link->next;
			else
				break ;
		}
		if (((t_salle *)link->content)->clean == 1)
		{
			iter_path(list, TC->way_value);
			init_useless(list);
			ret = 1;
		}
		link = link->next;
	}
	move_next(list);
	return (ret);
}
Beispiel #2
0
void G_Map::move(G_MapPlayer *player, obstack_vector<unsigned> &path, unsigned type) noexcept {
    player->_path = std::vector<unsigned>(path.begin(), path.end());
    player->_path_index = 0;
    if (!player->_move_timer) {
        move_next(player, type);
    }
}
Beispiel #3
0
bool
AsxParserInternal::parse_stream (TextStream *stream)
{
	tokenizer = new AsxTokenizer (stream);

	while (move_next ()) {
		if (stop_parsing)
			return false;
	}

	if (error_code != ASXPARSER_ERROR_NONE)
		return false;

	if (!g_queue_is_empty (element_stack)) {
		raise_error (ASXPARSER_ERROR_NO_ELEMENTS, "Unexpected end of file found.");
		return false;
	}

	return true;
}
Beispiel #4
0
bool ModBox::keyPressed (const KeyPress& key)
{
    KeyPress move_next(key.downKey, ModifierKeys::noModifiers, 0);
    KeyPress move_prev(key.upKey, ModifierKeys::noModifiers, 0);
    KeyPress shift_next(key.downKey, ModifierKeys::commandModifier, 0);
    KeyPress shift_prev(key.upKey, ModifierKeys::commandModifier, 0);
    
    if (key == move_prev) {
        select_prev_item();
        return true;
    } else if (key == move_next) {
        select_next_item();
        return true;
    } else if (key == shift_prev) {
        shift_item_prev();
    } else if (key == shift_next) {
        shift_item_next();
    }
    return false;
}
Beispiel #5
0
timeval_t G_Map::move_timer_handler(G_MapPlayer *player, Timer&, timeval_t) {
    player->_move_timer = nullptr;
    move_next(player, G_MOVE_NORMAL);
    return 0;
}
Beispiel #6
0
SubMesh* Mesh::new_submesh_as_box(const std::string& name, MaterialID material, float width, float height, float depth, const Vec3& offset) {
    VertexSpecification spec;
    spec.position_attribute = VERTEX_ATTRIBUTE_3F;
    spec.normal_attribute = VERTEX_ATTRIBUTE_3F;
    spec.texcoord0_attribute = VERTEX_ATTRIBUTE_2F;
    spec.texcoord1_attribute = VERTEX_ATTRIBUTE_2F;
    spec.diffuse_attribute = VERTEX_ATTRIBUTE_4F;

    SubMesh* sm = new_submesh_with_material(
        name,
        material,
        MESH_ARRANGEMENT_TRIANGLES,
        VERTEX_SHARING_MODE_INDEPENDENT,
        spec
    );

    auto vd = sm->vertex_data.get();
    auto id = sm->index_data.get();

    float x_offset = offset.x;
    float y_offset = offset.y;
    float z_offset = offset.z;

    float rx = width * 0.5f;
    float ry = height * 0.5f;
    float rz = depth * 0.5f;

    //front and back
    for(int32_t z: { -1, 1 }) {
        uint32_t count = vd->count();

        vd->position(-1 * rx, -1 * ry, z * rz);
        vd->tex_coord0(0, 0);
        vd->tex_coord1(0, 0);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, 0, z);
        vd->move_next();

        vd->position( 1 * rx, -1 * ry, z * rz);
        vd->tex_coord0(1, 0);
        vd->tex_coord1(1, 0);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, 0, z);
        vd->move_next();

        vd->position( 1 * rx,  1 * ry, z * rz);
        vd->tex_coord0(1, 1);
        vd->tex_coord1(1, 1);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, 0, z);
        vd->move_next();

        vd->position(-1 * rx,  1 * ry, z * rz);
        vd->tex_coord0(0, 1);
        vd->tex_coord1(0, 1);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, 0, z);
        vd->move_next();

        if(z > 0) {
            id->index(count);
            id->index(count + 1);
            id->index(count + 2);

            id->index(count);
            id->index(count + 2);
            id->index(count + 3);
        } else {
            id->index(count);
            id->index(count + 2);
            id->index(count + 1);

            id->index(count);
            id->index(count + 3);
            id->index(count + 2);
        }
    }

    //left and right
    for(int32_t x: { -1, 1 }) {
        uint32_t count = vd->count();

        vd->position( x * rx, -1 * ry, -1 * rz);
        vd->tex_coord0(0, 0);
        vd->tex_coord1(0, 0);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(x, 0, 0);
        vd->move_next();

        vd->position( x * rx,  1 * ry, -1 * rz);
        vd->tex_coord0(1, 0);
        vd->tex_coord1(1, 0);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(x, 0, 0);
        vd->move_next();

        vd->position( x * rx,  1 * ry, 1 * rz);
        vd->tex_coord0(1, 1);
        vd->tex_coord1(1, 1);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(x, 0, 0);
        vd->move_next();

        vd->position(x * rx, -1 * ry, 1 * rz);
        vd->tex_coord0(0, 1);
        vd->tex_coord1(0, 1);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(x, 0, 0);
        vd->move_next();

        if(x > 0) {
            id->index(count);
            id->index(count + 1);
            id->index(count + 2);

            id->index(count);
            id->index(count + 2);
            id->index(count + 3);
        } else {
            id->index(count);
            id->index(count + 2);
            id->index(count + 1);

            id->index(count);
            id->index(count + 3);
            id->index(count + 2);
        }

    }

    //top and bottom
    for(int32_t y: { -1, 1 }) {
        uint32_t count = vd->count();

        vd->position( 1 * rx, y * ry, -1 * rz);
        vd->tex_coord0(0, 0);
        vd->tex_coord1(0, 0);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, y, 0);
        vd->move_next();

        vd->position( -1 * rx,  y * ry, -1 * rz);
        vd->tex_coord0(1, 0);
        vd->tex_coord1(1, 0);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, y, 0);
        vd->move_next();

        vd->position( -1 * rx,  y * ry, 1 * rz);
        vd->tex_coord0(1, 1);
        vd->tex_coord1(1, 1);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, y, 0);
        vd->move_next();

        vd->position( 1 * rx, y * ry, 1 * rz);
        vd->tex_coord0(0, 1);
        vd->tex_coord1(0, 1);
        vd->diffuse(smlt::Colour::WHITE);
        vd->normal(0, y, 0);
        vd->move_next();

        if(y > 0) {
            id->index(count);
            id->index(count + 1);
            id->index(count + 2);

            id->index(count);
            id->index(count + 2);
            id->index(count + 3);
        } else {
            id->index(count);
            id->index(count + 2);
            id->index(count + 1);

            id->index(count);
            id->index(count + 3);
            id->index(count + 2);
        }

    }

    // Apply offset
    vd->move_to_start();
    for(uint16_t i = 0; i < vd->count(); ++i) {
        Vec3 pos = vd->position_at<Vec3>(i);
        vd->position(pos + smlt::Vec3(x_offset, y_offset, z_offset));
        vd->move_next();
    }

    vd->done();
    id->done();

    return sm;
}
int main(void)
{
    char c;
    int i, num;
    node* ptr = first;
    printf("How many entries do you want to enter initially?\n"); // ask user for a initial list length
    scanf("%i", &num);
    // create user defined length of a list of structures
    for (i = 0; i < num ; i++)
    {
        ptr = insert(ptr);
    }

    do
    {
        printf("Currently you have %i entry(ies)", num_list);
        if (num_list > 0)
        {
            if (ptr != NULL)
            {
                print_current(ptr);
            }
        }

        // print instructions
        printf("\nMENU\n\n"
            "1 - delete\n"
            "2 - insert\n"
            "3 - search\n"
            "4 - print_list\n"
            "5 - move to the previous list\n"
            "6 - move to the next list\n"
            "0 - quit\n\n");

        // get command
        printf("Command: ");
        fflush(stdin);
        scanf("%c", &c);

        // try to execute command
        switch (c)
        {
            case '1': del(); break;
            case '2': ptr = insert(ptr); break;
            case '3': search(); break;
            case '4': print_list(); break;
            case '5': ptr = move_pred(ptr); break;
            case '6': ptr = move_next(ptr); break;
        }
    }
    while (c != '0');

    // free list before quitting(to prevent memory leakage)
    while (ptr != NULL)
    {
        node* predptr = ptr;
        ptr = ptr->next;
        if (predptr->person != NULL)
        {
            if (predptr->person->name != NULL)
            {
                free(predptr->person->name);
            }
            free(predptr->person);
        }
        free(predptr);
    }

}
Beispiel #8
0
Datei: main.c Projekt: bgee/twilc
/**
 * Commands:
 * a --
 * b --
 * c -- conversation
 * d -- delete a tweet
 * e --
 * f -- fav/unfav a tweet
 * g --
 * h --
 * i --
 * j -- move down one tweet
 * J -- move down one page
 * k -- move up one tweet
 * K -- move up one page
 * l -- list
 * m -- direct message
 * n -- compose a new tweet
 * o --
 * p --
 * q -- quit
 * r -- reply
 * R -- reply to all
 * s -- search
 * t -- retweet
 * u --
 * v -- move to the last viewed tweet
 * w --
 * x --
 * y --
 * z --
 * ? -- show shortcuts help
 * . -- refresh
 */
void wait_command(WINDOW *win) {
    char ch = '\0';
    while((ch = getch()) != 'q') {
        switch(ch) {
        case 'n':
            // Compose new tweet
            notify_state_change(states[STATE_NORMAL]);
            compose_new_tweet(win,NULL,0);
            return_to_current_timeline(win);
            break;
        case 'J':
            // move down one page
            notify_state_change(states[STATE_NORMAL]);
            if(move_next_page(win,timelines[current_tl_index]->current_bottom,1) != -1) {
                timelines[current_tl_index]->current = timelines[current_tl_index]->current_top;
                highlight_status(win, timelines[current_tl_index]->current);
            }
            else
                notify_error_state();
            break;
        case 'K':
            // move up one page
            notify_state_change(states[STATE_NORMAL]);
            if(move_next_page(win,timelines[current_tl_index]->current_top,-1)!= -1) {
                timelines[current_tl_index]->current = timelines[current_tl_index]->current_top;
                highlight_status(win, timelines[current_tl_index]->current);
            }
            else
                notify_error_state();
            break;
        case 'j':
            // move down one tweet
            notify_state_change(states[STATE_NORMAL]);
            move_next(win, timelines[current_tl_index]->current,1);
            break;
        case 'k':
            // move up one tweet
            notify_state_change(states[STATE_NORMAL]);
            move_next(win, timelines[current_tl_index]->current,-1);
            break;
        case '.':
            // refresh the current timeline
            /*
            notify_state_change(states[STATE_RETRIEVING_UPDATES]);
            struct status_node *to_status = timelines[current_tl_index]->head;
            int res = update_timeline(current_tl_index,NULL,to_status);
            if(res >= 0){
                char *state_str = malloc(20*sizeof(char));
                memset(state_str,'\0',20);
                if(res == 0)
                    sprintf(state_str,"%s","No updates.");
                else if(res == 1)
                    sprintf(state_str,"%d new tweet.",res);
                else
                    sprintf(state_str,"%d new tweets.",res);
                notify_state_change(state_str);
                free(state_str);
            }
            else
                notify_error_state();
            */
            merge_timeline_updates(current_tl_index);

            timelines[current_tl_index]->last_viewed = timelines[current_tl_index]->current;
            move_top(win);
            notify_timeline_updates(current_tl_index,0);
            break;
        case 'v':
            notify_state_change(states[STATE_NORMAL]);
            if(timelines[current_tl_index]->last_viewed) {
                int y,x;
                struct status_node *last_viewed = timelines[current_tl_index]->last_viewed;
                getmaxyx(win,y,x);
                timelines[current_tl_index]->current = last_viewed;
                timelines[current_tl_index]->current_top = last_viewed;
                timelines[current_tl_index]->current_bottom = show_timeline(win,last_viewed,y,x);
                highlight_status(win,last_viewed);
            }
            else
                notify_state_change(states[STATE_NO_LAST_VIEWED]);
            break;
        case 'r':
            compose_new_tweet(win,timelines[current_tl_index]->current->st,0);
            return_to_current_timeline(win);
            break;
        case 'R':
            compose_new_tweet(win,timelines[current_tl_index]->current->st,1);
            return_to_current_timeline(win);
            break;
        case 't':
            if(timelines[current_tl_index]->current->st) {
                status *st = timelines[current_tl_index]->current->st;
                if(st->retweeted_status)
                    st = st->retweeted_status;
                if(IS_PROTECTED(st->composer->extra_info))
                    notify_state_change("This user is protected. Cannot retweet.");
                else
                    retweet_status(st->id);
            }
            break;
        }
    }
}