Example #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;
}
Example #2
0
/*
 * find PS. for cmd which will change PS
 */
static char *find_ps(const char *buf)
{
    char *ps = NULL;
    int tlllen = strlen(buf);
    int is_match = -1;

    ps = last_ttyio(outbuf, last_outlen);
    //last_outlen = 0;

    if (ps == NULL) {
        return NULL;
    }

    is_match = match_ps(ps);
    ps_clean(&ps);

    dbg("\n--\nis_match:(%d)\n(%s)\n--\n", is_match, ps);

    if (is_match == 0) {
        return ps;
    } else {
        free(ps);
        return NULL;
    }
}