/* ================ VID_Menu_ChooseNextMode chooses next resolution in order, then updates vid_width and vid_height cvars, then updates bpp and refreshrate lists ================ */ static void VID_Menu_ChooseNextMode (int dir) { int i; if (vid_menu_nummodes) { for (i = 0; i < vid_menu_nummodes; i++) { if (vid_menu_modes[i].width == vid_width.value && vid_menu_modes[i].height == vid_height.value) break; } if (i == vid_menu_nummodes) //can't find it in list, so it must be a custom windowed res { i = 0; } else { i += dir; if (i >= vid_menu_nummodes) i = 0; else if (i < 0) i = vid_menu_nummodes-1; } Cvar_SetValueQuick (&vid_width, (float)vid_menu_modes[i].width); Cvar_SetValueQuick (&vid_height, (float)vid_menu_modes[i].height); VID_Menu_RebuildBppList (); } }
/* ================ VID_Test -- johnfitz -- like vid_restart, but asks for confirmation after switching modes ================ */ static void VID_Test (void) { int old_width, old_height, old_bpp, old_fullscreen; if (vid_locked || !vid_changed) return; // // now try the switch // old_width = draw_context->w; old_height = draw_context->h; old_bpp = draw_context->format->BitsPerPixel; old_fullscreen = draw_context->flags & SDL_FULLSCREEN ? true : false; VID_Restart (); //pop up confirmation dialoge if (!SCR_ModalMessage("Would you like to keep this\nvideo mode? (y/n)\n", 5.0f)) { //revert cvars and mode Cvar_SetValueQuick (&vid_width, old_width); Cvar_SetValueQuick (&vid_height, old_height); Cvar_SetValueQuick (&vid_bpp, old_bpp); Cvar_SetQuick (&vid_fullscreen, old_fullscreen ? "1" : "0"); VID_Restart (); } }
/* ================ Host_Error This shuts down both the client and server ================ */ void Host_Error (const char *error, ...) { static char hosterrorstring1[MAX_INPUTLINE]; // THREAD UNSAFE static char hosterrorstring2[MAX_INPUTLINE]; // THREAD UNSAFE static qboolean hosterror = false; va_list argptr; // turn off rcon redirect if it was active when the crash occurred // to prevent loops when it is a networking problem Con_Rcon_Redirect_Abort(); va_start (argptr,error); dpvsnprintf (hosterrorstring1,sizeof(hosterrorstring1),error,argptr); va_end (argptr); Con_Printf("Host_Error: %s\n", hosterrorstring1); // LordHavoc: if crashing very early, or currently shutting down, do // Sys_Error instead if (host_framecount < 3 || host_shuttingdown) Sys_Error ("Host_Error: %s", hosterrorstring1); if (hosterror) Sys_Error ("Host_Error: recursively entered (original error was: %s new error is: %s)", hosterrorstring2, hosterrorstring1); hosterror = true; strlcpy(hosterrorstring2, hosterrorstring1, sizeof(hosterrorstring2)); CL_Parse_DumpPacket(); CL_Parse_ErrorCleanUp(); //PR_Crash(); // print out where the crash happened, if it was caused by QC (and do a cleanup) PRVM_Crash(SVVM_prog); PRVM_Crash(CLVM_prog); #ifdef CONFIG_MENU PRVM_Crash(MVM_prog); #endif cl.csqc_loaded = false; Cvar_SetValueQuick(&csqc_progcrc, -1); Cvar_SetValueQuick(&csqc_progsize, -1); SV_LockThreadMutex(); Host_ShutdownServer (); SV_UnlockThreadMutex(); if (cls.state == ca_dedicated) Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit CL_Disconnect (); cls.demonum = -1; hosterror = false; Host_AbortCurrentFrame(); }
void VID_EnableJoystick(qboolean enable) { int index = joy_enable.integer > 0 ? joy_index.integer : -1; qboolean success = false; int sharedcount = 0; sharedcount = VID_Shared_SetJoystick(index); if (index >= 0 && index < sharedcount) success = true; // update cvar containing count of XInput joysticks if (joy_detected.integer != sharedcount) Cvar_SetValueQuick(&joy_detected, sharedcount); Cvar_SetValueQuick(&joy_active, success ? 1 : 0); }
static void VR_Deadzone_f (cvar_t *var) { // clamp the mouse to a max of 0 - 70 degrees float deadzone = CLAMP (0.0f, vr_deadzone.value, 70.0f); if (deadzone != vr_deadzone.value) Cvar_SetValueQuick(&vr_deadzone, deadzone); }
/* ================ VID_Menu_ChooseNextBpp chooses next bpp in order, then updates vid_bpp cvar ================ */ static void VID_Menu_ChooseNextBpp (int dir) { int i; if (vid_menu_numbpps) { for (i = 0; i < vid_menu_numbpps; i++) { if (vid_menu_bpps[i] == vid_bpp.value) break; } if (i == vid_menu_numbpps) //can't find it in list { i = 0; } else { i += dir; if (i >= vid_menu_numbpps) i = 0; else if (i < 0) i = vid_menu_numbpps-1; } Cvar_SetValueQuick (&vid_bpp, (float)vid_menu_bpps[i]); } }
/* ================ VID_SyncCvars -- johnfitz -- set vid cvars to match current video mode ================ */ void VID_SyncCvars (void) { int swap_control; if (draw_context) { Cvar_SetValueQuick (&vid_width, draw_context->w); Cvar_SetValueQuick (&vid_height, draw_context->h); Cvar_SetValueQuick (&vid_bpp, draw_context->format->BitsPerPixel); Cvar_SetQuick (&vid_fullscreen, draw_context->flags & SDL_FULLSCREEN ? "1" : "0"); if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == 0) Cvar_SetQuick (&vid_vsync, (swap_control > 0)? "1" : "0"); } vid_changed = false; }
/* ================ VID_Menu_RebuildBppList regenerates bpp list based on current vid_width and vid_height ================ */ static void VID_Menu_RebuildBppList (void) { int i, j, b; vid_menu_numbpps = 0; for (i = 0; i < nummodes; i++) { if (vid_menu_numbpps >= MAX_BPPS_LIST) break; //bpp list is limited to bpps available with current width/height if (modelist[i].width != vid_width.value || modelist[i].height != vid_height.value) continue; b = modelist[i].bpp; for (j = 0; j < vid_menu_numbpps; j++) { if (vid_menu_bpps[j] == b) break; } if (j == vid_menu_numbpps) { vid_menu_bpps[j] = b; vid_menu_numbpps++; } } //if there are no valid fullscreen bpps for this width/height, just pick one if (vid_menu_numbpps == 0) { Cvar_SetValueQuick (&vid_bpp, (float)modelist[0].bpp); return; } //if vid_bpp is not in the new list, change vid_bpp for (i = 0; i < vid_menu_numbpps; i++) if (vid_menu_bpps[i] == (int)(vid_bpp.value)) break; if (i == vid_menu_numbpps) Cvar_SetValueQuick (&vid_bpp, (float)vid_menu_bpps[0]); }
static void VR_Enabled_f (cvar_t *var) { VR_Disable(); if (!vr_enabled.value) return; if( !VR_Enable() ) Cvar_SetValueQuick(&vr_enabled,0); }
void CL_VM_Error (const char *format, ...) //[515]: hope it will be never executed =) { char errorstring[4096]; va_list argptr; va_start (argptr, format); dpvsnprintf (errorstring, sizeof(errorstring), format, argptr); va_end (argptr); // Con_Printf( "CL_VM_Error: %s\n", errorstring ); PRVM_Crash(); cl.csqc_loaded = false; Cvar_SetValueQuick(&csqc_progcrc, -1); Cvar_SetValueQuick(&csqc_progsize, -1); // Host_AbortCurrentFrame(); //[515]: hmmm... if server says it needs csqc then client MUST disconnect Host_Error("CL_VM_Error: %s", errorstring); }
static void CDAudio_StopPlaylistTrack(void) { if (music_playlist_active >= 0 && music_playlist_active < MAX_PLAYLISTS && music_playlist_sampleposition[music_playlist_active].value >= 0) { // save position for resume float position = CDAudio_GetPosition(); Cvar_SetValueQuick(&music_playlist_sampleposition[music_playlist_active], position >= 0 ? position : 0); } music_playlist_active = -1; music_playlist_playing = 0; // not playing }
static void Host_ServerOptions (void) { int i; // general default svs.maxclients = 8; // COMMANDLINEOPTION: Server: -dedicated [playerlimit] starts a dedicated server (with a command console), default playerlimit is 8 // COMMANDLINEOPTION: Server: -listen [playerlimit] starts a multiplayer server with graphical client, like singleplayer but other players can connect, default playerlimit is 8 // if no client is in the executable or -dedicated is specified on // commandline, start a dedicated server i = COM_CheckParm ("-dedicated"); if (i || !cl_available) { cls.state = ca_dedicated; // check for -dedicated specifying how many players if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1) svs.maxclients = atoi (com_argv[i+1]); if (COM_CheckParm ("-listen")) Con_Printf ("Only one of -dedicated or -listen can be specified\n"); // default sv_public on for dedicated servers (often hosted by serious administrators), off for listen servers (often hosted by clueless users) Cvar_SetValue("sv_public", 1); } else if (cl_available) { // client exists and not dedicated, check if -listen is specified cls.state = ca_disconnected; i = COM_CheckParm ("-listen"); if (i) { // default players unless specified if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1) svs.maxclients = atoi (com_argv[i+1]); } else { // default players in some games, singleplayer in most if (gamemode != GAME_GOODVSBAD2 && !IS_NEXUIZ_DERIVED(gamemode) && gamemode != GAME_BATTLEMECH) svs.maxclients = 1; } } svs.maxclients = svs.maxclients_next = bound(1, svs.maxclients, MAX_SCOREBOARD); svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); if (svs.maxclients > 1 && !deathmatch.integer && !coop.integer) Cvar_SetValueQuick(&deathmatch, 1); }
int CDAudio_Init (void) { int i; if (cls.state == ca_dedicated) return -1; // COMMANDLINEOPTION: Sound: -nocdaudio disables CD audio support if (COM_CheckParm("-nocdaudio")) return -1; CDAudio_SysInit(); #ifdef MAXTRACKS for (i = 0; i < MAXTRACKS; i++) *remap[i] = 0; #endif Cvar_RegisterVariable(&cdaudio); Cvar_RegisterVariable(&cdaudioinitialized); Cvar_SetValueQuick(&cdaudioinitialized, true); enabled = true; Cvar_RegisterVariable(&music_playlist_index); for (i = 0;i < MAX_PLAYLISTS;i++) { Cvar_RegisterVariable(&music_playlist_list[i]); Cvar_RegisterVariable(&music_playlist_current[i]); Cvar_RegisterVariable(&music_playlist_random[i]); Cvar_RegisterVariable(&music_playlist_sampleposition[i]); } Cmd_AddCommand("cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage"); return 0; }
static void CL_Beams_SetupExternalTexture(void) { if (Mod_LoadTextureFromQ3Shader(r_main_mempool, "r_lightning.c", &cl_beams_externaltexture, "textures/particles/lightning", false, false, TEXF_ALPHA | TEXF_FORCELINEAR, MATERIALFLAG_WALL | MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_NOCULLFACE)) Cvar_SetValueQuick(&r_lightningbeam_qmbtexture, false); }
void VID_Finish (void) { qboolean vid_usevsync; // handle changes of the vsync option vid_usevsync = (vid_vsync.integer && !cls.timedemo); if (vid_usingvsync != vid_usevsync) { GLint sync = (vid_usevsync ? 1 : 0); if (qaglSetInteger(context, AGL_SWAP_INTERVAL, &sync) == GL_TRUE) { vid_usingvsync = vid_usevsync; Con_DPrintf("Vsync %s\n", vid_usevsync ? "activated" : "deactivated"); } else Con_Printf("ERROR: can't %s vsync\n", vid_usevsync ? "activate" : "deactivate"); } if (!vid_hidden) { if (r_speeds.integer == 2 || gl_finish.integer) GL_Finish(); qaglSwapBuffers(context); } VID_UpdateGamma(false, GAMMA_TABLE_SIZE); if (apple_multithreadedgl.integer) { if (!multithreadedgl) { if(qCGLGetCurrentContext && qCGLEnable && qCGLDisable) { CGLContextObj ctx = qCGLGetCurrentContext(); CGLError e = qCGLEnable(ctx, kCGLCEMPEngine); if(e == kCGLNoError) multithreadedgl = true; else { Con_Printf("WARNING: can't enable multithreaded GL, error %d\n", (int) e); Cvar_SetValueQuick(&apple_multithreadedgl, 0); } } else { Con_Printf("WARNING: can't enable multithreaded GL, CGL functions not present\n"); Cvar_SetValueQuick(&apple_multithreadedgl, 0); } } } else { if (multithreadedgl) { if(qCGLGetCurrentContext && qCGLEnable && qCGLDisable) { CGLContextObj ctx = qCGLGetCurrentContext(); qCGLDisable(ctx, kCGLCEMPEngine); multithreadedgl = false; } } } }
/* ==================== SndSys_Init Create "snd_renderbuffer" with the proper sound format if the call is successful May return a suggested format if the requested format isn't available ==================== */ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested) { unsigned int buffersize; SDL_AudioSpec wantspec; SDL_AudioSpec obtainspec; snd_threaded = false; Con_DPrint ("SndSys_Init: using the SDL module\n"); // Init the SDL Audio subsystem if( SDL_InitSubSystem( SDL_INIT_AUDIO ) ) { Con_Print( "Initializing the SDL Audio subsystem failed!\n" ); return false; } buffersize = (unsigned int)ceil((double)requested->speed / 25.0); // 2048 bytes on 24kHz to 48kHz // Init the SDL Audio subsystem wantspec.callback = Buffer_Callback; wantspec.userdata = NULL; wantspec.freq = requested->speed; wantspec.format = ((requested->width == 1) ? AUDIO_U8 : AUDIO_S16SYS); wantspec.channels = requested->channels; wantspec.samples = CeilPowerOf2(buffersize); // needs to be a power of 2 on some platforms. Con_Printf("Wanted audio Specification:\n" "\tChannels : %i\n" "\tFormat : 0x%X\n" "\tFrequency : %i\n" "\tSamples : %i\n", wantspec.channels, wantspec.format, wantspec.freq, wantspec.samples); if( SDL_OpenAudio( &wantspec, &obtainspec ) ) { Con_Printf( "Failed to open the audio device! (%s)\n", SDL_GetError() ); return false; } Con_Printf("Obtained audio specification:\n" "\tChannels : %i\n" "\tFormat : 0x%X\n" "\tFrequency : %i\n" "\tSamples : %i\n", obtainspec.channels, obtainspec.format, obtainspec.freq, obtainspec.samples); // If we haven't obtained what we wanted if (wantspec.freq != obtainspec.freq || wantspec.format != obtainspec.format || wantspec.channels != obtainspec.channels) { SDL_CloseAudio(); // Pass the obtained format as a suggested format if (suggested != NULL) { suggested->speed = obtainspec.freq; // FIXME: check the format more carefully. There are plenty of unsupported cases suggested->width = ((obtainspec.format == AUDIO_U8) ? 1 : 2); suggested->channels = obtainspec.channels; } return false; } snd_threaded = true; snd_renderbuffer = Snd_CreateRingBuffer(requested, 0, NULL); if (snd_channellayout.integer == SND_CHANNELLAYOUT_AUTO) Cvar_SetValueQuick (&snd_channellayout, SND_CHANNELLAYOUT_STANDARD); sdlaudiotime = 0; SDL_PauseAudio( false ); return true; }
/* ================= SCR_SizeDown_f Keybinding command ================= */ void SCR_SizeDown_f (void) { Cvar_SetValueQuick (&scr_viewsize, scr_viewsize.value-10); }
/* ================= SCR_SizeUp_f Keybinding command ================= */ void SCR_SizeUp_f (void) { Cvar_SetValueQuick (&scr_viewsize, scr_viewsize.value+10); }
void R_MeshQueue_RenderTransparent(void) { int i, hashindex, maxhashindex, batchnumsurfaces; float distscale; const entity_render_t *ent; const rtlight_t *rtlight; void (*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfaceindices); int batchsurfaceindex[MESHQUEUE_TRANSPARENT_BATCHSIZE]; meshqueue_t *mqt; if (!mqt_count) return; // check for bad cvars if (r_transparent_sortarraysize.integer < 1 || r_transparent_sortarraysize.integer > 32768) Cvar_SetValueQuick(&r_transparent_sortarraysize, bound(1, r_transparent_sortarraysize.integer, 32768)); if (r_transparent_sortmindist.integer < 1 || r_transparent_sortmindist.integer >= r_transparent_sortmaxdist.integer) Cvar_SetValueQuick(&r_transparent_sortmindist, 0); if (r_transparent_sortmaxdist.integer < r_transparent_sortmindist.integer || r_transparent_sortmaxdist.integer > 32768) Cvar_SetValueQuick(&r_transparent_sortmaxdist, bound(r_transparent_sortmindist.integer, r_transparent_sortmaxdist.integer, 32768)); // update hash array if (trans_sortarraysize != r_transparent_sortarraysize.integer) { trans_sortarraysize = r_transparent_sortarraysize.integer; if (trans_hash) Mem_Free(trans_hash); trans_hash = (meshqueue_t **)Mem_Alloc(cls.permanentmempool, sizeof(meshqueue_t *) * trans_sortarraysize); if (trans_hashpointer) Mem_Free(trans_hashpointer); trans_hashpointer = (meshqueue_t ***)Mem_Alloc(cls.permanentmempool, sizeof(meshqueue_t **) * trans_sortarraysize); } // build index memset(trans_hash, 0, sizeof(meshqueue_t *) * trans_sortarraysize); for (i = 0; i < trans_sortarraysize; i++) trans_hashpointer[i] = &trans_hash[i]; distscale = (trans_sortarraysize - 1) / min(mqt_viewmaxdist, r_transparent_sortmaxdist.integer); maxhashindex = trans_sortarraysize - 1; for (i = 0, mqt = mqt_array; i < mqt_count; i++, mqt++) { switch(mqt->category) { default: case TRANSPARENTSORT_HUD: hashindex = 0; break; case TRANSPARENTSORT_DISTANCE: // this could use a reduced range if we need more categories hashindex = bound(0, (int)(bound(0, mqt->dist - r_transparent_sortmindist.integer, r_transparent_sortmaxdist.integer) * distscale), maxhashindex); break; case TRANSPARENTSORT_SKY: hashindex = maxhashindex; break; } // link to tail of hash chain (to preserve render order) mqt->next = NULL; *trans_hashpointer[hashindex] = mqt; trans_hashpointer[hashindex] = &mqt->next; } callback = NULL; ent = NULL; rtlight = NULL; batchnumsurfaces = 0; // draw for (i = maxhashindex; i >= 0; i--) { if (trans_hash[i]) { for (mqt = trans_hash[i]; mqt; mqt = mqt->next) { if (ent != mqt->ent || rtlight != mqt->rtlight || callback != mqt->callback || batchnumsurfaces >= MESHQUEUE_TRANSPARENT_BATCHSIZE) { if (batchnumsurfaces) callback(ent, rtlight, batchnumsurfaces, batchsurfaceindex); batchnumsurfaces = 0; ent = mqt->ent; rtlight = mqt->rtlight; callback = mqt->callback; } batchsurfaceindex[batchnumsurfaces++] = mqt->surfacenumber; } } } if (batchnumsurfaces) callback(ent, rtlight, batchnumsurfaces, batchsurfaceindex); mqt_count = 0; }
void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor) { if (!mouse_avail || !window) relative = hidecursor = false; if (relative) { if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer)) VID_SetMouse(false, false, false); // ungrab first! if (!vid_usingmouse) { Rect winBounds; CGPoint winCenter; SelectWindow(window); // Put the mouse cursor at the center of the window GetWindowBounds (window, kWindowContentRgn, &winBounds); winCenter.x = (winBounds.left + winBounds.right) / 2; winCenter.y = (winBounds.top + winBounds.bottom) / 2; CGWarpMouseCursorPosition(winCenter); // Lock the mouse pointer at its current position CGAssociateMouseAndMouseCursorPosition(false); // Save the status of mouse acceleration originalMouseSpeed = -1.0; // in case of error if(apple_mouse_noaccel.integer) { io_connect_t mouseDev = IN_GetIOHandle(); if(mouseDev != 0) { if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess) { Con_DPrintf("previous mouse acceleration: %f\n", originalMouseSpeed); if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess) { Con_Print("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n"); Cvar_SetValueQuick(&apple_mouse_noaccel, 0); } } else { Con_Print("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n"); Cvar_SetValueQuick(&apple_mouse_noaccel, 0); } IOServiceClose(mouseDev); } else { Con_Print("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n"); Cvar_SetValueQuick(&apple_mouse_noaccel, 0); } } vid_usingmouse = true; vid_usingnoaccel = !!apple_mouse_noaccel.integer; } } else { if (vid_usingmouse) { if(originalMouseSpeed != -1.0) { io_connect_t mouseDev = IN_GetIOHandle(); if(mouseDev != 0) { Con_DPrintf("restoring mouse acceleration to: %f\n", originalMouseSpeed); if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess) Con_Print("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n"); IOServiceClose(mouseDev); } else Con_Print("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n"); } CGAssociateMouseAndMouseCursorPosition(true); vid_usingmouse = false; } } if (vid_usinghidecursor != hidecursor) { vid_usinghidecursor = hidecursor; if (hidecursor) CGDisplayHideCursor(CGMainDisplayID()); else CGDisplayShowCursor(CGMainDisplayID()); } }
/* =================== VID_Restart -- johnfitz -- change video modes on the fly =================== */ static void VID_Restart (void) { int width, height, bpp; qboolean fullscreen; qboolean vr_is_enabled = vr_enabled.value; if (vid_locked || !vid_changed) return; if (vr_is_enabled) // phoboslab { Cvar_SetValueQuick( &vr_enabled, 0 ); } width = (int)vid_width.value; height = (int)vid_height.value; bpp = (int)vid_bpp.value; fullscreen = vid_fullscreen.value ? true : false; // // validate new mode // if (!VID_ValidMode (width, height, bpp, fullscreen)) { Con_Printf ("%dx%dx%d %s is not a valid mode\n", width, height, bpp, fullscreen? "fullscreen" : "windowed"); return; } // // set new mode // VID_SetMode (width, height, bpp, fullscreen); GL_Init (); TexMgr_ReloadImages (); GL_SetupState (); //warpimages needs to be recalculated TexMgr_RecalcWarpImageSize (); //conwidth and conheight need to be recalculated vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width; vid.conwidth = CLAMP (320, vid.conwidth, vid.width); vid.conwidth &= 0xFFFFFFF8; vid.conheight = vid.conwidth * vid.height / vid.width; // // keep cvars in line with actual mode // VID_SyncCvars(); // // update mouse grab // if (key_dest == key_console || key_dest == key_menu) { if (modestate == MS_WINDOWED) IN_Deactivate(true); else if (modestate == MS_FULLSCREEN) IN_Activate(); } if (vr_is_enabled) // phoboslab { Cvar_SetValueQuick( &vr_enabled, 1 ); } }
static void r_lightningbeams_setupqmbtexture(void) { r_lightningbeamqmbtexture = R_SkinFrame_LoadExternal("textures/particles/lightning.pcx", TEXF_ALPHA | TEXF_FORCELINEAR, false); if (r_lightningbeamqmbtexture == NULL) Cvar_SetValueQuick(&r_lightningbeam_qmbtexture, false); }
/* =================== VID_Init =================== */ void VID_Init (void) { static char vid_center[] = "SDL_VIDEO_CENTERED=center"; const SDL_VideoInfo *info; int width, height, bpp; qboolean fullscreen; const char *read_vars[] = { "vid_fullscreen", "vid_width", "vid_height", "vid_bpp", "vid_vsync" }; #define num_readvars ( sizeof(read_vars)/sizeof(read_vars[0]) ) Cvar_RegisterVariable (&vid_fullscreen); //johnfitz Cvar_RegisterVariable (&vid_width); //johnfitz Cvar_RegisterVariable (&vid_height); //johnfitz Cvar_RegisterVariable (&vid_bpp); //johnfitz Cvar_RegisterVariable (&vid_vsync); //johnfitz Cvar_SetCallback (&vid_fullscreen, VID_Changed_f); Cvar_SetCallback (&vid_width, VID_Changed_f); Cvar_SetCallback (&vid_height, VID_Changed_f); Cvar_SetCallback (&vid_bpp, VID_Changed_f); Cvar_SetCallback (&vid_vsync, VID_Changed_f); Cmd_AddCommand ("vid_unlock", VID_Unlock); //johnfitz Cmd_AddCommand ("vid_restart", VID_Restart); //johnfitz Cmd_AddCommand ("vid_test", VID_Test); //johnfitz Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f); Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f); putenv (vid_center); /* SDL_putenv is problematic in versions <= 1.2.9 */ if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) Sys_Error("Could not initialize SDL Video"); info = SDL_GetVideoInfo(); Cvar_SetValueQuick (&vid_bpp, (float)info->vfmt->BitsPerPixel); if (CFG_OpenConfig("config.cfg") == 0) { CFG_ReadCvars(read_vars, num_readvars); CFG_CloseConfig(); } CFG_ReadCvarOverrides(read_vars, num_readvars); VID_InitModelist(); width = (int)vid_width.value; height = (int)vid_height.value; bpp = (int)vid_bpp.value; fullscreen = (int)vid_fullscreen.value; if (COM_CheckParm("-current")) { width = info->current_w; height = info->current_h; bpp = info->vfmt->BitsPerPixel; fullscreen = true; } else { int p; p = COM_CheckParm("-width"); if (p && p < com_argc-1) { width = Q_atoi(com_argv[p+1]); if(!COM_CheckParm("-height")) height = width * 3 / 4; } p = COM_CheckParm("-height"); if (p && p < com_argc-1) { height = Q_atoi(com_argv[p+1]); if(!COM_CheckParm("-width")) width = height * 4 / 3; } p = COM_CheckParm("-bpp"); if (p && p < com_argc-1) bpp = Q_atoi(com_argv[p+1]); if (COM_CheckParm("-window") || COM_CheckParm("-w")) fullscreen = false; else if (COM_CheckParm("-fullscreen") || COM_CheckParm("-f")) fullscreen = true; } if (!VID_ValidMode(width, height, bpp, fullscreen)) { width = (int)vid_width.value; height = (int)vid_height.value; bpp = (int)vid_bpp.value; fullscreen = (int)vid_fullscreen.value; } if (!VID_ValidMode(width, height, bpp, fullscreen)) { width = 640; height = 480; bpp = info->vfmt->BitsPerPixel; fullscreen = false; } vid_initialized = true; vid.maxwarpwidth = WARP_WIDTH; vid.maxwarpheight = WARP_HEIGHT; vid.colormap = host_colormap; vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048)); // set window icon PL_SetWindowIcon(); VID_SetMode (width, height, bpp, fullscreen); GL_Init (); GL_SetupState (); Cmd_AddCommand ("gl_info", GL_Info_f); //johnfitz //johnfitz -- removed code creating "glquake" subdirectory vid_menucmdfn = VID_Menu_f; //johnfitz vid_menudrawfn = VID_MenuDraw; vid_menukeyfn = VID_MenuKey; VID_Gamma_Init(); //johnfitz VID_Menu_Init(); //johnfitz //QuakeSpasm: current vid settings should override config file settings. //so we have to lock the vid mode from now until after all config files are read. vid_locked = true; }
void CDAudio_StartPlaylist(qboolean resume) { const char *list; const char *t; int index; int current; int randomplay; int count; int listindex; float position; char trackname[MAX_QPATH]; CDAudio_Stop(); index = music_playlist_index.integer; if (index >= 0 && index < MAX_PLAYLISTS && bgmvolume.value > 0) { list = music_playlist_list[index].string; current = music_playlist_current[index].integer; randomplay = music_playlist_random[index].integer; position = music_playlist_sampleposition[index].value; count = 0; trackname[0] = 0; if (list && list[0]) { for (t = list;;count++) { if (!COM_ParseToken_Console(&t)) break; // if we don't find the desired track, use the first one if (count == 0) strlcpy(trackname, com_token, sizeof(trackname)); } } if (count > 0) { // position < 0 means never resume track if (position < 0) position = 0; // advance to next track in playlist if the last one ended if (!resume) { position = 0; current++; if (randomplay) current = (int)lhrandom(0, count); } // wrap playlist position if needed if (current >= count) current = 0; // set current Cvar_SetValueQuick(&music_playlist_current[index], current); // get the Nth trackname if (current >= 0 && current < count) { for (listindex = 0, t = list;;listindex++) { if (!COM_ParseToken_Console(&t)) break; if (listindex == current) { strlcpy(trackname, com_token, sizeof(trackname)); break; } } } if (trackname[0]) { CDAudio_Play_byName(trackname, false, false, position); if (faketrack != -1) music_playlist_active = index; } } } music_playlist_playing = music_playlist_active >= 0 ? 1 : -1; }