static void CustomPredictionFunc(void *unused)
{
	float temp;

	temp = ClampCvar(0,75,atof(s_options_vr_advanced_prediction_field.buffer));
	Cvar_SetInteger("vr_prediction",temp);
	strcpy( s_options_vr_advanced_prediction_field.buffer, vr_prediction->string );
	s_options_vr_advanced_prediction_field.cursor = strlen( vr_prediction->string );
}
Beispiel #2
0
static void DeadzoneFunc ( void *unused )
{
	float temp;

	temp = ClampCvar(0,360,atof(s_options_vr_aimmode_deadzone_pitch_field.buffer));
	Cvar_SetInteger("vr_aimmode_deadzone_pitch",temp);

	temp = ClampCvar(0,360,atof(s_options_vr_aimmode_deadzone_yaw_field.buffer));
	Cvar_SetInteger("vr_aimmode_deadzone_yaw",temp);

	temp = ClampCvar(0,360,atof(s_options_vr_hud_deadzone_yaw_field.buffer));
	Cvar_SetInteger("vr_hud_deadzone_yaw",temp);

	strcpy( s_options_vr_aimmode_deadzone_pitch_field.buffer, vr_aimmode_deadzone_pitch->string );
	s_options_vr_aimmode_deadzone_pitch_field.cursor = strlen( vr_aimmode_deadzone_pitch->string );
	strcpy( s_options_vr_aimmode_deadzone_yaw_field.buffer, vr_aimmode_deadzone_yaw->string );
	s_options_vr_aimmode_deadzone_yaw_field.cursor = strlen( vr_aimmode_deadzone_yaw->string );
	strcpy( s_options_vr_hud_deadzone_yaw_field.buffer, vr_hud_deadzone_yaw->string );
	s_options_vr_hud_deadzone_yaw_field.cursor = strlen( vr_hud_deadzone_yaw->string );
}
Beispiel #3
0
static void set_frame_time( void ) {
    int framediv;

    if( g_features->integer & GMF_VARIABLE_FPS )
        framediv = sv_fps->integer / BASE_FRAMERATE;
    else
        framediv = 1;

    clamp( framediv, 1, MAX_FRAMEDIV );

    sv.framerate = framediv * BASE_FRAMERATE;
    sv.frametime = BASE_FRAMETIME / framediv;
    sv.framediv = framediv;

    Cvar_SetInteger( sv_fps, sv.framerate, FROM_CODE );
}
Beispiel #4
0
void R_AntialiasStartFrame (void)
{
	if (r_antialias->modified)
	{
		int32_t aa = r_antialias->value;
		if (!glConfig.ext_framebuffer_object)
			aa = ANTIALIAS_NONE;
		else if (aa >= NUM_ANTIALIAS_MODES)
			aa = NUM_ANTIALIAS_MODES - 1;
		else if (aa < 0)
			aa = 0;

		Cvar_SetInteger("r_antialias", aa);

		r_antialias->modified = false;
		
		changed = true;
	}

	if (changed || glConfig.render_width != screenBounds.width || glConfig.render_height != screenBounds.height)
	{
		screenBounds.width = glConfig.render_width;
		screenBounds.height = glConfig.render_height;
		switch ((int) r_antialias->value)
		{
		case ANTIALIAS_4X_FSAA:
			offscreenBounds.width = screenBounds.width * 2;
			offscreenBounds.height = screenBounds.height * 2;
			break;
		case ANTIALIAS_FXAA_FSS:
			offscreenBounds.width = screenBounds.width * 1.3333;
			offscreenBounds.height = screenBounds.height * 1.3333;
			break;
		default:
		case ANTIALIAS_NONE:
			offscreenBounds.width = screenBounds.width;
			offscreenBounds.height = screenBounds.height;
			break;
		}
		VID_NewWindow(offscreenBounds.width, offscreenBounds.height);
		changed = false;
	}
}
Beispiel #5
0
void VR_OVR_FrameStart()
{

	const char *results = ovrHmd_GetLatencyTestResult(hmd);
	if (results && strncmp(results,"",1))
	{
		static float lastms = 0;
		float ms;
		if (sscanf(results,"RESULT=%f ",&ms) && ms != lastms)
		{
			Cvar_SetInteger("vr_prediction",(int) ms);
			lastms = ms;
		}
	}

	if (vr_ovr_lowpersistence->modified)
	{
		unsigned int caps = 0;
		if (hmd->HmdCaps & ovrHmdCap_DynamicPrediction)
			caps |= ovrHmdCap_DynamicPrediction;

		if (hmd->HmdCaps & ovrHmdCap_LowPersistence && vr_ovr_lowpersistence->value)
			caps |= ovrHmdCap_LowPersistence;
		
		ovrHmd_SetEnabledCaps(hmd,caps);
		vr_ovr_lowpersistence->modified = false;
	}

	if (!withinFrame)
	{
		frameTime = ovrHmd_BeginFrameTiming(hmd,0);
	}
	else
	{
		ovrHmd_EndFrameTiming(hmd);
		ovrHmd_ResetFrameTiming(hmd,0);
		frameTime = ovrHmd_BeginFrameTiming(hmd,0);
	}
	withinFrame = true;
}
Beispiel #6
0
/*
==============
SV_InitGame

A brand new game has been started.
If mvd_spawn is non-zero, load the built-in MVD game module.
==============
*/
void SV_InitGame( unsigned mvd_spawn ) {
    int     i, entnum;
    edict_t *ent;
    client_t *client;

    if( svs.initialized ) {
        // cause any connected clients to reconnect
        SV_Shutdown( "Server restarted\n", ERR_RECONNECT | mvd_spawn );
    } else {
#if USE_CLIENT
        // make sure the client is down
        CL_Disconnect( ERR_RECONNECT );
        SCR_BeginLoadingPlaque();
#endif

        CM_FreeMap( &sv.cm );
        SV_FreeFile( sv.entitystring );
        memset( &sv, 0, sizeof( sv ) );

#if USE_FPS
        // set up default frametime for main loop
        sv.frametime = BASE_FRAMETIME;
#endif
    }

    // get any latched variable changes (maxclients, etc)
    Cvar_GetLatchedVars ();

#if !USE_CLIENT
    Cvar_Reset( sv_recycle );
#endif

    if( mvd_spawn ) {
        Cvar_Set( "deathmatch", "1" );
        Cvar_Set( "coop", "0" );
    } else {
        if( Cvar_VariableInteger( "coop" ) &&
            Cvar_VariableInteger( "deathmatch" ) )
        {
            Com_Printf( "Deathmatch and Coop both set, disabling Coop\n" );
            Cvar_Set( "coop", "0" );
        }

        // dedicated servers can't be single player and are usually DM
        // so unless they explicity set coop, force it to deathmatch
        if( Com_IsDedicated() ) {
            if( !Cvar_VariableInteger( "coop" ) )
                Cvar_Set( "deathmatch", "1" );
        }
    }

    // init clients
    if( Cvar_VariableInteger( "deathmatch" ) ) {
        if( sv_maxclients->integer <= 1 ) {
            Cvar_SetInteger( sv_maxclients, 8, FROM_CODE );
        } else if( sv_maxclients->integer > CLIENTNUM_RESERVED ) {
            Cvar_SetInteger( sv_maxclients, CLIENTNUM_RESERVED, FROM_CODE );
        }
    } else if( Cvar_VariableInteger( "coop" ) ) {
        if( sv_maxclients->integer <= 1 || sv_maxclients->integer > 4 )
            Cvar_Set( "maxclients", "4" );
    } else {    // non-deathmatch, non-coop is one player
        Cvar_FullSet( "maxclients", "1", CVAR_SERVERINFO|CVAR_LATCH, FROM_CODE );
    }

    // enable networking
    if( sv_maxclients->integer > 1 ) {
        NET_Config( NET_SERVER );
    }

    svs.client_pool = SV_Mallocz( sizeof( client_t ) * sv_maxclients->integer );

    svs.num_entities = sv_maxclients->integer * UPDATE_BACKUP * MAX_PACKET_ENTITIES;
    svs.entities = SV_Mallocz( sizeof( entity_state_t ) * svs.num_entities );

#if USE_MVD_SERVER
    // initialize MVD server
    if( !mvd_spawn ) {
        SV_MvdInit();
    }
#endif

    Cvar_ClampInteger( sv_reserved_slots, 0, sv_maxclients->integer - 1 );

#if USE_ZLIB
    svs.z.zalloc = SV_Zalloc;
    svs.z.zfree = SV_Zfree;
    if( deflateInit2( &svs.z, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
        -MAX_WBITS, 9, Z_DEFAULT_STRATEGY ) != Z_OK )
    {
        Com_Error( ERR_FATAL, "%s: deflateInit2() failed", __func__ );
    }
#endif

    // init game
#if USE_MVD_CLIENT
    if( mvd_spawn ) {
        if( ge ) {
            SV_ShutdownGameProgs();
        }
        ge = &mvd_ge;
        ge->Init();
    } else
#endif
        SV_InitGameProgs();

    // send heartbeat very soon
    svs.last_heartbeat = -(HEARTBEAT_SECONDS-5)*1000;

    for( i = 0; i < sv_maxclients->integer; i++ ) {
        client = svs.client_pool + i;
        entnum = i + 1;
        ent = EDICT_NUM( entnum );
        ent->s.number = entnum;
        client->edict = ent;
        client->number = i;
    }

#if USE_AC_SERVER
    AC_Connect( mvd_spawn );
#endif

    svs.initialized = qtrue;
}
static void LaserFunc( void *unused )
{
	Cvar_SetInteger("vr_aimlaser",s_options_vr_advanced_laser_box.curvalue);
}
Beispiel #8
0
void R_VR_StartFrame()
{
	qboolean resolutionChanged = 0;
	qboolean hudChanged = 0;

	extern int32_t scr_draw_loading;


	if (!hmd || !hmd->frameStart || !hmd->getState)
		return;
	
	R_AntialiasSetFBOSize(vrState.offscreen);
	if (vrState.offscreen->width != screen.width || vrState.offscreen->height != screen.height)
	{
		screen.height = vrState.offscreen->height;
		screen.width = vrState.offscreen->width;
		resolutionChanged = true;
	}

	hmd->frameStart(resolutionChanged);
	hmd->getState(&vrState);

	if (vr_hud_width->modified || vr_hud_height->modified)
	{
		int width, height;

		width = vr_hud_width->value;
		height = vr_hud_height->value;

		if (width < 640)
			width = 640;

		if (height < 480)
			height = 480;
		Cvar_SetInteger("vr_hud_width",width);
		Cvar_SetInteger("vr_hud_height",height);
		vr_hud_width->modified = false;
		vr_hud_height->modified = false;
		Com_Printf("VR: New HUD resolution %ix%i\n",width,height);
		if (hud.width != width || hud.height != height)
			R_ResizeFBO(width,height,1,GL_RGBA8,&hud);

	}

	if (vr_hud_segments->modified)
	{
		// clamp value from 30-90 degrees
		if (vr_hud_segments->value < 0)
			Cvar_SetInteger("vr_hud_segments", 1);
		else if (vr_hud_segments->value > MAX_SEGMENTS)
			Cvar_SetValue("vr_hud_segments", MAX_SEGMENTS);
		vr_hud_segments->modified = false;
		hudChanged = true;
	}

	if (vr_hud_depth->modified)
	{
		if (vr_hud_depth->value < 0.25f)
			Cvar_SetValue("vr_hud_depth", 0.25);
		else if (vr_hud_depth->value > 250)
			Cvar_SetValue("vr_hud_depth", 250);
		vr_hud_depth->modified = false;
		hudChanged = true;
	}

	if (vr_hud_fov->modified)
	{
		// clamp value from 30-90 degrees
		if (vr_hud_fov->value < 30)
			Cvar_SetValue("vr_hud_fov", 30.0f);
		else if (vr_hud_fov->value > vrState.viewFovY * 2.0)
			Cvar_SetValue("vr_hud_fov", vrState.viewFovY * 2.0);
		vr_hud_fov->modified = false;
		hudChanged = true;
	}

	if (hudChanged)
		R_VR_GenerateHud();

	if (resolutionChanged)
	{
		Com_Printf("VR: Calculated %.2f FOV\n", vrState.viewFovY);
	}


	GL_ClearColor(0.0, 0.0, 0.0, 0.0);
	R_BindFBO(vrState.eyeFBO[0]);
	R_Clear();
	R_BindFBO(vrState.eyeFBO[1]);
	R_Clear();
	R_BindFBO(&hud);
	R_Clear();
	R_BindFBO(&screenFBO);
	GL_SetDefaultClearColor();		

	hudStale = 1;

	loadingScreen = (qboolean) (scr_draw_loading > 0 ? 1 : 0);
}
Beispiel #9
0
/*
================
SV_SpawnServer

Change the server to a new map, taking all connected
clients along with it.
================
*/
void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint ) {
    int         i;
    client_t    *client;

#if USE_CLIENT
    SCR_BeginLoadingPlaque();           // for local system
#endif

    Com_Printf( "------- Server Initialization -------\n" );
    Com_Printf( "SpawnServer: %s\n", server );

    // everyone needs to reconnect
    FOR_EACH_CLIENT( client ) {
        SV_ClientReset( client );
    }

    SV_BroadcastCommand( "changing map=%s\n", server );
    SV_SendClientMessages();
    SV_SendAsyncPackets();

    // free current level
    CM_FreeMap( &sv.cm );
    SV_FreeFile( sv.entitystring );
    
    // wipe the entire per-level structure
    memset( &sv, 0, sizeof( sv ) );
    sv.spawncount = ( rand() | ( rand() << 16 ) ) ^ Sys_Milliseconds();
    sv.spawncount &= 0x7FFFFFFF;

    // set legacy spawncounts
    FOR_EACH_CLIENT( client ) {
        client->spawncount = sv.spawncount;
    }

    // reset entity counter
    svs.next_entity = 0;

#if USE_FPS
    // set framerate parameters
    set_frame_time();
#endif

    // save name for levels that don't set message
    Q_strlcpy( sv.configstrings[CS_NAME], server, MAX_QPATH );
    Q_strlcpy( sv.name, server, sizeof( sv.name ) );
    
    if( Cvar_VariableInteger( "deathmatch" ) ) {
        sprintf( sv.configstrings[CS_AIRACCEL],
            "%d", sv_airaccelerate->integer );
    } else {
        strcpy( sv.configstrings[CS_AIRACCEL], "0" );
    }

#if !USE_CLIENT
    resolve_masters();
#endif

    override_entity_string( server );

    sv.cm = *cm;
    sprintf( sv.configstrings[CS_MAPCHECKSUM], "%d", ( int )cm->cache->checksum );

    // set inline model names
    Q_concat( sv.configstrings[CS_MODELS + 1], MAX_QPATH, "maps/", server, ".bsp", NULL );
    for( i = 1; i < cm->cache->nummodels; i++ ) {
        sprintf( sv.configstrings[ CS_MODELS + 1 + i ], "*%d", i );
    }

    //
    // clear physics interaction links
    //
    SV_ClearWorld();

    //
    // spawn the rest of the entities on the map
    //  

    // precache and static commands can be issued during
    // map initialization
    sv.state = ss_loading;

    X86_PUSH_FPCW;
    X86_SINGLE_FPCW;

    // load and spawn all other entities
    ge->SpawnEntities ( sv.name, sv.entitystring ?
        sv.entitystring : cm->cache->entitystring, spawnpoint );

    // run two frames to allow everything to settle
    ge->RunFrame (); sv.framenum++;
    ge->RunFrame (); sv.framenum++;

    X86_POP_FPCW;

    // make sure maxclients string is correct
    sprintf( sv.configstrings[CS_MAXCLIENTS], "%d", sv_maxclients->integer );

    // all precaches are complete
    sv.state = ss_game;

#if USE_MVD_SERVER
    // respawn dummy MVD client, set base states, etc
    SV_MvdMapChanged();
#endif

    // set serverinfo variable
    SV_InfoSet( "mapname", sv.name );
    SV_InfoSet( "port", net_port->string );

    Cvar_SetInteger( sv_running, ss_game, FROM_CODE );
    Cvar_Set( "sv_paused", "0" );
    Cvar_Set( "timedemo", "0" );

    EXEC_TRIGGER( sv_changemapcmd );

#if USE_SYSCON
    SV_SetConsoleTitle();
#endif

    SV_BroadcastCommand( "reconnect\n" );

    Com_Printf ("-------------------------------------\n");
}
Beispiel #10
0
static void LumaFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_lumoverdrive", s_options_vr_ovr_lumaoverdrive_box.curvalue);
}
Beispiel #11
0
static void HudFixedFunc( void *unused )
{
	Cvar_SetInteger("vr_hud_fixed",s_options_vr_hud_fixed_box.curvalue);
}
Beispiel #12
0
static void EnableFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_enable", s_options_vr_ovr_enable_box.curvalue);
}
Beispiel #13
0
static void WarpFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_timewarp", s_options_vr_ovr_timewarp_box.curvalue);
}
Beispiel #14
0
static void AimmodeFunc( void *unused )
{
	Cvar_SetInteger( "vr_aimmode", s_options_vr_aimmode_box.curvalue);
}
Beispiel #15
0
static void ScaleFunc( void *unused )
{
	Cvar_SetInteger( "vr_ovr_maxfov", s_options_vr_ovr_maxfov_box.curvalue);
}
static void AutoFunc( void *unused )
{
	Cvar_SetInteger("vr_autoenable",s_options_vr_advanced_autoenable_box.curvalue);
}
Beispiel #17
0
static void ViewmodeFunc( void *unused )
{
	Cvar_SetInteger( "vr_viewmove", s_options_vr_viewmove_box.curvalue);
}
static void PositionFunc( void *unused )
{
	Cvar_SetInteger( "vr_positiontracking", s_options_vr_advanced_positiontracking_box.curvalue);
}
static void ChromaFunc( void *unused )
{
	Cvar_SetInteger( "vr_chromatic", s_options_vr_advanced_chroma_box.curvalue);
}
Beispiel #20
0
static void AutoIPDFunc ( void *unused )
{
	Cvar_SetInteger( "vr_autoipd", s_options_vr_autoipd_box.curvalue);
}
Beispiel #21
0
void OVR_FrameStart(int32_t changeBackBuffers)
{
	if (vr_ovr_maxfov->modified)
	{
		int newValue =  vr_ovr_maxfov->value ? 1 : 0;
		if (newValue != (int)vr_ovr_maxfov->value)
			Cvar_SetInteger("vr_ovr_maxfov",newValue);
		changeBackBuffers = 1;
		vr_ovr_maxfov->modified = (qboolean) false;
	}

	if (vr_ovr_supersample->modified)
	{
		if (vr_ovr_supersample->value < 1.0)
			Cvar_Set("vr_ovr_supersample", "1.0");
		else if (vr_ovr_supersample->value > 2.0)
			Cvar_Set("vr_ovr_supersample", "2.0");
		changeBackBuffers = 1;
		vr_ovr_supersample->modified = false;
	}
	if (useChroma != (qboolean) !!vr_chromatic->value)
	{
		useChroma = (qboolean) !!vr_chromatic->value;
	}

	if (vr_ovr_lumoverdrive->modified)
	{
		changeBackBuffers = 1;
		currentFrame = 0;
		vr_ovr_lumoverdrive->modified = false;
	}

	if (changeBackBuffers)
	{
		int i;
		float width, height;
		float ovrScale;

		OVR_CalculateState(&currentState);


		width = glConfig.render_width / (float) hmd->Resolution.w;
		height = glConfig.render_height / (float) hmd->Resolution.h;
		ovrScale = (width + height) / 2.0;
		ovrScale *= R_AntialiasGetScale() * vr_ovr_supersample->value;
		if (vr_ovr_debug->value)
			Com_Printf("VR_OVR: Set render target scale to %.2f\n",ovrScale);
		for (i = 0; i < 2; i++)
		{
			ovrRecti viewport = {{0,0}, {0,0}};
			renderInfo[i].renderTarget = ovrHmd_GetFovTextureSize(hmd, (ovrEyeType) i, renderInfo[i].eyeFov, ovrScale);
			viewport.Size.w = renderInfo[i].renderTarget.w;
			viewport.Size.h = renderInfo[i].renderTarget.h;
			ovrHmd_GetRenderScaleAndOffset(renderInfo[i].eyeFov, renderInfo[i].renderTarget, viewport, (ovrVector2f*) renderInfo[i].UVScaleOffset);

			if (renderInfo[i].renderTarget.w != renderInfo[i].eyeFBO.width || renderInfo[i].renderTarget.h != renderInfo[i].eyeFBO.height)
			{
				if (vr_ovr_debug->value)
					Com_Printf("VR_OVR: Set buffer %i to size %i x %i\n",i,renderInfo[i].renderTarget.w, renderInfo[i].renderTarget.h);
				R_ResizeFBO(renderInfo[i].renderTarget.w, renderInfo[i].renderTarget.h, 1, GL_RGBA8, &renderInfo[i].eyeFBO);
				R_ClearFBO(&renderInfo[i].eyeFBO);
			}

		}
	}
}
static void BounceFunc( void *unused )
{
	Cvar_SetInteger("vr_hud_bounce",s_options_vr_advanced_hudbounce_box.curvalue);
}
Beispiel #23
0
static void DebugFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_debug",s_options_vr_ovr_debug_box.curvalue);
}
static void TransFunc( void *unused )
{
	Cvar_SetInteger("vr_hud_transparency",s_options_vr_advanced_hudtrans_box.curvalue);
}
Beispiel #25
0
static void PredictionFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_autoprediction", s_options_vr_ovr_prediction_box.curvalue);
}
static void HUDFunc( void *unused )
{
	Cvar_SetValue( "vr_hud_depth", s_options_vr_advanced_hud_depth_slider.curvalue / 20.0f);
	Cvar_SetInteger( "vr_hud_fov", s_options_vr_advanced_hud_fov_slider.curvalue);
}
Beispiel #27
0
static void PersistenceFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_lowpersistence", s_options_vr_ovr_lowpersistence_box.curvalue);
}
static void NeckFunc( void *unused )
{
	Cvar_SetInteger( "vr_neckmodel", s_options_vr_advanced_neckmodel_box.curvalue );
}
Beispiel #29
0
static void ColorHackFunc( void *unused)
{
	Cvar_SetInteger("vr_ovr_dk2_color_hack", s_options_vr_ovr_dk2_color_hack_box.curvalue);
}
Beispiel #30
0
static void DistortionFunc( void *unused )
{
	Cvar_SetInteger( "vr_svr_distortion", 3 - s_options_vr_svr_distortion_box.curvalue  );
}