static void GetJoystickButtonDescription(int vbutton, char *buf, size_t buf_len) { M_snprintf(buf, buf_len, "BUTTON #%i", PhysicalForVirtualButton(vbutton) + 1); }
static boolean CacheSFX(sfxinfo_t *sfxinfo) { int lumpnum; unsigned int lumplen; int samplerate; unsigned int length; byte *data; // need to load the sound lumpnum = sfxinfo->lumpnum; data = W_CacheLumpNum(lumpnum, PU_STATIC); lumplen = W_LumpLength(lumpnum); // Check the header, and ensure this is a valid sound if (lumplen < 8 || data[0] != 0x03 || data[1] != 0x00) { // Invalid sound return false; } // 16 bit sample rate field, 32 bit length field samplerate = (data[3] << 8) | data[2]; length = (data[7] << 24) | (data[6] << 16) | (data[5] << 8) | data[4]; // If the header specifies that the length of the sound is greater than // the length of the lump itself, this is an invalid sound lump // We also discard sound lumps that are less than 49 samples long, // as this is how DMX behaves - although the actual cut-off length // seems to vary slightly depending on the sample rate. This needs // further investigation to better understand the correct // behavior. if (length > lumplen - 8 || length <= 48) { return false; } // The DMX sound library seems to skip the first 16 and last 16 // bytes of the lump - reason unknown. data += 16; length -= 32; // Sample rate conversion if (!ExpandSoundData(sfxinfo, data + 8, samplerate, length)) { return false; } #ifdef DEBUG_DUMP_WAVS { char filename[16]; allocated_sound_t * snd; M_snprintf(filename, sizeof(filename), "%s.wav", DEH_String(sfxinfo->name)); snd = GetAllocatedSoundBySfxInfoAndPitch(sfxinfo, NORM_PITCH); WriteWAV(filename, snd->chunk.abuf, snd->chunk.alen,mixer_freq); } #endif // don't need the original lump any more W_ReleaseLumpNum(lumpnum); return true; }
static void NET_SV_AddrToString(net_addr_t *addr, char *buffer, int buffer_len) { M_snprintf(buffer, buffer_len, "local client"); }
// Respond to keyboard input events, // intercept cheats. boolean ST_Responder (event_t* ev) { int i; // Filter automap on/off. if (ev->type == ev_keyup && ((ev->data1 & 0xffff0000) == AM_MSGHEADER)) { switch(ev->data1) { case AM_MSGENTERED: st_gamestate = AutomapState; st_firsttime = true; break; case AM_MSGEXITED: // fprintf(stderr, "AM exited\n"); st_gamestate = FirstPersonState; break; } } // if a user keypress... else if (ev->type == ev_keydown) { if (!netgame && gameskill != sk_nightmare) { // 'dqd' cheat for toggleable god mode if (cht_CheckCheat(&cheat_god, ev->data2)) { plyr->cheats ^= CF_GODMODE; if (plyr->cheats & CF_GODMODE) { if (plyr->mo) plyr->mo->health = 100; plyr->health = deh_god_mode_health; plyr->message = DEH_String(STSTR_DQDON); } else plyr->message = DEH_String(STSTR_DQDOFF); } // 'fa' cheat for killer f*****g arsenal else if (cht_CheckCheat(&cheat_ammonokey, ev->data2)) { plyr->armorpoints = deh_idfa_armor; plyr->armortype = deh_idfa_armor_class; for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true; for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; plyr->message = DEH_String(STSTR_FAADDED); } // 'kfa' cheat for key full ammo else if (cht_CheckCheat(&cheat_ammo, ev->data2)) { plyr->armorpoints = deh_idkfa_armor; plyr->armortype = deh_idkfa_armor_class; for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true; for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; for (i=0;i<NUMCARDS;i++) plyr->cards[i] = true; plyr->message = DEH_String(STSTR_KFAADDED); } // 'mus' cheat for changing music else if (cht_CheckCheat(&cheat_mus, ev->data2)) { char buf[3]; int musnum; plyr->message = DEH_String(STSTR_MUS); cht_GetParam(&cheat_mus, buf); // Note: The original v1.9 had a bug that tried to play back // the Doom II music regardless of gamemode. This was fixed // in the Ultimate Doom executable so that it would work for // the Doom 1 music as well. if (gamemode == commercial || gameversion < exe_ultimate) { musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1; if (((buf[0]-'0')*10 + buf[1]-'0') > 35) plyr->message = DEH_String(STSTR_NOMUS); else S_ChangeMusic(musnum, 1); } else { musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1'); if (((buf[0]-'1')*9 + buf[1]-'1') > 31) plyr->message = DEH_String(STSTR_NOMUS); else S_ChangeMusic(musnum, 1); } } else if ( (logical_gamemission == doom && cht_CheckCheat(&cheat_noclip, ev->data2)) || (logical_gamemission != doom && cht_CheckCheat(&cheat_commercial_noclip,ev->data2))) { // Noclip cheat. // For Doom 1, use the idspipsopd cheat; for all others, use // idclip plyr->cheats ^= CF_NOCLIP; if (plyr->cheats & CF_NOCLIP) plyr->message = DEH_String(STSTR_NCON); else plyr->message = DEH_String(STSTR_NCOFF); } // 'behold?' power-up cheats for (i=0;i<6;i++) { if (cht_CheckCheat(&cheat_powerup[i], ev->data2)) { if (!plyr->powers[i]) P_GivePower( plyr, i); else if (i!=pw_strength) plyr->powers[i] = 1; else plyr->powers[i] = 0; plyr->message = DEH_String(STSTR_BEHOLDX); } } // 'behold' power-up menu if (cht_CheckCheat(&cheat_powerup[6], ev->data2)) { plyr->message = DEH_String(STSTR_BEHOLD); } // 'choppers' invulnerability & chainsaw else if (cht_CheckCheat(&cheat_choppers, ev->data2)) { plyr->weaponowned[wp_chainsaw] = true; plyr->powers[pw_invulnerability] = true; plyr->message = DEH_String(STSTR_CHOPPERS); } // 'mypos' for player position else if (cht_CheckCheat(&cheat_mypos, ev->data2)) { static char buf[ST_MSGWIDTH]; M_snprintf(buf, sizeof(buf), "ang=0x%x;x,y=(0x%x,0x%x)", players[consoleplayer].mo->angle, players[consoleplayer].mo->x, players[consoleplayer].mo->y); plyr->message = buf; } } // 'clev' change-level cheat if (!netgame && cht_CheckCheat(&cheat_clev, ev->data2)) { char buf[3]; int epsd; int map; cht_GetParam(&cheat_clev, buf); if (gamemode == commercial) { epsd = 1; map = (buf[0] - '0')*10 + buf[1] - '0'; } else { epsd = buf[0] - '0'; map = buf[1] - '0'; } // Chex.exe always warps to episode 1. if (gameversion == exe_chex) { epsd = 1; } // Catch invalid maps. if (epsd < 1) return false; if (map < 1) return false; // Ohmygod - this is not going to work. if ((gamemode == retail) && ((epsd > 4) || (map > 9))) return false; if ((gamemode == registered) && ((epsd > 3) || (map > 9))) return false; if ((gamemode == shareware) && ((epsd > 1) || (map > 9))) return false; // The source release has this check as map > 34. However, Vanilla // Doom allows IDCLEV up to MAP40 even though it normally crashes. if ((gamemode == commercial) && (( epsd > 1) || (map > 40))) return false; // So be it. plyr->message = DEH_String(STSTR_CLEV); G_DeferedInitNew(gameskill, epsd, map); } } return false; }
static void GenerateModesTable(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(modes_table)) { TXT_CAST_ARG(txt_table_t, modes_table); char buf[15]; screen_mode_t *modes; txt_radiobutton_t *rbutton; int i; // Pick which modes list to use if (fullscreen) { if (screen_modes_fullscreen == NULL) { BuildFullscreenModesList(); } modes = screen_modes_fullscreen; } else if (aspect_ratio_correct) { modes = screen_modes_scaled; } else { modes = screen_modes_unscaled; } // Build the table TXT_ClearTable(modes_table); TXT_SetColumnWidths(modes_table, 14, 14, 14, 14, 14); for (i=0; modes[i].w != 0; ++i) { // Skip bad fullscreen modes if (fullscreen && !GoodFullscreenMode(&modes[i])) { continue; } if (modes[i].w < 640 || modes[i].h < 400) // hires { continue; } M_snprintf(buf, sizeof(buf), "%ix%i", modes[i].w, modes[i].h); rbutton = TXT_NewRadioButton(buf, &vidmode, i); TXT_AddWidget(modes_table, rbutton); TXT_SignalConnect(rbutton, "selected", ModeSelected, &modes[i]); } // Find the nearest mode in the list that matches the current // settings vidmode = FindBestMode(modes); if (vidmode > 0) { screen_width = modes[vidmode].w; screen_height = modes[vidmode].h; } }
static void NET_CL_AddrToString(net_addr_t *addr, char *buffer, int buffer_len) { M_snprintf(buffer, buffer_len, "local server"); }
static void InitGameVersion(void) { byte *demolump; char demolumpname[6]; int demoversion; int p; int i; boolean status; //! // @arg <version> // @category compat // // Emulate a specific version of Doom. Valid values are "1.666", // "1.7", "1.8", "1.9", "ultimate", "final", "final2", "hacx" and // "chex". // p = M_CheckParmWithArgs("-gameversion", 1); if (p) { for (i=0; gameversions[i].description != NULL; ++i) { if (!strcmp(myargv[p+1], gameversions[i].cmdline)) { gameversion = gameversions[i].version; break; } } if (gameversions[i].description == NULL) { printf("Supported game versions:\n"); for (i=0; gameversions[i].description != NULL; ++i) { printf("\t%s (%s)\n", gameversions[i].cmdline, gameversions[i].description); } I_Error("Unknown game version '%s'", myargv[p+1]); } } else { // Determine automatically if (gamemission == pack_chex) { // chex.exe - identified by iwad filename gameversion = exe_chex; } else if (gamemission == pack_hacx) { // hacx.exe: identified by iwad filename gameversion = exe_hacx; } else if (gamemode == shareware || gamemode == registered || (gamemode == commercial && gamemission == doom2)) { // original gameversion = exe_doom_1_9; // Detect version from demo lump for (i = 1; i <= 3; ++i) { M_snprintf(demolumpname, 6, "demo%i", i); if (W_CheckNumForName(demolumpname) > 0) { demolump = W_CacheLumpName(demolumpname, PU_STATIC); demoversion = demolump[0]; W_ReleaseLumpName(demolumpname); status = true; switch (demoversion) { case 106: gameversion = exe_doom_1_666; break; case 107: gameversion = exe_doom_1_7; break; case 108: gameversion = exe_doom_1_8; break; case 109: gameversion = exe_doom_1_9; break; default: status = false; break; } if (status) { break; } } } } else if (gamemode == retail) { gameversion = exe_ultimate; } else if (gamemode == commercial) { // Final Doom: tnt or plutonia // Defaults to emulating the first Final Doom executable, // which has the crash in the demo loop; however, having // this as the default should mean that it plays back // most demos correctly. gameversion = exe_final; } } // The original exe does not support retail - 4th episode not supported if (gameversion < exe_ultimate && gamemode == retail) { gamemode = registered; } // EXEs prior to the Final Doom exes do not support Final Doom. if (gameversion < exe_final && gamemode == commercial && (gamemission == pack_tnt || gamemission == pack_plut)) { gamemission = doom2; } }
// // Translate an address to string // void NET_Steamworks_AddrToString(net_addr_t *addr, char *buffer, int buffer_len) { uint64_t csid = *((uint64_t *)addr->handle); M_snprintf(buffer, buffer_len, "%llu", csid); }
// Respond to keyboard input events, // intercept cheats. boolean ST_Responder(event_t* ev) { // haleyjd 09/27/10: made static to ST_Responder static boolean st_keystate = false; int i; // Filter automap on/off. if(ev->type == ev_keyup) { if((ev->data1 & 0xffff0000) == AM_MSGHEADER) { switch(ev->data1) { case AM_MSGENTERED: st_gamestate = AutomapState; st_firsttime = true; break; case AM_MSGEXITED: st_gamestate = FirstPersonState; break; } return false; } // villsa [STRIFE] if(ev->data1 != key_invpop && ev->data1 != key_mission && ev->data1 != key_invkey) return false; // villsa [STRIFE] if(ev->data1 == key_invpop) st_showinvpop = false; else { if(ev->data1 == key_mission) st_showobjective = false; else { if(ev->data1 == key_invkey) { st_showkeys = false; st_keystate = false; } } } if(!st_showkeys && !st_showobjective && !st_showinvpop) { if(!st_popupdisplaytics) { st_displaypopup = false; if(st_dosizedisplay) M_SizeDisplay(true); st_dosizedisplay = false; } } return true; } // if a user keypress... if(ev->type != ev_keydown) return false; // haleyjd 20100927: No input allowed when the player is dead if(plyr->mo->health <= 0) return false; // keydown events if(ev->data1 == key_invquery) // inventory query { inventory_t *inv = &(plyr->inventory[plyr->inventorycursor]); if(inv->amount) { DEH_snprintf(st_msgbuf, sizeof(st_msgbuf), "%d %s", inv->amount, DEH_String(mobjinfo[inv->type].name)); plyr->message = st_msgbuf; } } // villsa [STRIFE] if(ev->data1 == key_invpop || ev->data1 == key_invkey || ev->data1 == key_mission) { if(ev->data1 == key_invkey) { st_showobjective = false; st_showinvpop = false; if(!st_keystate) { st_keystate = true; if(++st_keypage > 2) { st_popupdisplaytics = 0; st_showkeys = false; st_displaypopup = false; st_keypage = -1; return true; } } if(netgame) st_popupdisplaytics = 20; else st_popupdisplaytics = 50; st_showkeys = true; } else { if(ev->data1 != key_mission || netgame) { if(ev->data1 == key_invpop) { st_keypage = -1; st_popupdisplaytics = false; st_showkeys = false; st_showobjective = false; st_showinvpop = true; } } else { st_showkeys = netgame; st_showinvpop = netgame; st_keypage = -1; st_popupdisplaytics = ev->data2 ^ key_mission; st_showobjective = true; } } if(st_showkeys || st_showobjective || st_showinvpop) { st_displaypopup = true; if(viewheight == SCREENHEIGHT) { M_SizeDisplay(false); st_dosizedisplay = true; } } } if(ev->data1 == key_invleft) // inventory move left { if(plyr->inventorycursor > 0) plyr->inventorycursor--; return true; } else if(ev->data1 == key_invright) { if(plyr->inventorycursor < plyr->numinventory - 1) plyr->inventorycursor++; return true; } else if(ev->data1 == key_invhome) { plyr->inventorycursor = 0; return true; } else if(ev->data1 == key_invend) { if(plyr->numinventory) plyr->inventorycursor = plyr->numinventory - 1; else plyr->inventorycursor = 0; return true; } // // [STRIFE] Cheats which are allowed in netgames/demos: // // 'spin' cheat for changing music if (cht_CheckCheat(&cheat_mus, ev->data2)) { char buf[3]; int musnum; plyr->message = DEH_String(STSTR_MUS); cht_GetParam(&cheat_mus, buf); musnum = (buf[0] - '0') * 10 + buf[1] - '0'; if (((buf[0]-'0')*10 + buf[1]-'0') > 35) plyr->message = DEH_String(STSTR_NOMUS); else S_ChangeMusic(musnum, 1); } // [STRIFE]: "dev" cheat - "DOTS" else if (cht_CheckCheat(&cheat_dev, ev->data2)) { devparm = !devparm; if (devparm) plyr->message = DEH_String("devparm ON"); else plyr->message = DEH_String("devparm OFF"); } // [STRIFE] Cheats below are not allowed in netgames or demos if(netgame || !usergame) return false; if (cht_CheckCheat(&cheat_god, ev->data2)) { // 'omnipotent' cheat for toggleable god mode plyr->cheats ^= CF_GODMODE; if (plyr->cheats & CF_GODMODE) { if (plyr->mo) plyr->mo->health = 100; plyr->health = deh_god_mode_health; plyr->st_update = true; // [STRIFE] plyr->message = DEH_String(STSTR_DQDON); } else { plyr->st_update = true; plyr->message = DEH_String(STSTR_DQDOFF); } } else if (cht_CheckCheat(&cheat_ammo, ev->data2)) { // [STRIFE]: "BOOMSTIX" cheat for all normal weapons plyr->armorpoints = deh_idkfa_armor; plyr->armortype = deh_idkfa_armor_class; for (i = 0; i < NUMWEAPONS; i++) if(!isdemoversion || weaponinfo[i].availabledemo) plyr->weaponowned[i] = true; // Takes away the Sigil, even if you already had it... plyr->weaponowned[wp_sigil] = false; for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; plyr->message = DEH_String(STSTR_FAADDED); } else if(cht_CheckCheat(&cheat_keys, ev->data2)) { // villsa [STRIFE]: "JIMMY" cheat for all keys #define FIRSTKEYSETAMOUNT 16 if(plyr->cards[FIRSTKEYSETAMOUNT - 1]) { if(plyr->cards[NUMCARDS - 1] || isdemoversion) { for(i = 0; i < NUMCARDS; i++) plyr->cards[i] = false; plyr->message = DEH_String("Keys removed"); } else { for(i = 0; i < NUMCARDS; i++) plyr->cards[i] = true; plyr->message = DEH_String("Cheater Keys Added"); } } else { for(i = 0; i < FIRSTKEYSETAMOUNT; i++) plyr->cards[i] = true; plyr->message = DEH_String("Cheater Keys Added"); } } else if (cht_CheckCheat(&cheat_noclip, ev->data2)) { // [STRIFE] Removed idspispopd, added NOCLIP flag setting/removal // Noclip cheat - "ELVIS" (hah-hah :P ) plyr->cheats ^= CF_NOCLIP; if (plyr->cheats & CF_NOCLIP) { plyr->message = DEH_String(STSTR_NCON); plyr->mo->flags |= MF_NOCLIP; } else { plyr->message = DEH_String(STSTR_NCOFF); plyr->mo->flags &= ~MF_NOCLIP; } } else if(cht_CheckCheat(&cheat_stealth, ev->data2)) { // villsa [STRIFE]: "GRIPPER" cheat; nothing to do with stealth... plyr->cheats ^= CF_NOMOMENTUM; if(plyr->cheats & CF_NOMOMENTUM) plyr->message = DEH_String("STEALTH BOOTS ON"); else plyr->message = DEH_String("STEALTH BOOTS OFF"); } for(i = 0; i < ST_PUMPUP_B + 3; ++i) { // [STRIFE]: Handle berserk, invisibility, and envirosuit if(cht_CheckCheat(&cheat_powerup[i], ev->data2)) { if(plyr->powers[i]) plyr->powers[i] = (i != 1); else P_GivePower(plyr, i); plyr->message = DEH_String(STSTR_BEHOLDX); } } if(cht_CheckCheat(&cheat_powerup[ST_PUMPUP_H], ev->data2)) { // [STRIFE]: PUMPUPH gives medical inventory items P_GiveItemToPlayer(plyr, SPR_STMP, MT_INV_MED1); P_GiveItemToPlayer(plyr, SPR_MDKT, MT_INV_MED2); P_GiveItemToPlayer(plyr, SPR_FULL, MT_INV_MED3); plyr->message = DEH_String("you got the stuff!"); } if(cht_CheckCheat(&cheat_powerup[ST_PUMPUP_P], ev->data2)) { // [STRIFE]: PUMPUPP gives backpack if(!plyr->backpack) { for(i = 0; i < NUMAMMO; ++i) plyr->maxammo[i] = 2 * plyr->maxammo[i]; } plyr->backpack = true; for(i = 0; i < NUMAMMO; ++i) P_GiveAmmo(plyr, i, 1); plyr->message = DEH_String("you got the stuff!"); } if(cht_CheckCheat(&cheat_powerup[ST_PUMPUP_S], ev->data2)) { // [STRIFE]: PUMPUPS gives stamina and accuracy upgrades P_GiveItemToPlayer(plyr, SPR_TOKN, MT_TOKEN_STAMINA); P_GiveItemToPlayer(plyr, SPR_TOKN, MT_TOKEN_NEW_ACCURACY); plyr->message = DEH_String("you got the stuff!"); } if(cht_CheckCheat(&cheat_powerup[ST_PUMPUP_T], ev->data2)) { // [STRIFE] PUMPUPT gives targeter P_GivePower(plyr, pw_targeter); plyr->message = DEH_String("you got the stuff!"); } // [STRIFE]: PUMPUP if (cht_CheckCheat(&cheat_powerup[ST_PUMPUP], ev->data2)) { // 'behold' power-up menu plyr->message = DEH_String(STSTR_BEHOLD); return false; } if (cht_CheckCheat(&cheat_mypos, ev->data2)) { // [STRIFE] 'GPS' for player position static char buf[ST_MSGWIDTH]; M_snprintf(buf, sizeof(buf), "ang=0x%x;x,y=(0x%x,0x%x)", players[consoleplayer].mo->angle, players[consoleplayer].mo->x, players[consoleplayer].mo->y); plyr->message = buf; } // 'rift' change-level cheat if (cht_CheckCheat(&cheat_clev, ev->data2)) { char buf[3]; int map; cht_GetParam(&cheat_clev, buf); map = (buf[0] - '0') * 10 + buf[1] - '0'; // haleyjd 20100901: Removed Chex Quest stuff. // haleyjd 20100915: Removed retail/registered/shareware stuff // haleyjd 20130301: different bounds in v1.31 // Ohmygod - this is not going to work. if(gameversion == exe_strife_1_31) { if ((isdemoversion && (map < 32 || map > 34)) || (isregistered && (map <= 0 || map > 34))) return false; } else { if (map <= 0 || map > 40) return false; } // So be it. plyr->message = DEH_String(STSTR_CLEV); G_RiftExitLevel(map, 0, plyr->mo->angle); } else if(cht_CheckCheat(&cheat_scoot, ev->data2)) { char buf[3]; int spot; cht_GetParam(&cheat_scoot, buf); spot = buf[0] - '0'; // BUG: should be <= 9. Shouldn't do anything bad though... if(spot <= 10) { plyr->message = DEH_String("Spawning to spot"); G_RiftCheat(spot); return false; } } // villsa [STRIFE] if(cht_CheckCheat(&cheat_nuke, ev->data2)) { stonecold ^= 1; plyr->message = DEH_String("Kill 'em. Kill 'em All"); return false; } // villsa [STRIFE] if(cht_CheckCheat(&cheat_midas, ev->data2)) { plyr->message = DEH_String("YOU GOT THE MIDAS TOUCH, BABY"); P_GiveItemToPlayer(plyr, SPR_HELT, MT_TOKEN_TOUGHNESS); } // villsa [STRIFE] // haleyjd 20110224: No sigil in demo version if(!isdemoversion && cht_CheckCheat(&cheat_lego, ev->data2)) { plyr->st_update = true; if(plyr->weaponowned[wp_sigil]) { if(++plyr->sigiltype > 4) { plyr->sigiltype = -1; plyr->pendingweapon = wp_fist; plyr->weaponowned[wp_sigil] = false; } } else { plyr->weaponowned[wp_sigil] = true; plyr->sigiltype = 0; } // BUG: This brings up a bad version of the Sigil (sigiltype -1) which // causes some VERY interesting behavior, when you type LEGO for the // sixth time. This shouldn't be done when taking it away, and yet it // is here... verified with vanilla. plyr->pendingweapon = wp_sigil; } return false; }
void D_BindVariables(void) { int i; M_ApplyPlatformDefaults(); I_BindVideoVariables(); I_BindJoystickVariables(); I_BindSoundVariables(); M_BindBaseControls(); M_BindWeaponControls(); M_BindMapControls(); M_BindMenuControls(); M_BindStrifeControls(); // haleyjd 09/01/10: [STRIFE] M_BindChatControls(MAXPLAYERS); // haleyjd 20130915: Strife chat keys key_multi_msgplayer[0] = '1'; key_multi_msgplayer[1] = '2'; key_multi_msgplayer[2] = '3'; key_multi_msgplayer[3] = '4'; key_multi_msgplayer[4] = '5'; key_multi_msgplayer[5] = '6'; key_multi_msgplayer[6] = '7'; key_multi_msgplayer[7] = '8'; #ifdef FEATURE_MULTIPLAYER NET_BindVariables(); #endif // haleyjd 08/29/10: [STRIFE] // * Added voice volume // * Added back flat // * Removed show_messages // * Added show_talk // fraggle 03/06/10: [STRIFE] // * Removed detailLevel // * screenblocks -> screensize // * Added nickname, comport M_BindVariable("mouse_sensitivity", &mouseSensitivity); M_BindVariable("sfx_volume", &sfxVolume); M_BindVariable("music_volume", &musicVolume); M_BindVariable("voice_volume", &voiceVolume); M_BindVariable("show_talk", &dialogshowtext); M_BindVariable("screensize", &screenblocks); M_BindVariable("snd_channels", &snd_channels); M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); M_BindVariable("show_endoom", &show_endoom); M_BindVariable("back_flat", &back_flat); M_BindVariable("graphical_startup", &graphical_startup); M_BindVariable("nickname", &nickname); M_BindVariable("comport", &comport); // Multiplayer chat macros for (i=0; i<10; ++i) { char buf[12]; M_snprintf(buf, sizeof(buf), "chatmacro%i", i); M_BindVariable(buf, &chat_macros[i]); } }
void I_InitGraphics(void) { SDL_Event dummy; byte *doompal; char *env; // Pass through the XSCREENSAVER_WINDOW environment variable to // SDL_WINDOWID, to embed the SDL window into the Xscreensaver // window. env = getenv("XSCREENSAVER_WINDOW"); if (env != NULL) { char winenv[30]; int winid; sscanf(env, "0x%x", &winid); M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid); putenv(winenv); } SetSDLVideoDriver(); SetWindowPositionVars(); if (SDL_Init(SDL_INIT_VIDEO) < 0) { I_Error("Failed to initialize video: %s", SDL_GetError()); } // Set up title and icon. Windows cares about the ordering; this // has to be done before the call to SDL_SetVideoMode. I_InitWindowTitle(); #if !SDL_VERSION_ATLEAST(1, 3, 0) I_InitWindowIcon(); #endif // Warning to OS X users... though they might never see it :( #ifdef __MACOSX__ if (fullscreen) { printf("Some old versions of OS X might crash in fullscreen mode.\n" "If this happens to you, switch back to windowed mode.\n"); } #endif // // Enter into graphics mode. // // When in screensaver mode, run full screen and auto detect // screen dimensions (don't change video mode) // if (screensaver_mode) { SetVideoMode(NULL, 0, 0); } else { int w, h; if (autoadjust_video_settings) { I_AutoAdjustSettings(); } w = screen_width; h = screen_height; screen_mode = I_FindScreenMode(w, h); if (screen_mode == NULL) { I_Error("I_InitGraphics: Unable to find a screen mode small " "enough for %ix%i", w, h); } if (w != screen_mode->width || h != screen_mode->height) { printf("I_InitGraphics: %s (%ix%i within %ix%i)\n", WindowBoxType(screen_mode, w, h), screen_mode->width, screen_mode->height, w, h); } SetVideoMode(screen_mode, w, h); } // Start with a clear black screen // (screen will be flipped after we set the palette) SDL_FillRect(screenbuffer, NULL, 0); // Set the palette doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE); I_SetPalette(doompal); SDL_SetColors(screenbuffer, palette, 0, 256); CreateCursors(); UpdateFocus(); UpdateGrab(); // On some systems, it takes a second or so for the screen to settle // after changing modes. We include the option to add a delay when // setting the screen mode, so that the game doesn't start immediately // with the player unable to see anything. if (fullscreen && !screensaver_mode) { SDL_Delay(startup_delay); } // Check if we have a native surface we can use // If we have to lock the screen, draw to a buffer and copy // Likewise if the screen pitch is not the same as the width // If we have to multiply, drawing is done to a separate 320x200 buf native_surface = screen == screenbuffer && !SDL_MUSTLOCK(screen) && screen_mode == &mode_scale_1x && screen->pitch == SCREENWIDTH && aspect_ratio_correct; // If not, allocate a buffer and copy from that buffer to the // screen when we do an update if (native_surface) { I_VideoBuffer = (unsigned char *) screen->pixels; I_VideoBuffer += (screen->h - SCREENHEIGHT) / 2; } else { I_VideoBuffer = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); } V_RestoreBuffer(); // Clear the screen to black. memset(I_VideoBuffer, 0, SCREENWIDTH * SCREENHEIGHT); // We need SDL to give us translated versions of keys as well SDL_EnableUNICODE(1); // Repeat key presses - this is what Vanilla Doom does // Not sure about repeat rate - probably dependent on which DOS // driver is used. This is good enough though. SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // clear out any events waiting at the start and center the mouse while (SDL_PollEvent(&dummy)); initialized = true; // Call I_ShutdownGraphics on quit I_AtExit(I_ShutdownGraphics, true); }
static void LevelSelectDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data)) { txt_window_t *window; txt_table_t *table; txt_button_t *button; const iwad_t *iwad; char buf[10]; int episodes; intptr_t x, y; intptr_t l; int i; window = TXT_NewWindow("Select level"); iwad = GetCurrentIWAD(); if (warptype == WARP_ExMy) { episodes = D_GetNumEpisodes(iwad->mission, iwad->mode); table = TXT_NewTable(episodes); // ExMy levels for (y=1; y<10; ++y) { for (x=1; x<=episodes; ++x) { if (IsChexQuest(iwad) && (x > 1 || y > 5)) { continue; } if (!D_ValidEpisodeMap(iwad->mission, iwad->mode, x, y)) { TXT_AddWidget(table, NULL); continue; } M_snprintf(buf, sizeof(buf), " E%iM%i ", x, y); button = TXT_NewButton(buf); TXT_SignalConnect(button, "pressed", SetExMyWarp, (void *) (x * 10 + y)); TXT_SignalConnect(button, "pressed", CloseLevelSelectDialog, window); TXT_AddWidget(table, button); if (warpepisode == x && warpmap == y) { TXT_SelectWidget(table, button); } } } } else { table = TXT_NewTable(6); for (i=0; i<60; ++i) { x = i % 6; y = i / 6; l = x * 10 + y + 1; if (!D_ValidEpisodeMap(iwad->mission, iwad->mode, 1, l)) { TXT_AddWidget(table, NULL); continue; } M_snprintf(buf, sizeof(buf), " MAP%02i ", l); button = TXT_NewButton(buf); TXT_SignalConnect(button, "pressed", SetMAPxyWarp, (void *) l); TXT_SignalConnect(button, "pressed", CloseLevelSelectDialog, window); TXT_AddWidget(table, button); if (warpmap == l) { TXT_SelectWidget(table, button); } } } TXT_AddWidget(window, table); }
void I_InitGraphics(void) { SDL_Event dummy; byte *doompal; char *env; // Pass through the XSCREENSAVER_WINDOW environment variable to // SDL_WINDOWID, to embed the SDL window into the Xscreensaver // window. env = getenv("XSCREENSAVER_WINDOW"); if (env != NULL) { char winenv[30]; int winid; sscanf(env, "0x%x", &winid); M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid); putenv(winenv); } SetSDLVideoDriver(); if (SDL_Init(SDL_INIT_VIDEO) < 0) { I_Error("Failed to initialize video: %s", SDL_GetError()); } // When in screensaver mode, run full screen and auto detect // screen dimensions (don't change video mode) if (screensaver_mode) { fullscreen = true; } if (aspect_ratio_correct == 1) { actualheight = SCREENHEIGHT_4_3; } else { actualheight = SCREENHEIGHT; } // Create the game window; this may switch graphic modes depending // on configuration. AdjustWindowSize(); SetVideoMode(); // Start with a clear black screen // (screen will be flipped after we set the palette) SDL_FillRect(screenbuffer, NULL, 0); // Set the palette doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE); I_SetPalette(doompal); SDL_SetPaletteColors(screenbuffer->format->palette, palette, 0, 256); // SDL2-TODO UpdateFocus(); UpdateGrab(); // On some systems, it takes a second or so for the screen to settle // after changing modes. We include the option to add a delay when // setting the screen mode, so that the game doesn't start immediately // with the player unable to see anything. if (fullscreen && !screensaver_mode) { SDL_Delay(startup_delay); } // The actual 320x200 canvas that we draw to. This is the pixel buffer of // the 8-bit paletted screen buffer that gets blit on an intermediate // 32-bit RGBA screen buffer that gets loaded into a texture that gets // finally rendered into our window or full screen in I_FinishUpdate(). I_VideoBuffer = screenbuffer->pixels; V_RestoreBuffer(); // Clear the screen to black. memset(I_VideoBuffer, 0, SCREENWIDTH * SCREENHEIGHT * sizeof(*I_VideoBuffer)); // clear out any events waiting at the start and center the mouse while (SDL_PollEvent(&dummy)); initialized = true; // Call I_ShutdownGraphics on quit I_AtExit(I_ShutdownGraphics, true); }
// // haleyjd 20141022: [SVE] Alternate waiting on Steam clients // void NET_WaitForSteamLaunch(void) { boolean isServer = (net_SteamNodeType == NET_STEAM_SERVER); const char *strConn = "Connecting Netgame"; char numConn[64]; char pressStr[64]; char pressStr2[64]; int strConnWidth, pressStrWidth, pressStrX, numConnWidth; const char *keyActivateName = GetNameForKey(key_menu_activate); const char *keyForwardName = GetNameForKey(key_menu_forward); if(!keyActivateName) keyActivateName = "key_menu_activate"; if(!keyForwardName) keyForwardName = "key_menu_forward"; M_snprintf(pressStr, sizeof(pressStr), "(Press %s to cancel%c", keyActivateName, isServer ? ',' : ')'); if(isServer) { M_snprintf(pressStr2, sizeof(pressStr2), "%s to start now)", keyForwardName); } strConnWidth = V_BigFontStringWidth(strConn); pressStrWidth = M_StringWidth(pressStr); pressStrX = (SCREENWIDTH - pressStrWidth) / 2; expected_nodes = net_SteamNumNodes; while(net_waiting_for_launch) { event_t *ev; CheckAutoLaunch(); I_StartTic(); while((ev = D_PopEvent())) { switch(ev->type) { case ev_keydown: if(ev->data1 == key_menu_activate) I_Quit(); if(ev->data1 == key_menu_forward && isServer) StartGame(NULL, NULL); break; default: break; } } if(use3drenderer) RB_ClearBuffer(GLCB_COLOR); M_snprintf(numConn, sizeof(numConn), "%d of %d nodes connected", NumConnected(), net_SteamNumNodes); numConnWidth = M_StringWidth(numConn); V_DrawFilledBox(0, 0, SCREENWIDTH, SCREENHEIGHT, 0); V_WriteBigText(strConn, (SCREENWIDTH - strConnWidth)/2, 60); M_WriteText((SCREENWIDTH - numConnWidth)/2, 100, numConn); M_WriteText(pressStrX, 112, pressStr); if(isServer) M_WriteText(pressStrX+12, 124, pressStr2); NET_CL_Run(); NET_SV_Run(); if(!net_client_connected) I_Error("Lost connection to server"); I_FinishUpdate(); I_Sleep(100); } }
static void UpdateGUI(void) { txt_window_action_t *startgame; char buf[50]; unsigned int i; // If the value of max_players changes, we must rebuild the // contents of the window. This includes when the first // waiting data packet is received. if (net_client_received_wait_data) { if (net_client_wait_data.max_players != old_max_players) { BuildWindow(); } } else { return; } for (i = 0; i < net_client_wait_data.max_players; ++i) { txt_color_t color = TXT_COLOR_BRIGHT_WHITE; if ((signed) i == net_client_wait_data.consoleplayer) { color = TXT_COLOR_YELLOW; } TXT_SetFGColor(player_labels[i], color); TXT_SetFGColor(ip_labels[i], color); if (i < net_client_wait_data.num_players) { TXT_SetLabel(player_labels[i], net_client_wait_data.player_names[i]); TXT_SetLabel(ip_labels[i], net_client_wait_data.player_addrs[i]); } else { TXT_SetLabel(player_labels[i], ""); TXT_SetLabel(ip_labels[i], ""); } } if (net_client_wait_data.num_drones > 0) { M_snprintf(buf, sizeof(buf), " (+%i observer clients)", net_client_wait_data.num_drones); TXT_SetLabel(drone_label, buf); } else { TXT_SetLabel(drone_label, ""); } if (net_client_wait_data.is_controller) { startgame = TXT_NewWindowAction(' ', "Start game"); TXT_SignalConnect(startgame, "pressed", StartGame, NULL); } else { startgame = NULL; } TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, startgame); }