Ejemplo n.º 1
0
static void ipc_handler_info_end(struct ipc_manager *m, void *data)
{
	struct info *info = (struct info *)data;
	char *global_status;

	ipc_manager_get_arg_at(m, 0, IPC_STRING_T, &global_status);
	info->global_status = update_status_str(global_status);
}
Ejemplo n.º 2
0
static void ipc_handler_info_module(struct ipc_manager *m, void *data)
{
	struct info *info = (struct info *)data;
	struct module_info *mod_info = malloc(sizeof(struct module_info));
	int n, n_bases, argc;
	char *mod_name, *mod_status, *update_date;

	ipc_manager_get_arg_at(m, 0, IPC_STRING_T, &mod_name);
	mod_info->name = strdup(mod_name);
	ipc_manager_get_arg_at(m, 1, IPC_STRING_T, &mod_status);
	mod_info->mod_status = update_status_str(mod_status);
	ipc_manager_get_arg_at(m, 2, IPC_STRING_T, &update_date);
	mod_info->update_date = strdup(update_date);

	n_bases = (ipc_manager_get_argc(m) - 3) / 5;

	mod_info->base_infos = malloc((n_bases + 1) * sizeof(struct a6o_base_info *));
	mod_info->base_infos[n_bases] = NULL;

	for (argc = 3, n = 0; argc < ipc_manager_get_argc(m); argc += 5, n++) {
		struct base_info *base_info = malloc(sizeof(struct base_info));
		char *name, *date, *version, *full_path;

		ipc_manager_get_arg_at(m, argc+0, IPC_STRING_T, &name);
		base_info->name = strdup(name);
		ipc_manager_get_arg_at(m, argc+1, IPC_STRING_T, &date);
		base_info->date = strdup(date);
		ipc_manager_get_arg_at(m, argc+2, IPC_STRING_T, &version);
		base_info->version = strdup(version);
		ipc_manager_get_arg_at(m, argc+3, IPC_INT32_T, &base_info->signature_count);
		ipc_manager_get_arg_at(m, argc+4, IPC_STRING_T, &full_path);
		base_info->full_path = strdup(full_path);

		mod_info->base_infos[n] = base_info;
	}

	info_append_module(info, mod_info);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    int mode = SDL_HWSURFACE | SDL_HWACCEL |
        SDL_DOUBLEBUF | SDL_OPENGL;

    if (argc >= 2 && (! strcmp(argv[1], "-h") ||
                      ! strcmp(argv[1], "--help"))) {
        printf("Uso: %s [-fs] resolucao-x resolucao-y\n\n"
               "Exemplo: ./walker 1024 768\n\n"
               "Para mais informacoes, leia o README.\n",
               argv[0]);
        exit(0);
    }

    int shift = 1;
    if (argc >= 2 && ! strcmp(argv[1], "-fs")) {
        mode |= SDL_FULLSCREEN;
        res_x = 1360;
        res_y = 768;
        shift++;
    }
    if (argc >= 3) {
        res_x = atoi(argv[shift]);
        res_y = atoi(argv[shift+1]);
    }

    init_event_keys();

    glutInit(&argc, argv);
    initsdl(mode);
    initgl();

    carregar_texturas();

    SDL_Event ev;

    while (1)
        if (! SDL_PollEvent(&ev)
            || ev.type == SDL_MOUSEMOTION)
            break;
        else
            event_handler(ev);

    uint64_t old_time, new_time;
    uint64_t old_border, new_border;
    old_time = time_get();
    old_border = time_in_secs(old_time);

    float dt = 0;
    int count = 0;

    while (1) {
        while (SDL_PollEvent(&ev))
            event_handler(ev);

        new_time = time_get();
        new_border = time_in_secs(new_time);

        dt = time_diff(new_time, old_time);

        if (new_border > old_border) {
            update_fps_str(count);
            old_border = new_border;
            count = 0;
        }

        old_time = new_time;
        count++;

        update_status_str();

        toggle();
        model(dt);
        physics(dt);
        update_map_pos();
        draw();
    }
}