Example #1
0
/*
-----------------------------------------------------------------------------
 Function: Cbuf_ExecuteText -Execute string.
 
 Parameters: exec_when -[in] see execwhen_t definition.
			 text -[in] string with command to execute.
 Returns:
 
 Notes: 

-----------------------------------------------------------------------------
*/
PUBLIC void Cbuf_ExecuteText( execwhen_t exec_when, char *text )
{
	switch( exec_when )
	{
		case EXEC_NOW:
			Cmd_ExecuteString( text );
			break;

		case EXEC_INSERT:
			Cbuf_InsertText( text );
			break;

		case EXEC_APPEND:
			Cbuf_AddText( text );
			break;

		default:
			Com_DPrintf( "Cbuf_ExecuteText: bad exec_when" );
	}
}
Example #2
0
/*
===============
Cbuf_AddEarlyCommands

Adds command line parameters as script statements
Commands lead with a +, and continue until another +

Set commands are added early, so they are guaranteed to be set before
the client and server initialize for the first time.

Other commands are added late, after all initialization is complete.
===============
*/
void Cbuf_AddEarlyCommands (qboolean clear)
{
	int		i;
	char	*s;

	for (i=0 ; i<COM_Argc() ; i++)
	{
		s = COM_Argv(i);
		if (strcmp (s, "+set"))
			continue;
		Cbuf_AddText (va("set %s %s\n", COM_Argv(i+1), COM_Argv(i+2)));
		if (clear)
		{
			COM_ClearArgv(i);
			COM_ClearArgv(i+1);
			COM_ClearArgv(i+2);
		}
		i+=2;
	}
}
Example #3
0
/*
============
Cbuf_ExecuteText
============
*/
void Cbuf_ExecuteText( int exec_when, const char *text ) {
	switch ( exec_when )
	{
	case EXEC_NOW:
		if ( text && strlen( text ) > 0 ) {
			Cmd_ExecuteString( text );
		} else {
			Cbuf_Execute();
		}
		break;
	case EXEC_INSERT:
		Cbuf_InsertText( text );
		break;
	case EXEC_APPEND:
		Cbuf_AddText( text );
		break;
	default:
		Com_Error( ERR_FATAL, "Cbuf_ExecuteText: bad exec_when" );
	}
}
Example #4
0
qboolean TP_SoundTrigger(char *message)	//if there is a trigger there, play it. Return true if we found one, stripping off the file (it's neater that way).
{
	char *strip;
	char *lineend = NULL;
	char soundname[128];
	int filter = 0;

	for (strip = message+strlen(message)-1; *strip && strip >= message; strip--)
	{
		if (*strip == '#')
			filter++;
		if (*strip == ':')
			break;	//if someone says just one word, we can take any tidles in their name to be a voice command
		if (*strip == '\n')
			lineend = strip;
		else if (*strip <= ' ')
		{
			if (filter == 0 || filter == 1)	//allow one space in front of a filter.
			{
				filter++;
				continue;
			}
			break;
		}
		else if (*strip == '~')
		{
			//looks like a trigger, whoopie!
			if (lineend-strip > sizeof(soundname)-1)
			{
				Con_Printf("Sound trigger's file-name was too long\n");
				return false;
			}
			Q_strncpyz(soundname, strip+1, lineend-strip);
			memmove(strip, lineend, strlen(lineend)+1);

			Cbuf_AddText(va("play %s\n", soundname), RESTRICT_LOCAL);
			return true;
		}
	}
	return false;
}
Example #5
0
int main(int argc, char **argv)
{
    char cmdline[] = "+set sv_pure 0 +set vm_ui 0 +set vm_game 0 +set vm_cgame 0 +set fs_basepath ./app/native";
	cvar_t		*cv = NULL;
	char cmd_rundemo[100];
    Sys_SetDefaultCDPath("./app/native");

    //saved_euid = geteuid();

    // Clear the queues
    memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) );
    memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );

    // Initialize game
    Com_Init(cmdline);
    NET_Init();

    // Start game with running demo
#if 0
    cv = Cvar_Get("rundemo", "0", 0);
    Cvar_Set("rundemo", "demo1.dm_68");
	if (strcmp(cv->string, "0")) {
        memset(cmd_rundemo, 0, sizeof(cmd_rundemo));
        sprintf(cmd_rundemo, "demo %s", cv->string, sizeof(cmd_rundemo));

        Cbuf_AddText(cmd_rundemo);

        Com_Printf(" -- starting execution --- ");

        Cbuf_Execute();
        Com_Printf(" -- execution done --- ");
	}
#endif

	while (1) {
#if 0
		Cvar_Set("nextdemo", "demo1.dm_68");
#endif
		Com_Frame( );
	}
}
Example #6
0
void LoadGameCallback(void *self)
{
    menuaction_s *a = ( menuaction_s * )self;

    // set saveshot name here
    if (m_saveshotvalid[a->generic.localdata[0]])
    {
        Com_sprintf(loadshotname, sizeof(loadshotname), "/save/kmq2save%i/shot.jpg", a->generic.localdata[0]);
        load_saveshot = loadshotname;
    }
    else
    {
        load_saveshot = NULL;
    }

    if (m_savevalid[a->generic.localdata[0]])
    {
        Cbuf_AddText(va("load kmq2save%i\n", a->generic.localdata[0]));
    }
    UI_ForceMenuOff();
}
Example #7
0
/*
===============
GL_Init
===============
*/
static void GL_Init (void)
{
	gl_vendor = (const char *) glGetString (GL_VENDOR);
	gl_renderer = (const char *) glGetString (GL_RENDERER);
	gl_version = (const char *) glGetString (GL_VERSION);
	gl_extensions = (const char *) glGetString (GL_EXTENSIONS);

	if (gl_extensions_nice != NULL)
		Z_Free (gl_extensions_nice);
	gl_extensions_nice = GL_MakeNiceExtensionsList (gl_extensions);

	GL_CheckExtensions (); //johnfitz

	//johnfitz -- intel video workarounds from Baker
	if (!strcmp(gl_vendor, "Intel"))
	{
		Con_Printf ("Intel Display Adapter detected, enabling gl_clear\n");
		Cbuf_AddText ("gl_clear 1");
	}
	//johnfitz
}
void SV_RemoteCmdInit(){

    sv_rconsys = Cvar_RegisterBool("sv_rconsys", qtrue, CVAR_ARCHIVE, "Disable/enable the internal remote-command-system");

    if(!sv_rconsys->boolean) return;

    //Init the permission table with default values
    Cmd_ResetPower();

    Cmd_SetPower("cmdlist", 1);
    Cmd_SetPower("serverinfo", 1);
    Cmd_SetPower("systeminfo", 1);
    Cmd_SetPower("ministatus", 1);
    Cmd_SetPower("status", 30);
    Cmd_SetPower("dumpuser", 40);
    Cmd_SetPower("kick", 35);
    Cmd_SetPower("tempban", 50);
    Cmd_SetPower("unban", 50);
    Cmd_SetPower("permban", 80);
    Cmd_SetPower("btempban", 80);
    Cmd_SetPower("bpermban", 70);
    Cmd_SetPower("map", 60);
    Cmd_SetPower("map_restart", 50);
    Cmd_SetPower("adminlist", 90);
    Cmd_SetPower("cmdpowerlist", 90);
    Cmd_SetPower("tell", 60);
    Cmd_SetPower("say", 60);
    Cmd_SetPower("screentell", 70);
    Cmd_SetPower("screensay", 70);
    Cmd_SetPower("dumpbanlist", 30);
    Cmd_SetPower("setcmdminpower", 95);
    Cmd_SetPower("setadmin", 95);
    Cmd_SetPower("unsetadmin", 95);
    Cbuf_AddText(0, "addCommand gametype \"set g_gametype $arg; map_restart\"");
    Cmd_SetPower("gametype", 60);

    cmdInvoker.currentCmdPower = 100; //Set the default to 100 to prevent any blocking on local system. If a command gets remotely executed it will be set temporarely to the expected power
    //Now read the rest from file - Changed this will happen by executing nvconfig.cfg (nonvolatile config)
    cmdSystemInitialized = qtrue;
}
Example #9
0
/*
===============
IN_Frame
===============
*/
void IN_Frame( void )
{
	qboolean loading;

	IN_JoyMove( );
	IN_ProcessEvents( );

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading = ( clc.state != CA_DISCONNECTED && clc.state != CA_ACTIVE );

	if( !cls.glconfig.isFullscreen && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
	{
		// Console is down in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !cls.glconfig.isFullscreen && ( Key_GetCatcher( ) & KEYCATCH_CHATCONSOLE ) )
	{
		// Console is down in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !cls.glconfig.isFullscreen && loading )
	{
		// Loading in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_INPUT_FOCUS ) )
	{
		// Window not got focus
		IN_DeactivateMouse( );
	}
	else
		IN_ActivateMouse( );

	// In case we had to delay actual restart of video system
	if( ( vidRestartTime != 0 ) && ( vidRestartTime < Sys_Milliseconds( ) ) )
	{
		vidRestartTime = 0;
		Cbuf_AddText( "vid_restart\n" );
	}
}
/**
 * \brief Execute autoexec script
 */
PUBLIC void FS_ExecAutoexec( void )
{
	char *dir;
	char name[ MAX_GAMEPATH ];

	dir = Cvar_VariableString( "gamedir" );
	if( *dir )
	{
		com_snprintf( name, sizeof( name ), "%s%c%s%cautoexec.cfg", fs_basedir->string, PATH_SEP, dir, PATH_SEP ); 
	}
	else
	{
		com_snprintf(name, sizeof(name), "%s%c%s%cautoexec.cfg", fs_basedir->string, PATH_SEP, BASE_DIRECTORY, PATH_SEP); 
	}

	if( FS_FindFirst( name, 0, FA_DIR | FA_HIDDEN | FA_SYSTEM ) )
	{
		Cbuf_AddText( "exec autoexec.cfg\n" );
	}

	FS_FindClose();
}
Example #11
0
void IN_Frame(void)
{
	qboolean loading;
	qboolean fullscreen;

	IN_JoyMove();
	IN_ProcessEvents();

	// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
	loading    = !!(cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE);
	fullscreen = Cvar_VariableIntegerValue("r_fullscreen");

	if (!fullscreen && (Key_GetCatcher() & KEYCATCH_CONSOLE))
	{
		// Console is down in windowed mode
		IN_DeactivateMouse();
	}
	else if (!fullscreen && loading)
	{
		// Loading in windowed mode
		IN_DeactivateMouse();
	}
	else if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS))
	{
		// Window not got focus
		IN_DeactivateMouse();
	}
	else
	{
		IN_ActivateMouse();
	}

	/* in case we had to delay actual restart of video system... */
	if ((vidRestartTime != 0) && (vidRestartTime < Sys_Milliseconds()))
	{
		vidRestartTime = 0;
		Cbuf_AddText("vid_restart");
	}
}
Example #12
0
/*
==================
SCR_Init
==================
*/
void SCR_Init( void )
{
	if( scr_init ) return;

	MsgDev( D_NOTE, "SCR_Init()\n" );
	scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" );
	cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" );
	cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", CVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
	scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" );
	scr_download = Cvar_Get( "scr_download", "0", 0, "downloading bar progress" );
	cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" );
	cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", CVAR_ARCHIVE, "envshot size of cube side" );
	scr_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" );
	scr_viewsize = Cvar_Get( "viewsize", "120", CVAR_ARCHIVE, "screen size" );
	
	// register our commands
	Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
	Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
	Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" );

	if( host.state != HOST_RESTART && !UI_LoadProgs( ))
	{
		Msg( "^1Error: ^7can't initialize MainUI.dll\n" ); // there is non fatal for us
		if( !host.developer ) host.developer = 1; // we need console, because menu is missing
	}

	SCR_RegisterShaders ();
	SCR_InitCinematic();
	SCR_VidInit();

	if( host.state != HOST_RESTART )
          {
		if( host.developer && Sys_CheckParm( "-toconsole" ))
			Cbuf_AddText( "toggleconsole\n" );
		else UI_SetActiveMenu( true );
	}

	scr_init = true;
}
Example #13
0
/*
** GLimp_EndFrame
** 
** Responsible for doing a swapbuffers and possibly for other stuff
** as yet to be determined.  Probably better not to make this a GLimp
** function and instead do a call to GLimp_SwapBuffers.
*/
void GLimp_EndFrame (void)
{
  // don't flip if drawing to front buffer
  if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
  {
    SDL_GL_SwapBuffers();
  }

  if( r_fullscreen->modified )
  {
    qboolean    fullscreen;
    qboolean    sdlToggled = qfalse;
    SDL_Surface *s = SDL_GetVideoSurface( );

    if( s )
    {
      // Find out the current state
      if( s->flags & SDL_FULLSCREEN )
        fullscreen = qtrue;
      else
        fullscreen = qfalse;

      // Is the state we want different from the current state?
      if( !!r_fullscreen->integer != fullscreen )
        sdlToggled = SDL_WM_ToggleFullScreen( s );
      else
        sdlToggled = qtrue;
    }

    // SDL_WM_ToggleFullScreen didn't work, so do it the slow way
    if( !sdlToggled )
      Cbuf_AddText( "vid_restart" );

    r_fullscreen->modified = qfalse;
  }

  // check logging
  QGL_EnableLogging( (qboolean)r_logFile->integer ); // bk001205 - was ->value
}
Example #14
0
void GFXPresetToggle(qbool back) {
	if (back) fps_mode--; else fps_mode++;
	if (fps_mode < 0) fps_mode = mode_undef - 1;
	if (fps_mode >= mode_undef) fps_mode = 0;

	switch (GFXPreset()) {
#ifdef GLQUAKE
	case mode_fastest: Cbuf_AddText ("exec cfg/gfx_gl_fast.cfg\n"); return;
	case mode_higheyecandy: Cbuf_AddText ("exec cfg/gfx_gl_higheyecandy.cfg\n"); return;
	case mode_faithful: Cbuf_AddText ("exec cfg/gfx_gl_faithful.cfg\n"); return;
	case mode_eyecandy: Cbuf_AddText ("exec cfg/gfx_gl_eyecandy.cfg\n"); return;
#else
	case mode_fastest: Cbuf_AddText ("exec cfg/gfx_sw_fast.cfg\n"); return;
	case mode_default: Cbuf_AddText ("exec cfg/gfx_sw_default.cfg\n"); return;
#endif
	}
}
Example #15
0
void qtvlist_joinfromqtv_cmd(void)
{
	/* FIXME: Make this prettier */
	char addr[512];
	char httpaddr[512];
	char gameaddress[512];
	char *currstream, *server;

	currstream = CL_QTV_GetCurrentStream();
	if (currstream == NULL) {
		Com_Printf("Not connected to a QTV, can't join\n");
		return;
	}

	strlcpy(&addr[0], currstream, sizeof(addr));
	/* Bleh, transformation of id@server:port to http://server:port/watch.qtv?sid=id */
	server = strchr(&addr[0], '@');
	if (server == NULL) {
		Com_Printf("error: wrong format on input\n");
		return;
	}
	*server++ = 0;
	
	snprintf(&httpaddr[0], sizeof(httpaddr), "http://%s/watch.qtv?sid=%s", server, &addr[0]);

	if (SDL_TryLockMutex(qtvlist_mutex) != 0) {
		Com_Printf("qtvlist is being updated, please try again soon\n");
		return;
	}
	qtvlist_get_gameaddress((const char*)&httpaddr[0], &gameaddress[0], sizeof(gameaddress));
	SDL_UnlockMutex(qtvlist_mutex);

	if (gameaddress[0] != 0) {
		Cbuf_AddText(va("connect %s\n", &gameaddress[0]));
	} else {
		Com_Printf("No game address found for this QTV stream\n");
	}
}
Example #16
0
static qbool FChecks_CheckFRulesetRequest (const char *s)
{
	// format of the reply:
	// [nick: ]
	// [padding] - so that "nick: " + padding is 17 chars long
	// [ip address] - padded with spaces to 21 chars
	// - this fits to 38 chars which is length of line with conwidth 320
	// [space]
	// [client version] - padded to 16 chars
	// [ruleset name]
	// [ruleset addition]
	// - these 4 should be less than 38 chars so that reply does never take up more than 2 lines
	char *fServer;
	const char *features;
	char *emptystring = "";
	char *brief_version = "ezq" VERSION_NUMBER;
	char *ruleset = Rulesets_Ruleset();
	size_t name_len = strlen(cl.players[cl.playernum].name);
	size_t pad_len = 15 - min(name_len, 15);

	if (cl.spectator || (f_ruleset_reply_time && cls.realtime - f_ruleset_reply_time < 20))
		return false;

	if (Util_F_Match(s, "f_ruleset"))	{
		features = FChecks_RulesetAdditionString();
		fServer = FChecks_FServerResponse_Text();
		if (!fServer) {
			fServer = "server-na";
		}

		Cbuf_AddText(va("say \"%*s%21s %16s %s%s\"\n",
			pad_len, emptystring, fServer, brief_version, ruleset, features));
		f_ruleset_reply_time = cls.realtime;
		return true;
	}

	return false;
}
Example #17
0
int Daisy_main ( void )
{
    char cmdline[] = "+set sv_pure 0 +set vm_ui 0 +set vm_game 0 +set vm_cgame 0 +set fs_basepath /media/usd";
	cvar_t		*cv = NULL;
	char cmd_rundemo[100];
    Sys_SetDefaultCDPath("/media/usd");

    //saved_euid = geteuid();

    // Clear the queues
    memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
    memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );

    // Initialize game
    Com_Init(cmdline);

    // Start game with running demo
#if 0
    cv = Cvar_Get("rundemo", "0", 0);
    Cvar_Set("rundemo", "demo1.dm_68");
	if (strcmp(cv->string, "0")) {
        memset(cmd_rundemo, 0, sizeof(cmd_rundemo));
        sprintf(cmd_rundemo, "demo %s", cv->string, sizeof(cmd_rundemo));

        // Cbuf_AddText("demo FOUR.DM_68");
        Cbuf_AddText(cmd_rundemo);

        log_printf(LOG_INFO, " -- starting execution --- ");
        
        Cbuf_Execute();`
        log_printf(LOG_INFO, " -- execution done --- ");
	}
#endif

	while (1) {
		Com_Frame( );
	}
}
Example #18
0
// When a command wants to issue other commands immediately, the text is
// inserted at the beginning of the buffer, before any remaining unexecuted
// commands.
void Cbuf_InsertText(char *text)
{

	int addLen = Q_strlen(text);
	int currLen = cmd_text.cursize;

	if (cmd_text.cursize + addLen >= cmd_text.maxsize)
	{
		Con_Printf(__FUNCTION__ ": overflow\n");
		return;
	}

#ifdef REHLDS_FIXES
	if (currLen)
		Q_memmove(cmd_text.data + addLen, cmd_text.data, currLen);

	Q_memcpy(cmd_text.data, text, addLen);
	cmd_text.cursize += addLen;

#else
	char *temp = NULL;
	if (currLen)
	{
		
		temp = (char *)Z_Malloc(currLen);	// TODO: Optimize: better use memmove without need for a temp buffer
		Q_memcpy(temp, cmd_text.data, currLen);
		SZ_Clear(&cmd_text);
	}

	Cbuf_AddText(text);

	if (currLen)
	{
		SZ_Write(&cmd_text, temp, currLen);
		Z_Free(temp);
	}
#endif // REHLDS_FIXES
}
Example #19
0
/* <3617e> ../engine/host.c:201 */
NOXREF void Host_EndGame(const char *message, ...)
{
	int oldn;
	va_list argptr;
	char string[1024];

	va_start(argptr,message);
	Q_vsnprintf(string, sizeof(string), message, argptr);
	va_end(argptr);

	Con_DPrintf("Host_EndGame: %s\n", string);

	oldn = g_pcls.demonum;

	if (g_psv.active)
		Host_ShutdownServer(FALSE);

	g_pcls.demonum = oldn;

	if (!g_pcls.state)
	{
		Sys_Error("Host_EndGame: %s\n", string);
	}

	if (oldn != -1)
	{
		CL_Disconnect_f();
		g_pcls.demonum = oldn;
		Host_NextDemo();
		longjmp(host_enddemo, 1);
	}

	CL_Disconnect();
	Cbuf_AddText("cd stop\n");
	Cbuf_Execute();
	longjmp(host_abortserver, 1);
}
Example #20
0
/*
==============================
Netchan_CheckForCompletion

==============================
*/
void Netchan_CheckForCompletion( netchan_t *chan, int stream, int intotalbuffers )
{
	int	c, id;
	int	size;
	fragbuf_t	*p;

	size = 0;
	c = 0;

	p = chan->incomingbufs[stream];
	if( !p ) return;

	while( p )
	{
		size += BF_GetNumBytesWritten( &p->frag_message );
		c++;

		id = FRAG_GETID( p->bufferid );
		if( id != c )
		{
			if( chan->sock == NS_CLIENT )
			{
				MsgDev( D_ERROR, "Lost/dropped fragment would cause stall, retrying connection\n" );
				Cbuf_AddText( "reconnect\n" );
			}
		}
		p = p->next;
	}

	// received final message
	if( c == intotalbuffers )
	{
		chan->incomingready[stream] = true;
		MsgDev( D_NOTE, "\nincoming is complete %i bytes waiting\n", size );
	}
}
Example #21
0
void IN_Frame (void) {
	IN_JoyMove( );
	IN_ProcessEvents( );

	if( !cls.glconfig.isFullscreen && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
	{
		// Console is down in windowed mode
		IN_DeactivateMouse( );
	}
	else if( !( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_INPUT_FOCUS ) )
	{
		// Window not got focus
		IN_DeactivateMouse( );
	}
	else
		IN_ActivateMouse( );

	// In case we had to delay actual restart of video system
	if( ( vidRestartTime != 0 ) && ( vidRestartTime < Sys_Milliseconds( ) ) )
	{
		vidRestartTime = 0;
		Cbuf_AddText( "vid_restart\n" );
	}
}
Example #22
0
File: cmd.c Project: Slipyx/r1q2
/*
============
Cbuf_InsertText

Adds command text immediately after the current command
Adds a \n to the text
FIXME: actually change the command buffer to do less copying
============
*/
void Cbuf_InsertText (const char *text)
{
	char	temp[COMMAND_BUFFER_SIZE];
	int		templen;

// copy off any commands still remaining in the exec buffer
	templen = cmd_text.cursize;
	if (templen)
	{
		//temp = Z_TagMalloc (templen, TAGMALLOC_CMDBUFF);
		//temp = alloca (templen);
		memcpy (temp, cmd_text_buf, templen);
		SZ_Clear (&cmd_text);
	}
	//else
	//	temp = NULL;	// shut up compiler
		
// add the entire text of the file
	Cbuf_AddText (text);
	
// add the copied off data
	if (templen)
		SZ_Write (&cmd_text, temp, templen);
}
void D3DWin8_NotifyNewWindow( IUnknown* window, int logicalSizeX, int logicalSizeY )
{
    // Re-enable the deferral of the video init
    ResetEvent( g_WaitingForVideoEvent );
    ResetEvent( g_WaitingForVideoFinishedEvent );

    // Restart the video if we're already running
    if ( g_Window != nullptr )
    {
        Cbuf_AddText( "vid_restart\n" );
        SAFE_RELEASE( g_Window );
    }

    // Swap out the window information
    g_Window = window;
    g_WindowWidth = logicalSizeX;
    g_WindowHeight = logicalSizeY;

    // Allow the game to run again
    SetEvent( g_WaitingForVideoEvent );

    // Wait for video to bring up before we allow the main thread to continue
    WaitForSingleObjectEx( g_WaitingForVideoFinishedEvent, INFINITE, FALSE );
}
Example #24
0
void MS_Handle_Content_Button(struct menu_ct *content){

	if (!keydown[K_MOUSE1])
	{
		content->pressed = 0;
		content->pressed_time = 0;
		return;
	}
	
	if (keydown[K_MOUSE1] && content->pressed)
		return;

	if (content->subtype == 1)
		Cbuf_AddText(content->name);
	if (content->subtype == 2)
		if (content->function)
			content->function();
	if (content->subtype == 3)
		if (content->update_function)
			content->update_function(content);
	content->pressed =1;
	content->pressed_time = cls.realrealtime;

}
Example #25
0
/*
====================
Curl_CheckCommandWhenDone

Checks if a "done command" is to be executed.
All downloads finished, at least one success since connect, no single failure
-> execute the command.
*/
static void Curl_CheckCommandWhenDone(void)
{
	if(!curl_dll)
		return;
	if(numdownloads_added && (numdownloads_success == numdownloads_added) && *command_when_done)
	{
		Con_DPrintf("cURL downloads occurred, executing %s\n", command_when_done);
		Cbuf_AddText("\n");
		Cbuf_AddText(command_when_done);
		Cbuf_AddText("\n");
		Curl_Clear_forthismap();
	}
	else if(numdownloads_added && numdownloads_fail && *command_when_error)
	{
		Con_DPrintf("cURL downloads FAILED, executing %s\n", command_when_error);
		Cbuf_AddText("\n");
		Cbuf_AddText(command_when_error);
		Cbuf_AddText("\n");
		Curl_Clear_forthismap();
	}
}
Example #26
0
static menuSound_t Activate(menuCommon_t *self)
{
    switch (self->type) {
    case MTYPE_ACTION:
        Cbuf_AddText(&cmd_buffer, ((menuAction_t *)self)->cmd);
        Cbuf_AddText(&cmd_buffer, "\n");
        break;
    case MTYPE_BITMAP:
        Cbuf_AddText(&cmd_buffer, ((menuBitmap_t *)self)->cmd);
        Cbuf_AddText(&cmd_buffer, "\n");
        break;
    case MTYPE_SAVEGAME:
        Cbuf_AddText(&cmd_buffer, va("save \"%s\"; forcemenuoff\n", ((menuAction_t *)self)->cmd));
        break;
    case MTYPE_LOADGAME:
        Cbuf_AddText(&cmd_buffer, va("load \"%s\"\n", ((menuAction_t *)self)->cmd));
        break;
    default:
        break;
    }

    return QMS_NOTHANDLED;
}
Example #27
0
/*
==================
SV_Frame

Player movement occurs as a result of packet events, which
happen before SV_Frame is called
==================
*/
void SV_Frame( int msec ) {
	int		frameMsec;
	int		startTime;

	// the menu kills the server with this cvar
	if ( sv_killserver->integer ) {
		SV_Shutdown ("Server was killed");
		Cvar_Set( "sv_killserver", "0" );
		return;
	}

	if (!com_sv_running->integer)
	{
		if(com_dedicated->integer)
		{
			// Block indefinitely until something interesting happens
			// on STDIN.
			NET_Sleep(-1);
		}
		
		return;
	}

	// allow pause if only the local client is connected
	if ( SV_CheckPaused() ) {
		return;
	}

	// if it isn't time for the next frame, do nothing
	if ( sv_fps->integer < 1 ) {
		Cvar_Set( "sv_fps", "10" );
	}

	frameMsec = 1000 / sv_fps->integer * com_timescale->value;
	// don't let it scale below 1ms
	if(frameMsec < 1)
	{
		Cvar_Set("timescale", va("%f", sv_fps->integer / 1000.0f));
		frameMsec = 1;
	}

	sv.timeResidual += msec;

	if (!com_dedicated->integer) SV_BotFrame (sv.time + sv.timeResidual);

	if ( com_dedicated->integer && sv.timeResidual < frameMsec ) {
		// NET_Sleep will give the OS time slices until either get a packet
		// or time enough for a server frame has gone by
		NET_Sleep(frameMsec - sv.timeResidual);
		return;
	}

	// if time is about to hit the 32nd bit, kick all clients
	// and clear sv.time, rather
	// than checking for negative time wraparound everywhere.
	// 2giga-milliseconds = 23 days, so it won't be too often
	if ( svs.time > 0x70000000 ) {
		SV_Shutdown( "Restarting server due to time wrapping" );
		Cbuf_AddText( va( "map %s\n", Cvar_VariableString( "mapname" ) ) );
		return;
	}
	// this can happen considerably earlier when lots of clients play and the map doesn't change
	if ( svs.nextSnapshotEntities >= 0x7FFFFFFE - svs.numSnapshotEntities ) {
		SV_Shutdown( "Restarting server due to numSnapshotEntities wrapping" );
		Cbuf_AddText( va( "map %s\n", Cvar_VariableString( "mapname" ) ) );
		return;
	}

	if( sv.restartTime && sv.time >= sv.restartTime ) {
		sv.restartTime = 0;
		Cbuf_AddText( "map_restart 0\n" );
		return;
	}

	// update infostrings if anything has been changed
	if ( cvar_modifiedFlags & CVAR_SERVERINFO ) {
		SV_SetConfigstring( CS_SERVERINFO, Cvar_InfoString( CVAR_SERVERINFO ) );
		cvar_modifiedFlags &= ~CVAR_SERVERINFO;
	}
	if ( cvar_modifiedFlags & CVAR_SYSTEMINFO ) {
		SV_SetConfigstring( CS_SYSTEMINFO, Cvar_InfoString_Big( CVAR_SYSTEMINFO ) );
		cvar_modifiedFlags &= ~CVAR_SYSTEMINFO;
	}

	if ( com_speeds->integer ) {
		startTime = Sys_Milliseconds ();
	} else {
		startTime = 0;	// quite a compiler warning
	}

	// update ping based on the all received frames
	SV_CalcPings();

	if (com_dedicated->integer) SV_BotFrame (sv.time);

	// run the game simulation in chunks
	while ( sv.timeResidual >= frameMsec ) {
		sv.timeResidual -= frameMsec;
		svs.time += frameMsec;
		sv.time += frameMsec;

		// let everything in the world think and move
		VM_Call (gvm, GAME_RUN_FRAME, sv.time);
	}

	if ( com_speeds->integer ) {
		time_game = Sys_Milliseconds () - startTime;
	}

	// check timeouts
	SV_CheckTimeouts();
	
	// check user info buffer thingy
	SV_CheckClientUserinfoTimer();

	// send messages back to the clients
	SV_SendClientMessages();

	// send a heartbeat to the master if needed
	SV_MasterHeartbeat();
}
Example #28
0
/*
================
VID_MenuKey
================
*/
static void VID_MenuKey (int key)
{
	switch (key)
	{
	case K_ESCAPE:
		VID_SyncCvars (); //sync cvars before leaving menu. FIXME: there are other ways to leave menu
		S_LocalSound ("misc/menu1.wav");
		M_Menu_Options_f ();
		break;

	case K_UPARROW:
		S_LocalSound ("misc/menu1.wav");
		video_options_cursor--;
		if (video_options_cursor < 0)
			video_options_cursor = VIDEO_OPTIONS_ITEMS-1;
		break;

	case K_DOWNARROW:
		S_LocalSound ("misc/menu1.wav");
		video_options_cursor++;
		if (video_options_cursor >= VIDEO_OPTIONS_ITEMS)
			video_options_cursor = 0;
		break;

	case K_LEFTARROW:
		S_LocalSound ("misc/menu3.wav");
		switch (video_options_cursor)
		{
		case VID_OPT_MODE:
			VID_Menu_ChooseNextMode (1);
			break;
		case VID_OPT_BPP:
			VID_Menu_ChooseNextBpp (1);
			break;
		case VID_OPT_FULLSCREEN:
			Cbuf_AddText ("toggle vid_fullscreen\n");
			break;
		case VID_OPT_VSYNC:
			Cbuf_AddText ("toggle vid_vsync\n"); // kristian
			break;
		default:
			break;
		}
		break;

	case K_RIGHTARROW:
		S_LocalSound ("misc/menu3.wav");
		switch (video_options_cursor)
		{
		case VID_OPT_MODE:
			VID_Menu_ChooseNextMode (-1);
			break;
		case VID_OPT_BPP:
			VID_Menu_ChooseNextBpp (-1);
			break;
		case VID_OPT_FULLSCREEN:
			Cbuf_AddText ("toggle vid_fullscreen\n");
			break;
		case VID_OPT_VSYNC:
			Cbuf_AddText ("toggle vid_vsync\n");
			break;
		default:
			break;
		}
		break;

	case K_ENTER:
		m_entersound = true;
		switch (video_options_cursor)
		{
		case VID_OPT_MODE:
			VID_Menu_ChooseNextMode (1);
			break;
		case VID_OPT_BPP:
			VID_Menu_ChooseNextBpp (1);
			break;
		case VID_OPT_FULLSCREEN:
			Cbuf_AddText ("toggle vid_fullscreen\n");
			break;
		case VID_OPT_VSYNC:
			Cbuf_AddText ("toggle vid_vsync\n");
			break;
		case VID_OPT_TEST:
			Cbuf_AddText ("vid_test\n");
			break;
		case VID_OPT_APPLY:
			Cbuf_AddText ("vid_restart\n");
			key_dest = key_game;
			m_state = m_none;
			IN_Activate();
			break;
		default:
			break;
		}
		break;

	default:
		break;
	}
}
Example #29
0
// auto-tracking is a feature implemented in three different places in QW
// - server side, client side (for a demo), recorded in a demo
// this command will choose which feature is available
// at the moment and will toggle it (on/off)
void CL_Autotrack_f(void)
{
	cmd_alias_t* at;
	extern cvar_t mvd_autotrack;
	extern cvar_t demo_autotrack;
	qbool mvda = mvd_autotrack.integer ? true : false;
	qbool demoa = demo_autotrack.integer ? true : false;

	if (cls.demoplayback) {
		if (cls.mvdplayback) {
			if (cl_hightrack.integer) {
				Cvar_SetValue(&cl_hightrack, 0);
			}

			if (!mvda && !demoa) {
				// we will turn on both features but if demo_autotrack info is found
				// it will turn off mvd_autotrack
				Cvar_SetValue(&mvd_autotrack, 4);
				Cvar_SetValue(&demo_autotrack, 1);
				Com_Printf("MVD Autotracking on\n");
			} else if (mvda && !demoa) {
				Com_Printf("MVD Autotracking off\n");
				Cvar_SetValue(&mvd_autotrack, 0);
			} else if (!mvda && demoa) {
				Com_Printf("Demo Autotracking off\n");
				Cvar_SetValue(&demo_autotrack, 0);
			} else { // mvda && demoa
				Com_Printf("Autotracking off\n");
				Cvar_SetValue(&mvd_autotrack, 0);
				Cvar_SetValue(&demo_autotrack, 0);
			}
		} else {
			Com_Printf("Only one point of view is recorded in this demo\n");
		}
	}
	else { // not playing a demo
		if (cl.spectator) {
			if ((at = Cmd_FindAlias("autotrack")) != NULL) {
				// not very "clean" way to execute an alias, but sufficient for this purpose
				Cbuf_AddText(va("%s\n", at->value)); // note KTX this is cmd 154, but we want to be compatible with other mods/versions

				/* Bugfix: When setting autotrack ON, make sure to set cl_hightrack 0.
				If player hits autotrack bind before KTX had a chance to stuff the impulse, then ezQuake would set cl_hightrack to 1.
				Then, if player hits autotrack again after KTX has finished stuffing, both autotrack and cl_hightrack would be on, creating chaos.
				
				HOWEVER, this creates a different, albeit less frustrating bug: if you have autotrack on first, then set cl_hightrack 1, then turn off autotrack, cl_hightrack gets set to 0.
				Currently there is no better way to solve this as autotrack is simply a command sent to the server.*/				
				if (cl_hightrack.integer) {
					Cvar_SetValue(&cl_hightrack, 0);
					Com_Printf("Hightrack off\n");
				}		

			}
			else {
				if (!cl_hightrack.integer) {
					Com_Printf("Autotrack not supported here, tracking top fragger (Hightrack on)\n");
					Cvar_SetValue(&cl_hightrack, 1);
				}
				else {
					Com_Printf("Hightrack off\n");
					Cvar_SetValue(&cl_hightrack, 0);
				}
			}
		}
	}
}
Example #30
0
/*
=====================
CL_ParseServerMessage
=====================
*/
void
CL_ParseServerMessage(void)
{
    unsigned int bits;
    int i, cmd, prevcmd;
    int playernum, version, stylenum, signon, statnum;
    int stopsound, entitynum, channel;
    byte colors;
    player_info_t *player;
    lightstyle_t *style;
    const char *stylemap, *name;

//
// if recording demos, copy the message out
//
    if (cl_shownet.value == 1)
	Con_Printf("%i ", net_message.cursize);
    else if (cl_shownet.value == 2)
	Con_Printf("------------------\n");

    cl.onground = false;	// unless the server says otherwise
//
// parse the message
//
    prevcmd = svc_bad;
    MSG_BeginReading();

    while (1) {
	if (msg_badread)
	    Host_Error("%s: Bad server message", __func__);

	cmd = MSG_ReadByte();

	if (cmd == -1) {
	    SHOWNET("END OF MESSAGE");
	    return;		// end of message
	}
	// if the high bit of the command byte is set, it is a fast update
	if (cmd & 128) {
	    SHOWNET("fast update");
	    CL_ParseUpdate(cmd & 127);
	    continue;
	}

	SHOWNET(svc_strings[cmd]);

	// other commands
	switch (cmd) {
	case svc_nop:
	    break;

	case svc_time:
	    cl.mtime[1] = cl.mtime[0];
	    cl.mtime[0] = MSG_ReadFloat();
	    break;

	case svc_clientdata:
	    CL_ParseClientdata();
	    break;

	case svc_version:
	    version = MSG_ReadLong();
	    if (!Protocol_Known(version))
		Host_Error("%s: Server returned unknown protocol version %i",
			   __func__, version);
	    cl.protocol = version;
	    break;

	case svc_disconnect:
	    Host_EndGame("Server disconnected\n");

	case svc_print:
	    Con_Printf("%s", MSG_ReadString());
	    break;

	case svc_centerprint:
	    SCR_CenterPrint(MSG_ReadString());
	    break;

	case svc_stufftext:
	    Cbuf_AddText("%s", MSG_ReadString());
	    break;

	case svc_damage:
	    V_ParseDamage();
	    break;

	case svc_serverinfo:
	    CL_ParseServerInfo();
	    vid.recalc_refdef = true;	// leave intermission full screen
	    break;

	case svc_setangle:
	    for (i = 0; i < 3; i++)
		cl.viewangles[i] = MSG_ReadAngle();
	    break;

	case svc_setview:
	    cl.viewentity = MSG_ReadShort();
	    break;

	case svc_lightstyle:
	    stylenum = MSG_ReadByte();
	    if (stylenum >= MAX_LIGHTSTYLES)
		Sys_Error("svc_lightstyle > MAX_LIGHTSTYLES");
	    stylemap = MSG_ReadString();
	    style = cl_lightstyle + stylenum;
	    snprintf(style->map, MAX_STYLESTRING, "%s", stylemap);
	    style->length = strlen(style->map);
	    break;

	case svc_sound:
	    CL_ParseStartSoundPacket();
	    break;

	case svc_stopsound:
	    stopsound = MSG_ReadShort(); /* 3-bit channel encoded in lsb */
	    entitynum = stopsound >> 3;
	    channel = stopsound & 7;
	    S_StopSound(entitynum, channel);
	    break;

	case svc_updatename:
	    Sbar_Changed();
	    playernum = MSG_ReadByte();
	    if (playernum >= cl.maxclients)
		Host_Error("%s: svc_updatename > MAX_SCOREBOARD", __func__);
	    name = MSG_ReadString();
	    player = cl.players + playernum;
	    snprintf(player->name, MAX_SCOREBOARDNAME, "%s", name);
	    break;

	case svc_updatefrags:
	    Sbar_Changed();
	    playernum = MSG_ReadByte();
	    if (playernum >= cl.maxclients)
		Host_Error("%s: svc_updatefrags > MAX_SCOREBOARD", __func__);
	    player = cl.players + playernum;
	    player->frags = MSG_ReadShort();
	    break;

	case svc_updatecolors:
	    Sbar_Changed();
	    playernum = MSG_ReadByte();
	    if (playernum >= cl.maxclients)
		Host_Error("%s: svc_updatecolors > MAX_SCOREBOARD", __func__);
	    colors = MSG_ReadByte();
	    player = cl.players + playernum;
	    player->topcolor = (colors & 0xf0) >> 4;
	    player->bottomcolor = colors & 0x0f;
	    /* FIXME - is this the right check for current player? */
	    if (playernum == cl.viewentity)
		cl_color.value = colors;
	    CL_NewTranslation(playernum);
	    break;

	case svc_particle:
	    R_ParseParticleEffect();
	    break;

	case svc_spawnbaseline:
	    entitynum = MSG_ReadShort();
	    // must use CL_EntityNum() to force cl.num_entities up
	    CL_ParseBaseline(CL_EntityNum(entitynum), 0);
	    break;

	case svc_fitz_spawnbaseline2:
	    /* FIXME - check here that protocol is FITZ? => Host_Error() */
	    entitynum = MSG_ReadShort();
	    bits = MSG_ReadByte();
	    // must use CL_EntityNum() to force cl.num_entities up
	    CL_ParseBaseline(CL_EntityNum(entitynum), bits);
	    break;

	case svc_spawnstatic:
	    CL_ParseStatic(0);
	    break;

	case svc_fitz_spawnstatic2:
	    /* FIXME - check here that protocol is FITZ? => Host_Error() */
	    bits = MSG_ReadByte();
	    CL_ParseStatic(bits);
	    break;

	case svc_temp_entity:
	    CL_ParseTEnt();
	    break;

	case svc_setpause:
	    cl.paused = MSG_ReadByte();
	    if (cl.paused)
		CDAudio_Pause();
	    else
		CDAudio_Resume();
	    break;

	case svc_signonnum:
	    signon = MSG_ReadByte();
	    if (signon <= cls.signon)
		Host_Error("Received signon %d when at %d", signon, cls.signon);
	    cls.signon = signon;
	    CL_SignonReply();
	    break;

	case svc_killedmonster:
	    cl.stats[STAT_MONSTERS]++;
	    break;

	case svc_foundsecret:
	    cl.stats[STAT_SECRETS]++;
	    break;

	case svc_updatestat:
	    statnum = MSG_ReadByte();
	    if (statnum < 0 || statnum >= MAX_CL_STATS)
		Sys_Error("svc_updatestat: %d is invalid", statnum);
	    cl.stats[statnum] = MSG_ReadLong();
	    break;

	case svc_spawnstaticsound:
	    CL_ParseStaticSound();
	    break;

	case svc_fitz_spawnstaticsound2:
	    /* FIXME - check here that protocol is FITZ? => Host_Error() */
	    CL_ParseFitzStaticSound2();
	    break;

	case svc_cdtrack:
	    cl.cdtrack = MSG_ReadByte();
	    cl.looptrack = MSG_ReadByte();
	    if ((cls.demoplayback || cls.demorecording)
		&& (cls.forcetrack != -1))
		CDAudio_Play((byte)cls.forcetrack, true);
	    else
		CDAudio_Play((byte)cl.cdtrack, true);
	    break;

	case svc_intermission:
	    cl.intermission = 1;
	    cl.completed_time = cl.time;
	    vid.recalc_refdef = true;	// go to full screen
	    break;

	case svc_finale:
	    cl.intermission = 2;
	    cl.completed_time = cl.time;
	    vid.recalc_refdef = true;	// go to full screen
	    SCR_CenterPrint(MSG_ReadString());
	    break;

	case svc_cutscene:
	    cl.intermission = 3;
	    cl.completed_time = cl.time;
	    vid.recalc_refdef = true;	// go to full screen
	    SCR_CenterPrint(MSG_ReadString());
	    break;

	case svc_sellscreen:
	    Cmd_ExecuteString("help", src_command);
	    break;

	/* Various FITZ protocol messages - FIXME - !protocol => Host_Error */
	case svc_fitz_skybox:
	    MSG_ReadString(); // FIXME - TODO
	    break;

	case svc_fitz_bf:
	    Cmd_ExecuteString("bf", src_command);
	    break;

	case svc_fitz_fog:
	    /* FIXME - TODO */
	    MSG_ReadByte(); // density
	    MSG_ReadByte(); // red
	    MSG_ReadByte(); // green
	    MSG_ReadByte(); // blue
	    MSG_ReadShort(); // time
	    break;

	default:
	    Host_Error("%s: Illegible server message. Previous was %s",
		       __func__, svc_strings[prevcmd]);
	}
	prevcmd = cmd;
    }
}