Пример #1
0
void SCR_SetUpToDrawConsole(void) {
	Con_CheckResize();

	if (scr_drawloading)
		return; // never a console with loading plaque

	// decide on the height of the console
	con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;

	if (con_forcedup) {
		scr_conlines = vid.conheight; // full screen
		scr_con_current = scr_conlines;
	} else if (key_dest == key_console)
		scr_conlines = vid.conheight / 2; // half screen
	else
		scr_conlines = 0; // none visible

	if (scr_conlines < scr_con_current) {
		scr_con_current -= scr_conspeed.getFloat() * host_frametime;
		if (scr_conlines > scr_con_current)
			scr_con_current = scr_conlines;

	} else if (scr_conlines > scr_con_current) {
		scr_con_current += scr_conspeed.getFloat() * host_frametime;
		if (scr_conlines < scr_con_current)
			scr_con_current = scr_conlines;
	}

	if (!(clearconsole++ < vid.numpages || clearnotify++ < vid.numpages))
		con_notifylines = 0;
}
Пример #2
0
void SCR_SizeDown_f(void) {
	//JHL:HACK; changed to affect the HUD, not SCR size
	if (hud.getInt() > 0) {
		hud.set(hud.getFloat() - 1);
		vid.recalc_refdef = 1;
	}
	//qmb :hud
	//Cvar_SetValue ("viewsize",scr_viewsize.value-10);
	//vid.recalc_refdef = 1;
}
Пример #3
0
/**
 * Called for important messages that should stay in the center of the screen
 * for a few moments
 */
void SCR_CenterPrint(const char *str) {
	strncpy(scr_centerstring, str, sizeof (scr_centerstring) - 1);
	scr_centertime_off = scr_centertime.getFloat();
	scr_centertime_start = cl.time;

	// count the number of lines for centering
	scr_center_lines = 1;
	while (*str) {
		if (*str == '\n')
			scr_center_lines++;
		str++;
	}
}
Пример #4
0
/**
 * Returns false if the time is too short to run a frame
 */
bool Host_FilterTime(float time) {
    realtime += time;

    if (max_fps.getInt() > 0) {
        // CAPTURE <*****@*****.**>
        if (!cls.capturedemo) // only allow the following early return if not capturing:
            if (!cls.timedemo && realtime - oldrealtime < 1.0 / max_fps.getFloat())
                return false; // framerate is too high
    }

    host_frametime = realtime - oldrealtime;
    oldrealtime = realtime;

    if (host_framerate.getFloat() > 0)
        host_frametime = host_framerate.getFloat();
    else { // don't allow really long or short frames
        if (host_frametime > 0.1)
            host_frametime = 0.1;
        if (host_frametime < 0.001)
            host_frametime = 0.001;
    }

    return true;
}
Пример #5
0
void SCR_DrawCenterString(void) {
	char *start;
	int l;
	int j;
	int x, y;
	int remaining;

	// the finale prints the characters one at a time
	if (cl.intermission)
		remaining = scr_printspeed.getFloat() * (cl.time - scr_centertime_start);
	else
		remaining = 9999;

	scr_erase_center = 0;
	start = scr_centerstring;

	if (scr_center_lines <= 4)
		y = vid.conheight * 0.35;
	else
		y = 48;

	do {
		// scan the width of the line
		for (l = 0; l < 40; l++)
			if (start[l] == '\n' || !start[l])
				break;
		x = (vid.conwidth - l * 8) / 2;
		for (j = 0; j < l; j++, x += 8) {
			Draw_Character(x, y, start[j]);
			if (!remaining--)
				return;
		}

		y += 8;

		while (*start && *start != '\n')
			start++;

		if (!*start)
			break;
		start++; // skip the \n
	} while (1);
}
Пример #6
0
/**
 * timedemo [demoname]
 */
void CL_TimeDemo_f(void) {
	if (CmdArgs::getSource() != CmdArgs::COMMAND)
		return;

	if (CmdArgs::getArgCount() != 2) {
		Con_Printf("timedemo <demoname> : gets demo speeds\n");
		return;
	}

	if (key_dest == key_console) {
		//make console disappare fast
		saveconspeed = scr_conspeed.getFloat();
		scr_conspeed.set(1000000.0f);
		Con_ToggleConsole_f();
	}

	CL_PlayDemo_f();

	// cls.td_starttime will be grabbed at the second frame of the demo, so
	// all the loading time doesn't get counted
	cls.timedemo = true;
	cls.td_startframe = host_framecount;
	cls.td_lastframe = -1; // get a new message this frame
}
Пример #7
0
int	NET_GetMessage (qsocket_t *sock)
{
    int ret;

    if (!sock)
        return -1;

    if (sock->disconnected)
    {
        Con_Printf("NET_GetMessage: disconnected socket\n");
        return -1;
    }

    SetNetTime();

    ret = sfunc.QGetMessage(sock);

    // see if this connection has timed out
    if (ret == 0 && sock->driver)
    {
        if (net_time - sock->lastMessageTime > net_messagetimeout.getFloat())
        {
            NET_Close(sock);
            return -1;
        }
    }


    if (ret > 0)
    {
        if (sock->driver)
        {
            sock->lastMessageTime = net_time;
            if (ret == 1)
                messagesReceived++;
            else if (ret == 2)
                unreliableMessagesReceived++;
        }

        if (recording)
        {
            vcrGetMessage.time = host_time;
            vcrGetMessage.op = VCR_OP_GETMESSAGE;
            vcrGetMessage.session = (long)sock;
            vcrGetMessage.ret = ret;
            vcrGetMessage.len = net_message.cursize;
            SystemFileManager::FileWrite (vcrFile, &vcrGetMessage, 24);
            SystemFileManager::FileWrite (vcrFile, net_message.data, net_message.cursize);
        }
    }
    else
    {
        if (recording)
        {
            vcrGetMessage.time = host_time;
            vcrGetMessage.op = VCR_OP_GETMESSAGE;
            vcrGetMessage.session = (long)sock;
            vcrGetMessage.ret = ret;
            SystemFileManager::FileWrite (vcrFile, &vcrGetMessage, 20);
        }
    }

    return ret;
}
Пример #8
0
/**
 * Must be called whenever vid changes
 * 
 * Internal use only
 */
static void SCR_CalcRefdef(void) {
	float size, fov;
	int h;
	bool full = false;

	scr_fullupdate = 0; // force a background redraw
	vid.recalc_refdef = 0;

	//========================================
	size = scr_viewsize.getFloat();
	fov = scr_fov.getFloat();

	// bound viewsize
	size = max(30, size);
	size = min(120, size);

	// bound field of view
	fov = max(10, fov);
	fov = min(170, fov);

	if (size != scr_viewsize.getFloat())
		scr_viewsize.set(size);
	if (fov != scr_fov.getFloat())
		scr_fov.set(fov);

	sb_lines = 24 + 16 + 8;
	if (size >= 100.0) {
		full = true;
		size = 100.0;
	}

	if (cl.intermission) {
		full = true;
		size = 100;
		sb_lines = 0;
	}

	size /= 100.0f;

	// TODO: remove sb_lines variable
	h = vid.height; // - sb_lines;

	r_refdef.vrect.width = vid.width * size;
	if (r_refdef.vrect.width < 96) {
		size = 96.0 / r_refdef.vrect.width;
		r_refdef.vrect.width = 96; // min for icons
	}

	r_refdef.vrect.height = (signed)vid.height * size;
	//if (r_refdef.vrect.height > (signed)vid.height - sb_lines)
	//	r_refdef.vrect.height = (signed)vid.height - sb_lines;
	if (r_refdef.vrect.height > (signed)vid.height)
		r_refdef.vrect.height = vid.height;
	r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2;

	if (full)
		r_refdef.vrect.y = 0;
	else
		r_refdef.vrect.y = (h - r_refdef.vrect.height) / 2;

	r_refdef.fov_x = fov;
	r_refdef.fov_y = CalcFov(r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);

	scr_vrect = r_refdef.vrect;
}