static void PlayerQuitGame(player_t *player) { static char exitmsg[80]; unsigned int player_num; player_num = player - players; // Note: // The Heretic source code does this, which doesn't actually work. // As a result, the exit message is never seen. M_StringCopy(exitmsg, "PLAYER 1 LEFT THE GAME", sizeof(exitmsg)); exitmsg[7] += player_num; players[consoleplayer].message = exitmsg; playeringame[player_num] = false; players[consoleplayer].message = exitmsg; // TODO: check if it is sensible to do this: if (demorecording) { G_CheckDemoStatus (); } }
void I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ if (demorecording) G_CheckDemoStatus(); }
static void PlayerQuitGame(player_t *player) { static char exitmsg[80]; unsigned int player_num; player_num = player - players; // Do this the same way as Vanilla Doom does, to allow dehacked // replacements of this message M_StringCopy(exitmsg, DEH_String("Player 1 left the game"), sizeof(exitmsg)); exitmsg[7] += player_num; playeringame[player_num] = false; players[consoleplayer].message = exitmsg; // [crispy] don't interpolate players who left the game player->mo->interp = false; // TODO: check if it is sensible to do this: if (demorecording) { G_CheckDemoStatus (); } }
void G_ReadDemoTiccmd(ticcmd_t * cmd) { if (*demo_p == DEMOMARKER) { // end of demo data stream G_CheckDemoStatus(); return; } cmd->forwardmove = ((signed char) *demo_p++); cmd->sidemove = ((signed char) *demo_p++); // If this is a longtics demo, read back in higher resolution if (longtics) { cmd->angleturn = *demo_p++; cmd->angleturn |= (*demo_p++) << 8; } else { cmd->angleturn = ((unsigned char) *demo_p++) << 8; } cmd->buttons = (unsigned char) *demo_p++; cmd->lookfly = (unsigned char) *demo_p++; cmd->arti = (unsigned char) *demo_p++; }
void I_Error (char *error, ...) { va_list argptr; if (already_quitting) { fprintf(stderr, "Warning: recursive call to I_Error detected.\n"); exit(-1); } else { already_quitting = true; } // Message first. va_start(argptr, error); fprintf(stderr, "\nError: "); vfprintf(stderr, error, argptr); fprintf(stderr, "\n"); va_end(argptr); fflush(stderr); // Shutdown. Here might be other errors. if (demorecording) { G_CheckDemoStatus(); } D_QuitNetGame (); I_ShutdownGraphics(); S_Shutdown(); #ifdef _WIN32 // On Windows, pop up a dialog box with the error message. { char msgbuf[512]; wchar_t wmsgbuf[512]; va_start(argptr, error); memset(msgbuf, 0, sizeof(msgbuf)); vsnprintf(msgbuf, sizeof(msgbuf) - 1, error, argptr); va_end(argptr); MultiByteToWideChar(CP_ACP, 0, msgbuf, strlen(msgbuf) + 1, wmsgbuf, sizeof(wmsgbuf)); MessageBoxW(NULL, wmsgbuf, L"Error", MB_OK); } #endif // abort(); exit(-1); }
void I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ if (demorecording) G_CheckDemoStatus(); // [BC] Support for client-side demos. if ( CLIENTDEMO_IsRecording( )) CLIENTDEMO_FinishRecording( ); }
void STACK_ARGS I_Quit (void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ if (TimerEventID) timeKillEvent (TimerEventID); if (NewTicArrived) CloseHandle (NewTicArrived); timeEndPeriod (TimerPeriod); if (demorecording) G_CheckDemoStatus(); G_ClearSnapshots (); }
void I_Quit() { HasExited = true; /* Prevent infinitely recursive exits -- killough */ if (TimerEventID != 0) { timeKillEvent(TimerEventID); } if (NewTicArrived != NULL) { CloseHandle(NewTicArrived); } timeEndPeriod(TimerPeriod); if (demorecording) { G_CheckDemoStatus(); } }
void G_ReadDemoTiccmd(ticcmd_t* cmd) { unsigned int lowbyte; if(*demo_p == DEMOMARKER) { // end of demo data stream G_CheckDemoStatus(); return; } cmd->forwardmove = ((signed char)*demo_p++); cmd->sidemove = ((signed char)*demo_p++); lowbyte = (unsigned char)(*demo_p++); cmd->angleturn = (((signed int)(*demo_p++)) << 8) + lowbyte; lowbyte = (unsigned char)(*demo_p++); cmd->pitch = (((signed int)(*demo_p++)) << 8) + lowbyte; cmd->buttons = (unsigned char)*demo_p++; cmd->buttons2 = (unsigned char)*demo_p++; }
void I_Error (char *error, ...) { va_list arglist; printf("Error: "); va_start(arglist, error); vprintf(error, arglist); printf("\n"); va_end(arglist); // Shutdown. Here might be other errors. if (demorecording) G_CheckDemoStatus(); D_QuitNetGame (); I_ShutdownGraphics(); exit(-1); }
static void NET_CL_PlayerQuitGame(player_t *player) { static char exitmsg[80]; // Do this the same way as Vanilla Doom does, to allow dehacked // replacements of this message strcpy(exitmsg, DEH_String("Player 1 left the game")); exitmsg[7] += player - players; players[consoleplayer].message = exitmsg; // TODO: check if it is sensible to do this: if (demorecording) { G_CheckDemoStatus (); } }
void I_Quit (void) { D_QuitNetGame (); G_CheckDemoStatus(); S_Shutdown(); if (!screensaver_mode) { M_SaveDefaults (); } I_ShutdownGraphics(); if (show_endoom && !testcontrols && !screensaver_mode) { I_Endoom(); } exit(0); }
static void PlayerQuitGame(player_t *player) { static char exitmsg[80]; unsigned int player_num; player_num = player - players; M_StringCopy(exitmsg, "PLAYER 1 LEFT THE GAME", sizeof(exitmsg)); exitmsg[7] += player_num; P_SetMessage(&players[consoleplayer], exitmsg, true); S_StartSound(NULL, SFX_CHAT); playeringame[player_num] = false; // TODO: check if it is sensible to do this: if (demorecording) { G_CheckDemoStatus (); } }
void I_Error (char *error, ...) { va_list argptr; // Message first. va_start (argptr,error); printf ("Error: "); printf (error,argptr); printf ("\n\r"); va_end (argptr); // Shutdown. Here might be other errors. if (demorecording) G_CheckDemoStatus(); D_QuitNetGame (); I_ShutdownGraphics(); sound_state=0; // getch(); exit(-1); }
void G_WriteDemoTiccmd(ticcmd_t * cmd) { byte *demo_start; if (gamekeydown[key_demo_quit]) // press to end demo recording G_CheckDemoStatus(); demo_start = demo_p; *demo_p++ = cmd->forwardmove; *demo_p++ = cmd->sidemove; // If this is a longtics demo, record in higher resolution if (longtics) { *demo_p++ = (cmd->angleturn & 0xff); *demo_p++ = (cmd->angleturn >> 8) & 0xff; } else {
void G_DoCompleted(void) { int i; static int afterSecret[5] = { 7, 5, 5, 5, 4 }; gameaction = ga_nothing; // quit demo unless -demoextend if (!demoextend && G_CheckDemoStatus()) { return; } for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { G_PlayerFinishLevel(i); } } prevmap = gamemap; if (secretexit == true) { gamemap = 9; } else if (gamemap == 9) { // Finished secret level gamemap = afterSecret[gameepisode - 1]; } else if (gamemap == 8) { gameaction = ga_victory; return; } else { gamemap++; } gamestate = GS_INTERMISSION; IN_Start(); }
void I_Error (const char *error, ...) { va_list argptr; // Message first. va_start (argptr,error); fprintf (stderr, "Error: "); vfprintf (stderr,error,argptr); fprintf (stderr, "\n"); va_end (argptr); fflush( stderr ); // Shutdown. Here might be other errors. if (demorecording) G_CheckDemoStatus(); D_QuitNetGame (); I_ShutdownGraphics(); exit(-1); }
void I_Error (char *error, ...) { //printf("I_Error: %s\n", error); va_list argptr; static char string[1024]; // Message first. va_start (argptr,error); vsprintf (string, error ,argptr); /* Vladimir fprintf (stderr, "Error: "); vfprintf ( stderr,error,argptr); fprintf (stderr, "\n"); printf ( "Error: "); vprintf (error,argptr); printf ("\n"); */ va_end (argptr); // Vladimir fflush( stderr ); // Shutdown. Here might be other errors. if (demorecording) G_CheckDemoStatus(); // Vladimir D_QuitNetGame (); I_ShutdownGraphics(); // Send the error back to JNI layer jni_fatal_error(string); // Vladimir JNI Change: The Lib will not terminate to let Java know // Something wrong has happened //exit(-1); }
void G_DoReborn(int playernum) { int i; // quit demo unless -demoextend if (!demoextend && G_CheckDemoStatus()) return; if (!netgame) gameaction = ga_loadlevel; // reload the level from scratch else { // respawn at the start players[playernum].mo->player = NULL; // dissasociate the corpse // spawn at random spot if in death match if (deathmatch) { G_DeathMatchSpawnPlayer(playernum); return; } if (G_CheckSpot(playernum, &playerstarts[playernum])) { P_SpawnPlayer(&playerstarts[playernum]); return; } // try to spawn at one of the other players spots for (i = 0; i < MAXPLAYERS; i++) if (G_CheckSpot(playernum, &playerstarts[i])) { playerstarts[i].type = playernum + 1; // fake as other player P_SpawnPlayer(&playerstarts[i]); playerstarts[i].type = i + 1; // restore return; } // he's going to be inside something. Too bad. P_SpawnPlayer(&playerstarts[playernum]); } }
// // I_Quit // // Primary atexit routine for shutting down the game engine. // void I_Quit(void) { has_exited = 1; /* Prevent infinitely recursive exits -- killough */ // haleyjd 06/05/10: not in fatal error situations; causes heap calls if(error_exitcode < I_ERRORLEVEL_FATAL && demorecording) G_CheckDemoStatus(); // sf : rearrange this so the errmsg doesn't get messed up if(error_exitcode >= I_ERRORLEVEL_MESSAGE) puts(errmsg); // killough 8/8/98 else I_EndDoom(); // SoM: 7/5/2002: Why I didn't remember this in the first place I'll never know. // haleyjd 10/09/05: moved down here SDL_Quit(); // haleyjd 03/18/10: none of these should be called in fatal error situations. // 06/06/10: check each call, as an I_FatalError called from any of this // code could escalate the error status. IFNOTFATAL(M_SaveDefaults()); IFNOTFATAL(M_SaveSysConfig()); IFNOTFATAL(G_SaveDefaults()); // haleyjd #ifdef _MSC_VER // Under Visual C++, the console window likes to rudely slam // shut -- this can stop it, but is now optional except when an error occurs if(error_exitcode >= I_ERRORLEVEL_NORMAL || waitAtExit) { puts("Press any key to continue\n"); getch(); } #endif }
boolean MN_Responder(event_t *event) { int key; int i; MenuItem_t *item; extern boolean automapactive; static boolean shiftdown; extern void D_StartTitle(void); extern void G_CheckDemoStatus(void); char *textBuffer; if(event->data1 == KEY_RSHIFT) { shiftdown = (event->type == ev_keydown); } if(event->type != ev_keydown) { return(false); } key = event->data1; if(InfoType) { if(shareware) { InfoType = (InfoType+1)%5; } else { InfoType = (InfoType+1)%4; } if(key == KEY_ESCAPE) { InfoType = 0; } if(!InfoType) { paused = false; MN_DeactivateMenu(); SB_state = -1; //refresh the statbar BorderNeedRefresh = true; } S_StartSound(NULL, sfx_dorcls); return(true); //make the info screen eat the keypress } if(ravpic && key == KEY_F1) { G_ScreenShot(); return(true); } if(askforquit) { switch(key) { case 'y': if(askforquit) { switch(typeofask) { case 1: G_CheckDemoStatus(); I_Quit(); break; case 2: players[consoleplayer].messageTics = 0; //set the msg to be cleared players[consoleplayer].message = NULL; typeofask = 0; askforquit = false; paused = false; I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); D_StartTitle(); // go to intro/demo mode. break; case 3: P_SetMessage(&players[consoleplayer], "QUICKSAVING....", false); FileMenuKeySteal = true; SCSaveGame(quicksave-1); askforquit = false; typeofask = 0; BorderNeedRefresh = true; return true; case 4: P_SetMessage(&players[consoleplayer], "QUICKLOADING....", false); SCLoadGame(quickload-1); askforquit = false; typeofask = 0; BorderNeedRefresh = true; return true; default: return true; // eat the 'y' keypress } } return false; case 'n': case KEY_ESCAPE: if(askforquit) { players[consoleplayer].messageTics = 1; //set the msg to be cleared askforquit = false; typeofask = 0; paused = false; UpdateState |= I_FULLSCRN; BorderNeedRefresh = true; return true; } return false; } return false; // don't let the keys filter thru } if(MenuActive == false && !chatmodeon) { switch(key) { case KEY_MINUS: if(automapactive) { // Don't screen size in automap return(false); } SCScreenSize(LEFT_DIR); S_StartSound(NULL, sfx_keyup); BorderNeedRefresh = true; UpdateState |= I_FULLSCRN; return(true); case KEY_EQUALS: if(automapactive) { // Don't screen size in automap return(false); } SCScreenSize(RIGHT_DIR); S_StartSound(NULL, sfx_keyup); BorderNeedRefresh = true; UpdateState |= I_FULLSCRN; return(true); #ifndef __NeXT__ case KEY_F1: // help screen SCInfo(0); // start up info screens MenuActive = true; return(true); case KEY_F2: // save game if(gamestate == GS_LEVEL && !demoplayback) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &SaveMenu; CurrentItPos = CurrentMenu->oldItPos; if(!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed } return true; case KEY_F3: // load game if(SCNetCheck(2)) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &LoadMenu; CurrentItPos = CurrentMenu->oldItPos; if(!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed } return true; case KEY_F4: // volume MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &Options2Menu; CurrentItPos = CurrentMenu->oldItPos; if(!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed return true; case KEY_F5: // F5 isn't used in Heretic. (detail level) return true; case KEY_F6: // quicksave if(gamestate == GS_LEVEL && !demoplayback) { if(!quicksave || quicksave == -1) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &SaveMenu; CurrentItPos = CurrentMenu->oldItPos; if(!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed quicksave = -1; P_SetMessage(&players[consoleplayer], "CHOOSE A QUICKSAVE SLOT", true); } else { askforquit = true; typeofask = 3; if(!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_chat); } } return true; case KEY_F7: // endgame if(gamestate == GS_LEVEL && !demoplayback) { S_StartSound(NULL, sfx_chat); SCEndGame(0); } return true; case KEY_F8: // toggle messages SCMessages(0); return true; case KEY_F9: // quickload if(!quickload || quickload == -1) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &LoadMenu; CurrentItPos = CurrentMenu->oldItPos; if(!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed quickload = -1; P_SetMessage(&players[consoleplayer], "CHOOSE A QUICKLOAD SLOT", true); } else { askforquit = true; if(!netgame && !demoplayback) { paused = true; } typeofask = 4; S_StartSound(NULL, sfx_chat); } return true; case KEY_F10: // quit if(gamestate == GS_LEVEL) { SCQuitGame(0); S_StartSound(NULL, sfx_chat); } return true; case KEY_F11: // F11 - gamma mode correction usegamma++; if(usegamma > 4) { usegamma = 0; } I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE)); return true; #endif } } if(MenuActive == false) { if(key == KEY_ESCAPE || gamestate == GS_DEMOSCREEN || demoplayback) { MN_ActivateMenu(); return(true); } return(false); } if(!FileMenuKeySteal) { item = &CurrentMenu->items[CurrentItPos]; switch(key) { case KEY_DOWNARROW: do { if(CurrentItPos+1 > CurrentMenu->itemCount-1) { CurrentItPos = 0; } else { CurrentItPos++; } } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); S_StartSound(NULL, sfx_switch); return(true); break; case KEY_UPARROW: do { if(CurrentItPos == 0) { CurrentItPos = CurrentMenu->itemCount-1; } else { CurrentItPos--; } } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); S_StartSound(NULL, sfx_switch); return(true); break; case KEY_LEFTARROW: if(item->type == ITT_LRFUNC && item->func != NULL) { item->func(LEFT_DIR); S_StartSound(NULL, sfx_keyup); } return(true); break; case KEY_RIGHTARROW: if(item->type == ITT_LRFUNC && item->func != NULL) { item->func(RIGHT_DIR); S_StartSound(NULL, sfx_keyup); } return(true); break; case KEY_ENTER: if(item->type == ITT_SETMENU) { SetMenu(item->menu); } else if(item->func != NULL) { CurrentMenu->oldItPos = CurrentItPos; if(item->type == ITT_LRFUNC) { item->func(RIGHT_DIR); } else if(item->type == ITT_EFUNC) { if(item->func(item->option)) { if(item->menu != MENU_NONE) { SetMenu(item->menu); } } } } S_StartSound(NULL, sfx_dorcls); return(true); break; case KEY_ESCAPE: MN_DeactivateMenu(); return(true); case KEY_BACKSPACE: S_StartSound(NULL, sfx_switch); if(CurrentMenu->prevMenu == MENU_NONE) { MN_DeactivateMenu(); } else { SetMenu(CurrentMenu->prevMenu); } return(true); default: for(i = 0; i < CurrentMenu->itemCount; i++) { if(CurrentMenu->items[i].text) { if(toupper(key) == toupper(CurrentMenu->items[i].text[0])) { CurrentItPos = i; return(true); } } } break; } return(false); } else { // Editing file names textBuffer = &SlotText[currentSlot][slotptr]; if(key == KEY_BACKSPACE) { if(slotptr) { *textBuffer-- = 0; *textBuffer = ASCII_CURSOR; slotptr--; } return(true); } if(key == KEY_ESCAPE) { memset(SlotText[currentSlot], 0, SLOTTEXTLEN+2); strcpy(SlotText[currentSlot], oldSlotText); SlotStatus[currentSlot]--; MN_DeactivateMenu(); return(true); } if(key == KEY_ENTER) { SlotText[currentSlot][slotptr] = 0; // clear the cursor item = &CurrentMenu->items[CurrentItPos]; CurrentMenu->oldItPos = CurrentItPos; if(item->type == ITT_EFUNC) { item->func(item->option); if(item->menu != MENU_NONE) { SetMenu(item->menu); } } return(true); } if(slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE) { if((key >= 'a' && key <= 'z')) { *textBuffer++ = key-32; *textBuffer = ASCII_CURSOR; slotptr++; return(true); } if(((key >= '0' && key <= '9') || key == ' ' || key == ',' || key == '.' || key == '-') && !shiftdown) { *textBuffer++ = key; *textBuffer = ASCII_CURSOR; slotptr++; return(true); } if(shiftdown && key == '1') { *textBuffer++ = '!'; *textBuffer = ASCII_CURSOR; slotptr++; return(true); } } return(true); } return(false); }
static void G_CheckDemoStatusAtExit (void) { G_CheckDemoStatus(); }
boolean MN_Responder(event_t * event) { int charTyped; int key; int i; MenuItem_t *item; extern boolean automapactive; extern void D_StartTitle(void); extern void G_CheckDemoStatus(void); char *textBuffer; // In testcontrols mode, none of the function keys should do anything // - the only key is escape to quit. if (testcontrols) { if (event->type == ev_quit || (event->type == ev_keydown && (event->data1 == key_menu_activate || event->data1 == key_menu_quit))) { I_Quit(); return true; } return false; } // "close" button pressed on window? if (event->type == ev_quit) { // First click on close = bring up quit confirm message. // Second click = confirm quit. if (!MenuActive && askforquit && typeofask == 1) { G_CheckDemoStatus(); I_Quit(); } else { SCQuitGame(0); S_StartSound(NULL, sfx_chat); } return true; } // Allow the menu to be activated from a joystick button if a button // is bound for joybmenu. if (event->type == ev_joystick) { if (joybmenu >= 0 && (event->data1 & (1 << joybmenu)) != 0) { MN_ActivateMenu(); return true; } } if (event->type != ev_keydown) { return false; } key = event->data1; charTyped = event->data2; if (InfoType) { if (gamemode == shareware) { InfoType = (InfoType + 1) % 5; } else { InfoType = (InfoType + 1) % 4; } if (key == KEY_ESCAPE) { InfoType = 0; } if (!InfoType) { paused = false; MN_DeactivateMenu(); SB_state = -1; //refresh the statbar BorderNeedRefresh = true; } S_StartSound(NULL, sfx_dorcls); return (true); //make the info screen eat the keypress } if ((ravpic && key == KEY_F1) || (key != 0 && key == key_menu_screenshot)) { G_ScreenShot(); return (true); } if (askforquit) { if (key == key_menu_confirm) { switch (typeofask) { case 1: G_CheckDemoStatus(); I_Quit(); return false; case 2: players[consoleplayer].messageTics = 0; //set the msg to be cleared players[consoleplayer].message = NULL; paused = false; I_SetPalette(W_CacheLumpName ("PLAYPAL", PU_CACHE)); D_StartTitle(); // go to intro/demo mode. break; case 3: P_SetMessage(&players[consoleplayer], "QUICKSAVING....", false); FileMenuKeySteal = true; SCSaveGame(quicksave - 1); BorderNeedRefresh = true; break; case 4: P_SetMessage(&players[consoleplayer], "QUICKLOADING....", false); SCLoadGame(quickload - 1); BorderNeedRefresh = true; break; default: break; } askforquit = false; typeofask = 0; return true; } else if (key == key_menu_abort || key == KEY_ESCAPE) { players[consoleplayer].messageTics = 1; //set the msg to be cleared askforquit = false; typeofask = 0; paused = false; UpdateState |= I_FULLSCRN; BorderNeedRefresh = true; return true; } return false; // don't let the keys filter thru } if (!MenuActive && !chatmodeon) { if (key == key_menu_decscreen) { if (automapactive) { // Don't screen size in automap return (false); } SCScreenSize(LEFT_DIR); S_StartSound(NULL, sfx_keyup); BorderNeedRefresh = true; UpdateState |= I_FULLSCRN; return (true); } else if (key == key_menu_incscreen) { if (automapactive) { // Don't screen size in automap return (false); } SCScreenSize(RIGHT_DIR); S_StartSound(NULL, sfx_keyup); BorderNeedRefresh = true; UpdateState |= I_FULLSCRN; return (true); } else if (key == key_menu_help) // F1 { SCInfo(0); // start up info screens MenuActive = true; return (true); } else if (key == key_menu_save) // F2 (save game) { if (gamestate == GS_LEVEL && !demoplayback) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &SaveMenu; CurrentItPos = CurrentMenu->oldItPos; if (!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed } return true; } else if (key == key_menu_load) // F3 (load game) { if (SCNetCheck(2)) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &LoadMenu; CurrentItPos = CurrentMenu->oldItPos; if (!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed } return true; } else if (key == key_menu_volume) // F4 (volume) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &Options2Menu; CurrentItPos = CurrentMenu->oldItPos; if (!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed return true; } else if (key == key_menu_detail) // F5 (detail) { // F5 isn't used in Heretic. (detail level) return true; } else if (key == key_menu_qsave) // F6 (quicksave) { if (gamestate == GS_LEVEL && !demoplayback) { if (!quicksave || quicksave == -1) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &SaveMenu; CurrentItPos = CurrentMenu->oldItPos; if (!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed quicksave = -1; P_SetMessage(&players[consoleplayer], "CHOOSE A QUICKSAVE SLOT", true); } else { askforquit = true; typeofask = 3; if (!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_chat); } } return true; } else if (key == key_menu_endgame) // F7 (end game) { if (gamestate == GS_LEVEL && !demoplayback) { S_StartSound(NULL, sfx_chat); SCEndGame(0); } return true; } else if (key == key_menu_messages) // F8 (toggle messages) { SCMessages(0); return true; } else if (key == key_menu_qload) // F9 (quickload) { if (!quickload || quickload == -1) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &LoadMenu; CurrentItPos = CurrentMenu->oldItPos; if (!netgame && !demoplayback) { paused = true; } S_StartSound(NULL, sfx_dorcls); slottextloaded = false; //reload the slot text, when needed quickload = -1; P_SetMessage(&players[consoleplayer], "CHOOSE A QUICKLOAD SLOT", true); } else { askforquit = true; if (!netgame && !demoplayback) { paused = true; } typeofask = 4; S_StartSound(NULL, sfx_chat); } return true; } else if (key == key_menu_quit) // F10 (quit) { if (gamestate == GS_LEVEL) { SCQuitGame(0); S_StartSound(NULL, sfx_chat); } return true; } else if (key == key_menu_gamma) // F11 (gamma correction) { usegamma++; if (usegamma > 4) { usegamma = 0; } I_SetPalette((byte *) W_CacheLumpName("PLAYPAL", PU_CACHE)); return true; } } if (!MenuActive) { if (key == key_menu_activate || gamestate == GS_DEMOSCREEN || demoplayback) { MN_ActivateMenu(); return (true); } return (false); } if (!FileMenuKeySteal) { item = &CurrentMenu->items[CurrentItPos]; if (key == key_menu_down) // Next menu item { do { if (CurrentItPos + 1 > CurrentMenu->itemCount - 1) { CurrentItPos = 0; } else { CurrentItPos++; } } while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); S_StartSound(NULL, sfx_switch); return (true); } else if (key == key_menu_up) // Previous menu item { do { if (CurrentItPos == 0) { CurrentItPos = CurrentMenu->itemCount - 1; } else { CurrentItPos--; } } while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); S_StartSound(NULL, sfx_switch); return (true); } else if (key == key_menu_left) // Slider left { if (item->type == ITT_LRFUNC && item->func != NULL) { item->func(LEFT_DIR); S_StartSound(NULL, sfx_keyup); } return (true); } else if (key == key_menu_right) // Slider right { if (item->type == ITT_LRFUNC && item->func != NULL) { item->func(RIGHT_DIR); S_StartSound(NULL, sfx_keyup); } return (true); } else if (key == key_menu_forward) // Activate item (enter) { if (item->type == ITT_SETMENU) { SetMenu(item->menu); } else if (item->func != NULL) { CurrentMenu->oldItPos = CurrentItPos; if (item->type == ITT_LRFUNC) { item->func(RIGHT_DIR); } else if (item->type == ITT_EFUNC) { if (item->func(item->option)) { if (item->menu != MENU_NONE) { SetMenu(item->menu); } } } } S_StartSound(NULL, sfx_dorcls); return (true); } else if (key == key_menu_activate) // Toggle menu { MN_DeactivateMenu(); return (true); } else if (key == key_menu_back) // Go back to previous menu { S_StartSound(NULL, sfx_switch); if (CurrentMenu->prevMenu == MENU_NONE) { MN_DeactivateMenu(); } else { SetMenu(CurrentMenu->prevMenu); } return (true); } else if (charTyped != 0) { // Jump to menu item based on first letter: for (i = 0; i < CurrentMenu->itemCount; i++) { if (CurrentMenu->items[i].text) { if (toupper(charTyped) == toupper(DEH_String(CurrentMenu->items[i].text)[0])) { CurrentItPos = i; return (true); } } } } return (false); } else { // Editing file names #ifndef USE_VIRTUALKEYBOARD textBuffer = &SlotText[currentSlot][slotptr]; if (key == KEY_BACKSPACE) { if (slotptr) { *textBuffer-- = 0; *textBuffer = ASCII_CURSOR; slotptr--; } return (true); } if (key == KEY_ESCAPE) { memset(SlotText[currentSlot], 0, SLOTTEXTLEN + 2); M_StringCopy(SlotText[currentSlot], oldSlotText, sizeof(SlotText[currentSlot])); SlotStatus[currentSlot]--; MN_DeactivateMenu(); return (true); } if (key == KEY_ENTER) { SlotText[currentSlot][slotptr] = 0; // clear the cursor item = &CurrentMenu->items[CurrentItPos]; CurrentMenu->oldItPos = CurrentItPos; if (item->type == ITT_EFUNC) { item->func(item->option); if (item->menu != MENU_NONE) { SetMenu(item->menu); } } return (true); } if (slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE) { if (isalpha(charTyped)) { *textBuffer++ = toupper(charTyped); *textBuffer = ASCII_CURSOR; slotptr++; return (true); } if (isdigit(charTyped) || charTyped == ' ' || charTyped == ',' || charTyped == '.' || charTyped == '-' || charTyped == '!') { *textBuffer++ = charTyped; *textBuffer = ASCII_CURSOR; slotptr++; return (true); } } #else if (key == KEY_BBUTTON) { memset(SlotText[currentSlot], 0, SLOTTEXTLEN + 2); M_StringCopy(SlotText[currentSlot], oldSlotText, sizeof(SlotText[currentSlot])); SlotStatus[currentSlot]--; MN_DeactivateMenu(); return (true); } if (key == KEY_ABUTTON) { SlotText[currentSlot][slotptr] = 0; // clear the cursor item = &CurrentMenu->items[CurrentItPos]; CurrentMenu->oldItPos = CurrentItPos; if (item->type == ITT_EFUNC) { item->func(item->option); if (item->menu != MENU_NONE) { SetMenu(item->menu); } } return (true); } #endif return (true); } return (false); }
void G_RecordDemo(const char* name) { byte *demostart, *dm_p; int i; demofp = NULL; endDemo = false; dstrcpy(demoname, name); dstrcat(demoname, ".lmp"); if(access(demoname, F_OK)) { demofp = fopen(demoname, "wb"); } else { int demonum = 0; while(demonum < 10000) { sprintf(demoname, "%s%i.lmp", name, demonum); if(access(demoname, F_OK)) { demofp = fopen(demoname, "wb"); break; } demonum++; } // so yeah... dunno how to properly handle this... if(demonum >= 10000) { I_Error("G_RecordDemo: file %s already exists", demoname); return; } } CON_DPrintf("--------Recording %s--------\n", demoname); demostart = dm_p = malloc(1000); G_InitNew(startskill, startmap); *dm_p++ = 'D'; *dm_p++ = 'M'; *dm_p++ = '6'; *dm_p++ = '4'; *dm_p++ = '\0'; *dm_p++ = gameskill; *dm_p++ = gamemap; *dm_p++ = deathmatch; *dm_p++ = respawnparm; *dm_p++ = respawnitem; *dm_p++ = fastparm; *dm_p++ = nomonsters; *dm_p++ = consoleplayer; *dm_p++ = (byte)((rngseed >> 24) & 0xff); *dm_p++ = (byte)((rngseed >> 16) & 0xff); *dm_p++ = (byte)((rngseed >> 8) & 0xff); *dm_p++ = (byte)( rngseed & 0xff); *dm_p++ = (byte)((gameflags >> 24) & 0xff); *dm_p++ = (byte)((gameflags >> 16) & 0xff); *dm_p++ = (byte)((gameflags >> 8) & 0xff); *dm_p++ = (byte)( gameflags & 0xff); *dm_p++ = (byte)((compatflags >> 24) & 0xff); *dm_p++ = (byte)((compatflags >> 16) & 0xff); *dm_p++ = (byte)((compatflags >> 8) & 0xff); *dm_p++ = (byte)( compatflags & 0xff); for(i = 0; i < MAXPLAYERS; i++) { *dm_p++ = playeringame[i]; } if(fwrite(demostart, 1, dm_p-demostart, demofp) != (size_t)(dm_p-demostart)) { I_Error("G_RecordDemo: Error writing demo header"); } free(demostart); demorecording = true; usergame = false; G_RunGame(); G_CheckDemoStatus(); }
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; } } } } }
void GetPackets (void) { int netconsole; int netnode; ticcmd_t *src, *dest; int realend; int realstart; while ( HGetPacket() ) { if (netbuffer->checksum & NCMD_SETUP) continue; // extra setup packet netconsole = netbuffer->player & ~PL_DRONE; netnode = doomcom->remotenode; // to save bytes, only the low byte of tic numbers are sent // Figure out what the rest of the bytes are realstart = ExpandTics (netbuffer->starttic); realend = (realstart+netbuffer->numtics); // check for exiting the game if (netbuffer->checksum & NCMD_EXIT) { if (!nodeingame[netnode]) continue; nodeingame[netnode] = false; playeringame[netconsole] = false; strcpy (exitmsg, "Player 1 left the game"); exitmsg[7] += netconsole; players[consoleplayer].message = exitmsg; if (demorecording) G_CheckDemoStatus (); continue; } // check for a remote game kill if (netbuffer->checksum & NCMD_KILL) I_Error ("Killed by network driver"); nodeforplayer[netconsole] = netnode; // check for retransmit request if ( resendcount[netnode] <= 0 && (netbuffer->checksum & NCMD_RETRANSMIT) ) { resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); if (debugfile) fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); resendcount[netnode] = RESENDCOUNT; } else resendcount[netnode]--; // check for out of order / duplicated packet if (realend == nettics[netnode]) continue; if (realend < nettics[netnode]) { if (debugfile) fprintf (debugfile, "out of order packet (%i + %i)\n" , realstart,netbuffer->numtics); continue; } // check for a missed packet if (realstart > nettics[netnode]) { // stop processing until the other system resends the missed tics if (debugfile) fprintf (debugfile, "missed tics from %i (%i - %i)\n", netnode, realstart, nettics[netnode]); remoteresend[netnode] = true; continue; } // update command store from the packet { int start; remoteresend[netnode] = false; start = nettics[netnode] - realstart; src = &netbuffer->cmds[start]; while (nettics[netnode] < realend) { dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; nettics[netnode]++; *dest = *src; src++; } } } }
void I_Error (char *error, ...) { va_list argptr; if (already_quitting) { fprintf(stderr, "Warning: recursive call to I_Error detected.\n"); exit(-1); } else { already_quitting = true; } // Message first. va_start(argptr, error); //fprintf(stderr, "\nError: "); vfprintf(stderr, error, argptr); fprintf(stderr, "\n\n"); va_end(argptr); fflush(stderr); // Shutdown. Here might be other errors. if (demorecording) { G_CheckDemoStatus(); } D_QuitNetGame (); I_ShutdownGraphics(); S_Shutdown(); #ifdef _WIN32 // On Windows, pop up a dialog box with the error message. { char msgbuf[512]; wchar_t wmsgbuf[512]; va_start(argptr, error); memset(msgbuf, 0, sizeof(msgbuf)); vsnprintf(msgbuf, sizeof(msgbuf) - 1, error, argptr); va_end(argptr); MultiByteToWideChar(CP_ACP, 0, msgbuf, strlen(msgbuf) + 1, wmsgbuf, sizeof(wmsgbuf)); MessageBoxW(NULL, wmsgbuf, L"", MB_OK); } #endif #ifdef __MACOSX__ if (!I_ConsoleStdout()) { CFStringRef message; char msgbuf[512]; int i; va_start(argptr, error); memset(msgbuf, 0, sizeof(msgbuf)); vsnprintf(msgbuf, sizeof(msgbuf) - 1, error, argptr); va_end(argptr); // The CoreFoundation message box wraps text lines, so replace // newline characters with spaces so that multiline messages // are continuous. for (i = 0; msgbuf[i] != '\0'; ++i) { if (msgbuf[i] == '\n') { msgbuf[i] = ' '; } } message = CFStringCreateWithCString(NULL, msgbuf, kCFStringEncodingUTF8); CFUserNotificationDisplayNotice(0, kCFUserNotificationCautionAlertLevel, NULL, NULL, NULL, CFSTR(PACKAGE_STRING), message, NULL); } #endif // abort(); exit(-1); }
dboolean G_Responder(event_t* ev) { // Handle level specific ticcmds if(gamestate == GS_LEVEL) { // allow spy mode changes even during the demo if(ev->type == ev_keydown && ev->data1 == KEY_F12 && (singledemo || !deathmatch)) { // spy mode do { displayplayer++; if(displayplayer == MAXPLAYERS) { displayplayer = 0; } } while(!playeringame[displayplayer] && displayplayer != consoleplayer); return true; } if(demoplayback && gameaction == ga_nothing) { if(ev->type == ev_keydown || ev->type == ev_gamepad) { G_CheckDemoStatus(); gameaction = ga_warpquick; return true; } else { return false; } } if(ST_Responder(ev)) { return true; // status window ate it } if(AM_Responder(ev)) { return true; // automap ate it } } // Handle screen specific ticcmds if(gamestate == GS_SKIPPABLE) { if(gameaction == ga_nothing) { if(ev->type == ev_keydown || (ev->type == ev_mouse && ev->data1) || ev->type == ev_gamepad) { gameaction = ga_title; return true; } return false; } } if((ev->type == ev_keydown) && (ev->data1 == KEY_PAUSE)) { sendpause = true; return true; } if(G_ActionResponder(ev)) { return true; } return false; }