Пример #1
0
/**
 * @sa CL_Frame
 */
static void CL_SendCommand (void)
{
	/* get new key events */
	IN_SendKeyEvents();

	/* process console commands */
	Cbuf_Execute();

	/* send intentions now */
	CL_SendChangedUserinfos();

	/* fix any cheating cvars */
	Cvar_FixCheatVars();

	switch (cls.state) {
	case ca_disconnected:
		/* if the local server is running and we aren't connected then connect */
		if (Com_ServerState()) {
			cls.servername[0] = '\0';
			cls.serverport[0] = '\0';
			CL_SetClientState(ca_connecting);
			return;
		}
		break;
	case ca_connecting:
		if (CL_Milliseconds() - cls.connectTime > cl_connecttimeout->integer) {
			if (GAME_IsMultiplayer())
				Com_Error(ERR_DROP, "Server is not reachable");
		}
		break;
	case ca_connected:
		if (cls.waitingForStart) {
			if (CL_Milliseconds() - cls.waitingForStart > cl_connecttimeout->integer) {
				Com_Error(ERR_DROP, "Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout",
						cl_connecttimeout->integer / 1000);
			} else {
				SCR_DrawLoading(100);
			}
		}
		break;
	default:
		break;
	}
}
Пример #2
0
int TTY_Connect(int handle, char *host)
{
	double	start;
	ComPort	*p;
	char	*response = NULL;
	keydest_t	save_key_dest;
	byte	dialstring[64];
	byte	b;

	p = handleToPort[handle];

	if ((p->modemStatus & MODEM_STATUS_MASK) != MODEM_STATUS_MASK)
	{
		Con_Printf ("Serial: line not ready (");
		if ((p->modemStatus & MSR_CTS) == 0)
			Con_Printf(" CTS");
		if ((p->modemStatus & MSR_DSR) == 0)
			Con_Printf(" DSR");
		if ((p->modemStatus & MSR_CD) == 0)
			Con_Printf(" CD");
		Con_Printf(" )");
		return -1;
	}

	// discard any scraps in the input buffer
	while (! EMPTY (p->inputQueue))
		DEQUEUE (p->inputQueue, b);

	CheckStatus (p);

	if (p->useModem)
	{
		save_key_dest = key_dest;
		key_dest = key_console;
		key_count = -2;

		Con_Printf ("Dialing...\n");
		snprintf (dialstring, sizeof(dialstring), "AT D%c %s\r", p->dialType, host);
		Modem_Command (p, dialstring);
		start = Sys_DoubleTime();
		while(1)
		{
			if ((Sys_DoubleTime() - start) > 60.0)
			{
				Con_Printf("Dialing failure!\n");
				break;
			}

			IN_SendKeyEvents ();
			if (key_count == 0)
			{
				if (key_lastpress != K_ESCAPE)
				{
					key_count = -2;
					continue;
				}
				Con_Printf("Aborting...\n");
				while ((Sys_DoubleTime() - start) < 5.0)
					;
				disable();
				p->outputQueue.head = p->outputQueue.tail = 0;
				p->inputQueue.head = p->inputQueue.tail = 0;
				outportb(p->uart + MODEM_CONTROL_REGISTER, inportb(p->uart + MODEM_CONTROL_REGISTER) & ~MCR_DTR);
				enable();
				start = Sys_DoubleTime();
				while ((Sys_DoubleTime() - start) < 0.75)
					;
				outportb(p->uart + MODEM_CONTROL_REGISTER, inportb(p->uart + MODEM_CONTROL_REGISTER) | MCR_DTR);
				response = "Aborted";
				break;
			}

			response = Modem_Response(p);
			if (!response)
				continue;
			if (Q_strncmp(response, "CONNECT", 7) == 0)
			{
				disable();
				p->modemRang = true;
				p->modemConnected = true;
				p->outputQueue.head = p->outputQueue.tail = 0;
				p->inputQueue.head = p->inputQueue.tail = 0;
				enable();
				key_dest = save_key_dest;
				key_count = 0;
				m_return_onerror = false;
				return 0;
			}
			if (Q_strncmp(response, "NO CARRIER", 10) == 0)
				break;
			if (Q_strncmp(response, "NO DIALTONE", 11) == 0)
				break;
			if (Q_strncmp(response, "NO DIAL TONE", 12) == 0)
				break;
			if (Q_strncmp(response, "NO ANSWER", 9) == 0)
				break;
			if (Q_strncmp(response, "BUSY", 4) == 0)
				break;
			if (Q_strncmp(response, "ERROR", 5) == 0)
				break;
		}
		key_dest = save_key_dest;
		key_count = 0;
		if (m_return_onerror)
		{
			key_dest = key_menu;
			m_state = m_return_state;
			m_return_onerror = false;
			Q_strncpy(m_return_reason, response, 31);
		}
		return -1;
	}
	m_return_onerror = false;
	return 0;
}
Пример #3
0
void Sys_SendKeyEvents (void)
{
	IN_SendKeyEvents();
}
Пример #4
0
/*
==================
Host_Frame

Runs all active servers
==================
*/
void _Host_Frame (float time)
{
	static double		time1 = 0;
	static double		time2 = 0;
	static double		time3 = 0;
	int			pass1, pass2, pass3;

	if (setjmp (host_abortserver) )
		return;			// something bad happened, or the server disconnected

// keep the random time dependent
	rand ();
	
// decide the simulation time
	if (!Host_FilterTime (time))
		return;			// don't run too fast, or packets will flood out

// get new key events
#if !defined (__APPLE__) && !defined (MACOSX)
	Sys_SendKeyEvents ();
#else
    {
        void IN_SendKeyEvents (void);
        
        IN_SendKeyEvents ();
    }
#endif // !__APPLE__ && !MACOSX

// allow mice or other external controllers to add commands
	IN_Commands ();

// process console commands
	Cbuf_Execute ();

	NET_Poll();

// if running the server locally, make intentions now
	if (sv.active)
		CL_SendCmd ();
	
//-------------------
//
// server operations
//
//-------------------

// check for commands typed to the host
	Host_GetConsoleCommands ();
	
	if (sv.active)
		Host_ServerFrame ();

//-------------------
//
// client operations
//
//-------------------

// if running the server remotely, send intentions now after
// the incoming messages have been read
	if (!sv.active)
		CL_SendCmd ();

	host_time += host_frametime;

// fetch results from server
	if (cls.state == ca_connected)
	{
                CL_ReadFromServer ();
	}

// update video
	if (host_speeds.value)
		time1 = Sys_FloatTime ();

	SCR_UpdateScreen ();

	if (host_speeds.value)
		time2 = Sys_FloatTime ();

// update audio
	if (cls.signon == SIGNONS)
	{
		S_Update (r_origin, vpn, vright, vup);
		CL_DecayLights ();
	}
	else
		S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
	
	CDAudio_Update();

	if (host_speeds.value)
	{
		pass1 = (time1 - time3)*1000;
		time3 = Sys_FloatTime ();
		pass2 = (time2 - time1)*1000;
		pass3 = (time3 - time2)*1000;
		Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
					pass1+pass2+pass3, pass1, pass2, pass3);
	}
	
	host_framecount++;
}