Ejemplo n.º 1
0
/**
 * Playstate implementation. Must initialize it, run the loop and clean it up
 */
state playstate(int doLoad) {
    GFraMe_ret rv;
    state ret;
    
    ret = -1;
    rv = ps_init(doLoad);
    GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init playstate", __ret);
    
    GFraMe_event_init(_maxUfps, _maxDfps);
    
    _ps_pause = 0;
    _psRunning = 1;
    while (gl_running && _psRunning) {
#ifdef DEBUG
        unsigned int t;
#endif
        
        ps_event();
        timer_update();
        if (_ps_pause) {
            ps_doPause();
            if (_ps_onOptions) {
                options();
                _ps_onOptions = 0;
                _ps_lastPress = 300;
            }
        }
        else {
            if (gv_isZero(SWITCH_MAP))
                ps_update();
            else {
                rv = ps_switchMap();
                GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to switch maps",
                    __ret);
            }
        }
        ps_draw();
        
#ifdef DEBUG
        t = SDL_GetTicks();
        if (t >= _time) {
            GFraMe_log("t=%04i, U=%03i/%03i D=%03i/%03i", _time - _ltime,
                _updCalls, _maxUfps, _drwCalls, _maxDfps);
            _updCalls = 0;
            _drwCalls = 0;
            _ltime = _time;
            _time = SDL_GetTicks() + 1000;
        }
#endif
    }
    
    if (_timerTilCredits >= 5000)
        ret = CREDITS;
    else
        ret = MENUSTATE;
__ret:
    ps_clean();
    
    return ret;
}
Ejemplo n.º 2
0
void machine_proc_get_more(struct myproc **procs)
{
    ps_update();

    for(size_t i = 0; i < ps_n; i++) {
        pid_t pid, ppid;

        if(sscanf(ps_list[i], " %d %d ", &pid, &ppid) == 2
                && !proc_get(procs, pid))
        {
            struct myproc *p = umalloc(sizeof *p);

            /* bare minimum - rest is done in _update */
            p->pid  = pid;
            p->ppid = ppid;

            proc_addto(procs, p);
        } else {
            //fprintf(stderr, "couldn't sscanf(\"%s\")\n", ps[i]);
        }
    }
}