/* * Handle character death */ void death_screen(void) { bool done = FALSE; const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Retire in the town in a good state */ if (p_ptr->total_winner) { p_ptr->depth = 0; my_strcpy(p_ptr->died_from, "Ripe Old Age", sizeof(p_ptr->died_from)); p_ptr->exp = p_ptr->max_exp; p_ptr->lev = p_ptr->max_lev; p_ptr->au += 10000000L; display_winner(); } /* Get time of death */ (void)time(&death_time); print_tomb(); death_knowledge(); enter_score(&death_time); /* Flush all input and output */ flush(); message_flush(); /* Display and use the death menu */ if (!death_menu) { death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; } menu_layout(death_menu, &area); while (!done) { ui_event e = menu_select(death_menu, EVT_KBRD); if (e.type == EVT_KBRD) { if (e.key.code == KTRL('X')) break; } else if (e.type == EVT_SELECT) { done = get_check("Do you want to quit? "); } } /* Save dead player */ if (!savefile_save(savefile)) { msg("death save failed!"); message_flush(); } }
/* * Handle character death */ void death_screen(void) { const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Retire in the town in a good state */ if (p_ptr->total_winner) { p_ptr->depth = 0; my_strcpy(p_ptr->died_from, "Ripe Old Age", sizeof(p_ptr->died_from)); p_ptr->exp = p_ptr->max_exp; p_ptr->lev = p_ptr->max_lev; p_ptr->au += 10000000L; display_winner(); } /* Save dead player */ if (!savefile_save(savefile)) { msg("death save failed!"); message_flush(); } /* Get time of death */ (void)time(&death_time); print_tomb(); death_knowledge(); enter_score(&death_time); /* Flush all input and output */ flush(); message_flush(); if (!death_menu) { death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; } menu_layout(death_menu, &area); do { menu_select(death_menu, 0); } while (!get_check("Do you want to quit? ")); }
void play_the_game(t_rows **begin) { int i; i = 0; while ((*begin)->line[0] != 0) { get_play(begin, i); if ((*begin)->line[0] == '\0' && (*begin)->next) delete_row(begin); i++; } free((*begin)->line); free(*begin); display_winner(i); }
void player_death(void) { /* Try to make a player ghost template */ add_player_ghost_entry(); /* Retire in the town in a good state */ if (p_ptr->total_winner) { p_ptr->depth = 0; p_ptr->died_from = "Ripe Old Age"; p_ptr->exp = p_ptr->max_exp; p_ptr->lev = p_ptr->max_lev; p_ptr->au += 10000000L; display_winner(); } QDate today = QDate::currentDate(); QTime right_now = QTime::currentTime(); QString long_day = QString("%1 at %2") .arg(today.toString()) .arg(right_now.toString()); write_death_note(long_day); print_tomb(); death_knowledge(); enter_score(long_day); /* Save dead player */ if (!save_player()) { message(QString("death save failed!")); } // Hack - update everything onscreen ui_redraw_all(); // Automatic character dump if (death_char_dump) { save_character_file(); save_screenshot(FALSE); } p_ptr->in_death_menu = TRUE; PlayerDeathDialog(); p_ptr->in_death_menu = FALSE; }
/** * Handle character death */ void death_screen(void) { struct menu *death_menu; bool done = false; const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Winner */ if (player->total_winner) { display_winner(); } /* Tombstone */ print_tomb(); /* Flush all input and output */ event_signal(EVENT_INPUT_FLUSH); event_signal(EVENT_MESSAGE_FLUSH); /* Display and use the death menu */ death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; menu_layout(death_menu, &area); while (!done) { ui_event e = menu_select(death_menu, EVT_KBRD, false); if (e.type == EVT_KBRD) { if (e.key.code == KTRL('X')) break; } else if (e.type == EVT_SELECT) { done = get_check("Do you want to quit? "); } } menu_free(death_menu); }
int main(int argc, char **argv) { FILE *port; char *filename; int c, i, j, tmp; int debugmode = 0; int lanes; float times[MAX_LANES]; float prev_times[MAX_LANES][4]; int prev_head = 0;\ char *tmpbuf[10]; /* parse command line options */ if (argc == 1) { usage(); return 0; } opterr = 0; while ((c = getopt (argc, argv, "dp:")) != -1) { switch (c) { case 'd': printf("Debugging mode enabled\n"); debugmode = 1; break; case 'p': filename = optarg; break; case '?': default: usage(); return 1; } } /* open timer */ port = open_timer(filename, !debugmode); if (!port) { fprintf(stderr, "Eek! Unable to open timer port! Cannot continue.\n"); fprintf(stderr, "Possible problems:\n"); fprintf(stderr, "\tbad filename for port (if USB timer, check dmesg for port id\n"); fprintf(stderr, "\tno write access to device (check permissions or run as root)\n"); fprintf(stderr, "\tUSB timer not connected\n"); return 1; } /* reset timer */ lanes = init_timer(port); if (!lanes) { fprintf(stderr, "Eek! Cannot initialize timer! Cannot continue!\n"); fprintf(stderr, "Make sure your timer is supported by this program.\n"); close_timer(port); return 1; } memset(prev_times, 0, sizeof(float) * 3 * MAX_LANES); printf("Press enter to continue.\n"); fgets(tmpbuf, 10, stdin); /* main loop */ while (1) { printf("Begin racing when ready.\n"); tmp = get_times(port, lanes, times, debugmode); printf("Run is complete. Results:\n"); if (tmp > 0) { /* good race! */ display_winner(tmp); printf("\n"); // save current time, drop last time display_times(lanes, times); for (j = 0; j < lanes; j++) { prev_times[j][prev_head] = times[j]; } printf("\nPrevious results:\n"); i = prev_head - 1; if (i < 0) i = 3; while (i != prev_head) { for (j = 0; j < lanes; j++) printf("\t%1.4f", prev_times[j][i]); printf("\n"); i--; if (i < 0) i = 3; } prev_head++; if (prev_head == 4) prev_head = 0; } if (tmp == 0) { printf("Null race result! Please redo this run.\n"); } if (tmp < 0) { port = reinit_timer(port, filename, !debugmode, lanes); /* if this returns, we've succeeded */ } printf("Press enter to continue, X to exit.\n"); fgets(tmpbuf, 10, stdin); if (strchr(tmpbuf, 'x') || strchr(tmpbuf, 'X')) break; rearm_timer(port, debugmode); } /* all done */ printf("\nDone.\n"); close_timer(port); return 0; }