示例#1
0
void G_Init(void) {
    G_ReloadDefaults();
    G_InitActions();

    dmemset(playeringame, 0, sizeof(playeringame));
    G_ClearInput();

    G_AddCommand("+fire", CMD_Button, PCKEY_ATTACK);
    G_AddCommand("-fire", CMD_Button, PCKEY_ATTACK|PCKF_UP);
    G_AddCommand("+strafe", CMD_Button, PCKEY_STRAFE);
    G_AddCommand("-strafe", CMD_Button, PCKEY_STRAFE|PCKF_UP);
    G_AddCommand("+use", CMD_Button, PCKEY_USE);
    G_AddCommand("-use", CMD_Button, PCKEY_USE|PCKF_UP);
    G_AddCommand("+run", CMD_Button, PCKEY_RUN);
    G_AddCommand("-run", CMD_Button, PCKEY_RUN|PCKF_UP);
    G_AddCommand("+jump", CMD_Button, PCKEY_JUMP);
    G_AddCommand("-jump", CMD_Button, PCKEY_JUMP|PCKF_UP);
    G_AddCommand("weapon", CMD_Weapon, 0);
    G_AddCommand("nextweap", CMD_NextWeapon, 0);
    G_AddCommand("prevweap", CMD_PrevWeapon, 0);
    G_AddCommand("+forward", CMD_Button, PCKEY_FORWARD);
    G_AddCommand("-forward", CMD_Button, PCKEY_FORWARD|PCKF_UP);
    G_AddCommand("+back", CMD_Button, PCKEY_BACK);
    G_AddCommand("-back", CMD_Button, PCKEY_BACK|PCKF_UP);
    G_AddCommand("+left", CMD_Button, PCKEY_LEFT);
    G_AddCommand("-left", CMD_Button, PCKEY_LEFT|PCKF_UP);
    G_AddCommand("+right", CMD_Button, PCKEY_RIGHT);
    G_AddCommand("-right", CMD_Button, PCKEY_RIGHT|PCKF_UP);
    G_AddCommand("+lookup", CMD_Button, PCKEY_LOOKUP);
    G_AddCommand("-lookup", CMD_Button, PCKEY_LOOKUP|PCKF_UP);
    G_AddCommand("+lookdown", CMD_Button, PCKEY_LOOKDOWN);
    G_AddCommand("-lookdown", CMD_Button, PCKEY_LOOKDOWN|PCKF_UP);
    G_AddCommand("+center",  CMD_Button, PCKEY_CENTER);
    G_AddCommand("-center",  CMD_Button, PCKEY_CENTER|PCKF_UP);
    G_AddCommand("autorun",  CMD_Autorun, 0);
    G_AddCommand("+strafeleft", CMD_Button, PCKEY_STRAFELEFT);
    G_AddCommand("-strafeleft", CMD_Button, PCKEY_STRAFELEFT|PCKF_UP);
    G_AddCommand("+straferight", CMD_Button, PCKEY_STRAFERIGHT);
    G_AddCommand("-straferight", CMD_Button, PCKEY_STRAFERIGHT|PCKF_UP);
    G_AddCommand("bind", CMD_Bind, 0);
    G_AddCommand("seta", CMD_Seta, 0);
    G_AddCommand("quit", CMD_Quit, 0);
    G_AddCommand("exec", CMD_Exec, 0);
    G_AddCommand("listcmd", CMD_List, 0);
    G_AddCommand("god",  CMD_Cheat, 0);
    G_AddCommand("noclip", CMD_Cheat, 1);
    G_AddCommand("give", CMD_Cheat, 2);
    G_AddCommand("killall", CMD_Cheat, 3);
    G_AddCommand("mapall", CMD_Cheat, 4);
    G_AddCommand("pause", CMD_Pause, 0);
    G_AddCommand("spawnthing", CMD_SpawnThing, 0);
    G_AddCommand("exitlevel", CMD_ExitLevel, 0);
    G_AddCommand("trigger", CMD_TriggerSpecial, 0);
    G_AddCommand("setcamerastatic", CMD_PlayerCamera, 0);
    G_AddCommand("setcamerachase", CMD_PlayerCamera, 1);
    G_AddCommand("enddemo", CMD_EndDemo, 0);
}
示例#2
0
dboolean CON_Responder(event_t* ev)
{
    int c;
    dboolean clearheld = true;
    
    if((ev->type != ev_keyup) && (ev->type != ev_keydown))
        return false;
    
    c = ev->data1;
    lastkey = c;
    lastevent = ev->type;

    if(ev->type == ev_keydown && !keyheld)
    {
        keyheld = true;
        ticpressed = gametic;
    }
    else
    {
        keyheld = false;
        ticpressed = 0;
    }
    
    if(c == KEY_SHIFT)
    {
        if(ev->type == ev_keydown)
            shiftdown = true;
        else if(ev->type == ev_keyup)
            shiftdown = false;
    }
    
    switch(console_state)
    {
    case CST_DOWN:
    case CST_LOWER:
        if(ev->type == ev_keydown)
        {
            switch(c)
            {
            case '`':
                console_state = CST_UP;
                console_enabled = false;
                break;
                
            case KEY_ESCAPE:
                console_inputlength = 1;
                break;
                
            case KEY_TAB:
                CON_CvarAutoComplete(&console_inputbuffer[1]);
                break;
                
            case KEY_ENTER:
                if(console_inputlength <= 1)
                    break;
                
                console_inputbuffer[console_inputlength]=0;
                CON_AddLine(console_inputbuffer, console_inputlength);

                console_prevcmds[console_cmdhead] = console_head;
                console_cmdhead++;
                console_nextcmd = console_cmdhead;

                if(console_cmdhead >= CMD_HISTORY_SIZE)
                    console_cmdhead = 0;

                console_prevcmds[console_cmdhead] = -1;
                G_ExecuteCommand(&console_inputbuffer[1]);
                console_inputlength = 1;
                CONCLEARINPUT();
                break;
                
            case KEY_UPARROW:
                c = console_nextcmd - 1;
                if(c < 0)
                    c = CMD_HISTORY_SIZE - 1;
                
                if(console_prevcmds[c] == -1)
                    break;
                
                console_nextcmd = c;
                c = console_prevcmds[console_nextcmd];
                if(console_buffer[c])
                {
                    console_inputlength = console_buffer[c]->len;
                    dmemcpy(console_inputbuffer, console_buffer[console_prevcmds[console_nextcmd]]->line, console_inputlength);
                }
                break;
                
            case KEY_DOWNARROW:
                if(console_prevcmds[console_nextcmd] == -1)
                    break;
                
                c = console_nextcmd + 1;
                if(c >= CMD_HISTORY_SIZE)
                    c = 0;
                
                if(console_prevcmds[c] == -1)
                    break;
                
                console_nextcmd = c;
                console_inputlength = console_buffer[console_prevcmds[console_nextcmd]]->len;
                dmemcpy(console_inputbuffer, console_buffer[console_prevcmds[console_nextcmd]]->line, console_inputlength);
                break;

            case KEY_MWHEELUP:
            case KEY_PAGEUP:
                if(console_head < MAX_CONSOLE_LINES)
                    console_head++;
                break;

            case KEY_MWHEELDOWN:
            case KEY_PAGEDOWN:
                if(console_head > console_minline)
                    console_head--;
                break;
                
            default:
                if(c == KEY_SHIFT || c == KEY_ALT || c == KEY_CTRL)
                    break;

                clearheld = false;
                CON_ParseKey(c);
                break;
            }

            if(clearheld)
            {
                keyheld = false;
                ticpressed = 0;
            }
        }
        return true;
        
    case CST_UP:
    case CST_RAISE:
        if(c == '`')
        {
            if(ev->type == ev_keydown)
            {
                console_state = CST_DOWN;
                console_enabled = true;
                G_ClearInput();
            }
            return false;
        }
        break;
    }
    
    return false;
}
示例#3
0
void G_DoLoadLevel(void) {
    int i;
    mapdef_t* map;

    for(i = 0; i < MAXPLAYERS; i++) {
        if(playeringame[i] && players[i].playerstate == PST_DEAD) {
            players[i].playerstate = PST_REBORN;
        }

        dmemset(players[i].frags, 0, sizeof(players[i].frags));
    }

    basetic = gametic;

    // update settings from server cvar
    if(!netgame) {
        gameskill   = (int)sv_skill.value;
        respawnparm = (int)sv_respawn.value;
        respawnitem = (int)sv_respawnitems.value;
        fastparm    = (int)sv_fastmonsters.value;
        nomonsters  = (int)sv_nomonsters.value;
    }

    map = P_GetMapInfo(gamemap);

    if(map == NULL) {
        // boot out to main menu
        gameaction = ga_title;
        return;
    }

    forcecollision  = map->oldcollision;
    forcejump       = map->allowjump;
    forcefreelook   = map->allowfreelook;

    // This was quite messy with SPECIAL and commented parts.
    // Supposedly hacks to make the latest edition work.
    // It might not work properly.

    G_SetFastParms(fastparm || gameskill == sk_nightmare);  // killough 4/10/98

    if(gameskill == sk_nightmare || respawnparm) {
        respawnmonsters = true;
    }
    else {
        respawnmonsters = false;
    }

    if(respawnitem) {
        respawnspecials = true;
    }
    else {
        respawnspecials = false;
    }

    P_SetupLevel(gamemap, 0, gameskill);
    displayplayer = consoleplayer;        // view the guy you are playing
    starttime = I_GetTime();
    gameaction = ga_nothing;

    // clear cmd building stuff
    G_ClearInput();
    sendpause = sendsave = paused = false;
}