void CON_AddLine(char *line, int len) { conline_t *cline; int i; dboolean recursed = false; if(!console_linebuffer) { //not initialised yet return; } if(recursed) { //later call to Z_Malloc can fail and call I_Error/I_Printf... return; } recursed = true; if(!line) { return; } if(len == -1) { len = dstrlen(line); } cline = (conline_t *)Z_Malloc(sizeof(conline_t)+len, PU_STATIC, NULL); cline->len = len; if(len) { dmemcpy(cline->line, line, len); } cline->line[len] = 0; console_head = (console_lineoffset + CONSOLETEXT_MASK) & CONSOLETEXT_MASK; console_minline = console_head; console_lineoffset = console_head; console_buffer[console_head] = cline; console_buffer[console_head]->color = WHITE; i = (console_head + CONSOLETEXT_MASK) & CONSOLETEXT_MASK; if(console_buffer[i]) { Z_Free(console_buffer[i]); console_buffer[i] = NULL; } recursed = false; }
static void ST_DrawKey(int key, const float uv[4][2], const float xy[4][2]) { float keydrawxy[4][2]; if (plyr->cards[key] || (flashCards[key].doDraw && flashCards[key].active)) { dmemcpy(keydrawxy, xy, (sizeof(float) * 4) * 2); if (st_drawhud.value >= 2) { keydrawxy[0][0] += 20; keydrawxy[1][0] += 20; keydrawxy[2][0] += 20; keydrawxy[3][0] += 20; keydrawxy[0][1] += 78; keydrawxy[1][1] += 78; keydrawxy[2][1] += 78; keydrawxy[3][1] += 78; } ST_DrawStatusItem(keydrawxy, uv, D_RGBA(0xff, 0xff, 0xff, 0x80)); } }
int Predictor_New(ParametersType *Parameters, MatrixDataType *MatrixData, FemStructsType *FemStructs, FemFunctionsType *FemFunctions, FemOtherFunctionsType *FemOtherFunctions) { int I, i; int nel, neq, passo; double t, dt, alpha, norm_a, norm_Da, tol_correction; double *a, *aB, *auxVec, *Da, *DaB, *u, *u_old, **R2, *R2aux, *invN2, **M2, *M2aux, *F; //Parametros do Preditor double *uB, *delta_old, *delta_old_NMV; AuxBuildStructuresType *AuxBuild; nel = Parameters->nel; neq = Parameters->neq; a = (double*) mycalloc("a of 'Preditor_New'", neq + 1, sizeof(double)); aB = (double*) mycalloc("aB of 'Preditor_New'",NDOF*nel, sizeof(double)); Da = (double*) mycalloc("Da of 'Preditor_New'", neq + 1, sizeof(double)); DaB = (double*) mycalloc("DaB of 'Preditor_New'", NDOF*nel, sizeof(double)); auxVec = (double*) mycalloc("auxVec of 'Preditor_New'", neq + 1, sizeof(double)); u_old = (double*) mycalloc("u_old of 'Preditor_New'", neq + 1, sizeof(double)); R2 = (double**) mycalloc("R2 of 'Preditor_New'", nel, sizeof(double)); R2aux = (double *) mycalloc("R2aux of 'Preditor_New'", NDOF*nel, sizeof(double)); for (I = 0; I < nel;I++) R2[I] = &R2aux[NDOF*I]; invN2 = (double*) mycalloc("invN2 of 'Preditor_New'", nel, sizeof(double)); M2 = (double **) mycalloc("M2 of 'Preditor_New'", nel, sizeof(double*)); M2aux = (double *) mycalloc("M2aux of 'Preditor_New'", NNOEL*NDOF*NDOF*nel, sizeof(double)); for (I = 0; I < nel;I++) M2[I] = &M2aux[NNOEL*NDOF*NDOF*I]; uB = (double*) mycalloc("uB of 'Preditor_New'", nel*NDOF, sizeof(double)); delta_old = (double*) mycalloc("delta_old of 'Preditor_New'", nel, sizeof(double)); delta_old_NMV = (double*) mycalloc("delta_old of 'Preditor_New'", nel, sizeof(double)); u = FemStructs->u; F = FemStructs->F; dt = Parameters->DeltaT; Parameters->DeltaT_Build = dt; alpha = Parameters->Alpha; Parameters->Alpha_Build = alpha; tol_correction = Parameters->NonLinearTolerance; AuxBuild = (AuxBuildStructuresType*) mycalloc("AuxBuild of 'Predictor_New'",1,sizeof(AuxBuildStructuresType)); AuxBuild->tolerance = Parameters->StabilizationTolerance; AuxBuild->M2 = M2; AuxBuild->R2 = R2; AuxBuild->invN2 = invN2; AuxBuild->delta_old_NMV = delta_old_NMV; FemStructs->AuxBuild = AuxBuild; FemStructs->delta_old = delta_old; FemStructs->du = a; FemStructs->uB = uB; FemStructs->duB = aB; FemFunctions->InitialSolution(Parameters, FemStructs->Node, u); uB_InitialSolution(Parameters, FemStructs, FemFunctions, u, uB); t = 0.0; passo = 0; int tag = 1; do{ passo++; t += dt; #ifdef debug printf("\n\n Passo: %d\n", passo); #endif //PREDICAO i = 0; dmemcpy(neq, u, u_old); // copy u to u_old daxpy(neq, (1.0-alpha)*dt , a, u); // u = u + (1-alpha)*dt*a memsetzero(neq,a); // set 0 in a daxpy(nel*NDOF, (1.0-alpha)*dt , aB, uB); // uB = uB + (1-alpha)*dt*aB memsetzero(nel*NDOF,aB); // set 0 in aB // MULTICORRECAO do{ i++; FemOtherFunctions->Build(Parameters, MatrixData, FemStructs, FemFunctions); FemFunctions->scaling(Parameters, MatrixData, FemStructs); FemFunctions->precond_setup(Parameters, MatrixData, FemStructs, tag++, F); FemOtherFunctions->solver(Parameters, MatrixData, FemStructs, FemFunctions, F, Da); FemFunctions->unscaling(Parameters, MatrixData, FemStructs, Da); calculate_DaB(Parameters, FemStructs, FemFunctions, Da, DaB); daxpy(neq, 1, Da, a); daxpy(neq, alpha*dt, Da, u); daxpy(nel*NDOF, 1, DaB, aB); daxpy(nel*NDOF, alpha*dt, DaB, uB); norm_a = sqrt(ddot(neq, a, a)); norm_Da = sqrt(ddot(neq, Da, Da)); #ifdef debug double normF; normF = sqrt(ddot(neq, F, F)); printf("Tol_correction = %lf \t Norma_Res =%lf \t Norm a = %lf \t Norma Da = %lf \t t = %lf \t i = %d \n", tol_correction*norm_a, normF, norm_a, norm_Da, t, i); #endif }while(!FemFunctions->StopCriteria(Parameters,norm_a,norm_Da,i)); // end while multicorrection #ifdef debug printf("\n\n"); #endif }while(!FemFunctions->StopTimeIntegration(Parameters,u,u_old,t)); // end while time free(a); free(Da); free(u_old); free(auxVec); free(uB); free(DaB); free(delta_old); free(M2aux); free(M2); free(R2aux); free(R2); free(invN2); free(delta_old_NMV); free(AuxBuild); return 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; }
void G_PlayerReborn(int player) { player_t *p; int i; int frags[MAXPLAYERS]; int killcount; int itemcount; int secretcount; dboolean cards[NUMCARDS]; dboolean wpns[NUMWEAPONS]; int pammo[NUMAMMO]; int pmaxammo[NUMAMMO]; int artifacts; dboolean backpack; dmemcpy(frags, players[player].frags, sizeof(frags)); dmemcpy(cards, players[player].cards, sizeof(dboolean)*NUMCARDS); dmemcpy(wpns, players[player].weaponowned, sizeof(dboolean)*NUMWEAPONS); dmemcpy(pammo, players[player].ammo, sizeof(int)*NUMAMMO); dmemcpy(pmaxammo, players[player].maxammo, sizeof(int)*NUMAMMO); backpack = players[player].backpack; artifacts = players[player].artifacts; killcount = players[player].killcount; itemcount = players[player].itemcount; secretcount = players[player].secretcount; quakeviewx = 0; quakeviewy = 0; infraredFactor = 0; R_RefreshBrightness(); p = &players[player]; dmemset(p, 0, sizeof(*p)); dmemcpy(players[player].frags, frags, sizeof(players[player].frags)); players[player].killcount = killcount; players[player].itemcount = itemcount; players[player].secretcount = secretcount; p->usedown = p->attackdown = p->jumpdown = true; // don't do anything immediately p->playerstate = PST_LIVE; p->health = MAXHEALTH; p->readyweapon = p->pendingweapon = wp_pistol; p->weaponowned[wp_fist] = true; p->weaponowned[wp_pistol] = true; p->ammo[am_clip] = 50; p->recoilpitch = 0; for(i = 0; i < NUMAMMO; i++) { p->maxammo[i] = maxammo[i]; } if(netgame) { for(i = 0; i < NUMCARDS; i++) { players[player].cards[i] = cards[i]; } if(gameflags & GF_KEEPITEMS) { p->artifacts = artifacts; p->backpack = backpack; for(i = 0; i < NUMAMMO; i++) { p->ammo[i] = pammo[i]; p->maxammo[i] = pmaxammo[i]; } for(i = 0; i < NUMWEAPONS; i++) { p->weaponowned[i] = wpns[i]; } } } }
void G_Ticker(void) { int i; int buf; ticcmd_t* cmd; G_ActionTicker(); CON_Ticker(); if(savenow) { G_DoSaveGame(); savenow = false; } if(gameaction == ga_screenshot) { M_ScreenShot(); gameaction = ga_nothing; } if(paused & 2 || (!demoplayback && menuactive && !netgame)) { basetic++; // For tracers and RNG -- we must maintain sync } else { // get commands, check consistency, // and build new consistency check buf = (gametic / ticdup) % BACKUPTICS; for(i = 0; i < MAXPLAYERS; i++) { if(playeringame[i]) { cmd = &players[i].cmd; dmemcpy(cmd, &netcmds[i][buf], sizeof(ticcmd_t)); // // 20120404 villsa - make sure gameaction isn't set to anything before // reading a demo lump // if(demoplayback && gameaction == ga_nothing) { G_ReadDemoTiccmd(cmd); } if(demorecording) { G_WriteDemoTiccmd(cmd); if(endDemo == true) { G_CheckDemoStatus(); } } if(netgame && !netdemo && !(gametic % ticdup)) { if(gametic > BACKUPTICS && consistency[i][buf] != cmd->consistency) { I_Error("consistency failure (%i should be %i)", cmd->consistency, consistency[i][buf], consoleplayer); } if(players[i].mo) { consistency[i][buf] = players[i].mo->x; } else { consistency[i][buf] = 0; } } } } } // check for special buttons for(i = 0; i < MAXPLAYERS; i++) { if(playeringame[i]) { if(players[i].cmd.buttons & BT_SPECIAL) { /*villsa - fixed crash when player restarts level after dying Changed switch statments to if statments*/ if((players[i].cmd.buttons & BT_SPECIALMASK) == BTS_PAUSE) { paused ^= 1; if(paused) { S_PauseSound(); } else { S_ResumeSound(); } } if((players[i].cmd.buttons & BT_SPECIALMASK) == BTS_SAVEGAME) { if(!savedescription[0]) { dstrcpy(savedescription, "NET GAME"); } savegameslot = (players[i].cmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT; savenow = true; } } } } }