Example #1
0
void CWorld::Spawn( void )
{
	SetLocalOrigin( vec3_origin );
	SetLocalAngles( vec3_angle );
	// NOTE:  SHOULD NEVER BE ANYTHING OTHER THAN 1!!!
	SetModelIndex( 1 );
	// world model
	SetModelName( AllocPooledString( modelinfo->GetModelName( GetModel() ) ) );
	AddFlag( FL_WORLDBRUSH );

	g_EventQueue.Init();
	Precache( );
	GlobalEntity_Add( "is_console", STRING(gpGlobals->mapname), ( IsConsole() ) ? GLOBAL_ON : GLOBAL_OFF );
	GlobalEntity_Add( "is_pc", STRING(gpGlobals->mapname), ( !IsConsole() ) ? GLOBAL_ON : GLOBAL_OFF );
}
FSReturnCode_t SetSteamInstallPath( char *steamInstallPath, int steamInstallPathLen, CSteamEnvVars &steamEnvVars, bool bErrorsAsWarnings )
{
	if ( IsConsole() )
	{
		// consoles don't use steam
		return FS_MISSING_STEAM_DLL;
	}

	// Start at our bin directory and move up until we find a directory with steam.dll in it.
	char executablePath[MAX_PATH];
	if ( !FileSystem_GetExecutableDir( executablePath, sizeof( executablePath ) )	)
	{
		if ( bErrorsAsWarnings )
		{
			Warning( "SetSteamInstallPath: FileSystem_GetExecutableDir failed.\n" );
			return FS_INVALID_PARAMETERS;
		}
		else
		{
			return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetExecutableDir failed." );
		}
	}

	Q_strncpy( steamInstallPath, executablePath, steamInstallPathLen );
	while ( 1 )
	{
		// Ignore steamapp.cfg here in case they're debugging. We still need to know the real steam path so we can find their username.
		// find 
		if ( DoesFileExistIn( steamInstallPath, "steam.dll" ) && !DoesFileExistIn( steamInstallPath, "steamapp.cfg" ) )
			break;
	
		if ( !Q_StripLastDir( steamInstallPath, steamInstallPathLen ) )
		{
			if ( bErrorsAsWarnings )
			{
				Warning( "Can't find steam.dll relative to executable path: %s.\n", executablePath );
				return FS_MISSING_STEAM_DLL;
			}
			else
			{
				return SetupFileSystemError( false, FS_MISSING_STEAM_DLL, "Can't find steam.dll relative to executable path: %s.", executablePath );
			}
		}			
	}

	// Also, add the install path to their PATH environment variable, so filesystem_steam.dll can get to steam.dll.
	char szPath[ 8192 ];
	steamEnvVars.m_Path.GetValue( szPath, sizeof( szPath ) );
	if ( !DoesPathExistAlready( szPath, steamInstallPath ) )
	{
		steamEnvVars.m_Path.SetValue( "%s;%s", szPath, steamInstallPath );
	}
	return FS_OK;
}
Example #3
0
void set_prompt(dbref console)
{
  hship *ship;
  hconsole *con;
  char *prompt;
  dbref player;

  if (IsShip(console))
  {
    con = NULL;
    ship = find_ship_by_nav(console);
    prompt = &(ship->prompt);
  }
  else if (IsConsole(console))
  {
    con = find_console(console);
    if (!con)
    {
      notify_console(console, "Unable to find console! Contact your local flight mechanic immediately!");
      return;
    }
    
    ship = find_ship(console);
    prompt = &(con->prompt);
  }
  else
  {
    ship = NULL;
    con = NULL;
  }
  
  if (!ship || !prompt)
  {
    notify_console(console, "Unable to find ship! Contact your local flight mechanic immediately!");
    return;
  }

  player = get_user(console);
  if (!IsPlayer(player))
  {
    notify_console(console, "Only players may receive prompts.");
    return;
  }

  *prompt = HasFlag(atr_parse_integer(player, "HSPROMPT_FREQUENCY", 1), HS_PROMPT_FREQUENCY);
  FlagOn(*prompt, atr_parse_flags(player, hs_prompt_flags, "HSPROMPT_FLAGS"));
  
  hs_std_notice(console, "Prompt flags reloaded.");
  return;
}
Example #4
0
/* unman console command */
void unman_console(dbref player)
{
  dbref curman, console;
  hship *ship;
  hconsole *con;

  console = atr_parse_dbref(player, "MANNING");
  if (!IsConsole(console) && !IsShip(console))
  {
    notify(player, "You are not manning a console.");
    return;
  }
  
  curman = get_user(console);
  
  if (curman != player)
  {
    notify(player, "You aren't manning that.");
    return;
  }
  
  ship = find_ship_by_nav(console);
  if (!ship)
  {
    con = find_console(console);
    if (!con)
    {
      notify(player, "That console has not been activated.");
      return;
    }
    
    load_weapon(console, &(con->primary), HS_PRIMARY);
    load_weapon(console, &(con->secondary), HS_SECONDARY);
  } else {
    load_weapon(console, &(ship->primary), HS_PRIMARY);
    load_weapon(console, &(ship->secondary), HS_SECONDARY);
  }

  set_user(console, NOTHING);
  notify(player, tprintf("You unman the %s.", Name(console)));
  notify_except(console, Location(console), player,
             tprintf("%s unmans the %s.", Name(player), Name(console)), 0);

  execute_trigger(console, "AUNMAN", ship);
}
//-----------------------------------------------------------------------------
// 
//-----------------------------------------------------------------------------
void CBindPanel::DrawBindingName()
{
	int iconWide = m_iIconTall * m_fWidthScale * m_fScale;

	int x = (iconWide>>1);
	int y = ( m_iIconTall * m_fScale ) * 0.5f;

	if ( !m_bController && !IsConsole() )
	{
		// Draw the caption
		vgui::surface()->DrawSetTextFont( m_hKeysFont );
		int fontTall = vgui::surface()->GetFontTall( m_hKeysFont );

		char szBinding[ 256 ];
		Q_strcpy( szBinding, m_szKey );

		if ( Q_strcmp( szBinding, "SEMICOLON" ) == 0 )
		{
			Q_strcpy( szBinding, ";" );
		}
		else if ( Q_strlen( szBinding ) == 1 && szBinding[ 0 ] >= 'a' && szBinding[ 0 ] <= 'z' )
		{
			// Make single letters uppercase
			szBinding[ 0 ] += ( 'A' - 'a' );
		}

		wchar wszCaption[ 64 ];
		g_pVGuiLocalize->ConstructString( wszCaption, sizeof(wchar)*64, szBinding, NULL );

		int iWidth = GetScreenWidthForCaption( wszCaption, m_hKeysFont );

		// Draw black text
		vgui::surface()->DrawSetTextColor( 0,0,0, 255 );
		vgui::surface()->DrawSetTextPos( x - (iWidth>>1) - 1, y - (fontTall >>1) - 1 );
		vgui::surface()->DrawUnicodeString( wszCaption );
	}
FSReturnCode_t SetSteamInstallPath( char *steamInstallPath, int steamInstallPathLen, CSteamEnvVars &steamEnvVars, bool bErrorsAsWarnings )
{
	if ( IsConsole() )
	{
		// consoles don't use steam
		return FS_MISSING_STEAM_DLL;
	}

	if ( IsPosix() )
		return FS_OK; // under posix the content does not live with steam.dll up the path, rely on the environment already being set by steam
	
	// Start at our bin directory and move up until we find a directory with steam.dll in it.
	char executablePath[MAX_PATH];
	if ( !FileSystem_GetExecutableDir( executablePath, sizeof( executablePath ) )	)
	{
		if ( bErrorsAsWarnings )
		{
			Warning( "SetSteamInstallPath: FileSystem_GetExecutableDir failed.\n" );
			return FS_INVALID_PARAMETERS;
		}
		else
		{
			return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetExecutableDir failed." );
		}
	}

	Q_strncpy( steamInstallPath, executablePath, steamInstallPathLen );
#ifdef WIN32
	const char *pchSteamDLL = "steam.dll";
#elif defined(OSX)
	// under osx the bin lives in the bin/ folder, so step back one
	Q_StripLastDir( steamInstallPath, steamInstallPathLen );
	const char *pchSteamDLL = "libsteam.dylib";	
#elif defined(LINUX)
	// under linux the bin lives in the bin/ folder, so step back one
	Q_StripLastDir( steamInstallPath, steamInstallPathLen );
	const char *pchSteamDLL = "libsteam.so";
#else
#error
#endif
	while ( 1 )
	{
		// Ignore steamapp.cfg here in case they're debugging. We still need to know the real steam path so we can find their username.
		// find 
		if ( DoesFileExistIn( steamInstallPath, pchSteamDLL ) && !DoesFileExistIn( steamInstallPath, "steamapp.cfg" ) )
			break;
	
		if ( !Q_StripLastDir( steamInstallPath, steamInstallPathLen ) )
		{
			if ( bErrorsAsWarnings )
			{
				Warning( "Can't find %s relative to executable path: %s.\n", pchSteamDLL, executablePath );
				return FS_MISSING_STEAM_DLL;
			}
			else
			{
				return SetupFileSystemError( false, FS_MISSING_STEAM_DLL, "Can't find %s relative to executable path: %s.", pchSteamDLL, executablePath );
			}
		}			
	}

	// Also, add the install path to their PATH environment variable, so filesystem_steam.dll can get to steam.dll.
	char szPath[ 8192 ];
	steamEnvVars.m_Path.GetValue( szPath, sizeof( szPath ) );
	if ( !DoesPathExistAlready( szPath, steamInstallPath ) )
	{
#ifdef WIN32
#define PATH_SEP ";"
#else
#define PATH_SEP ":"
#endif	
		steamEnvVars.m_Path.SetValue( "%s%s%s", szPath, PATH_SEP, steamInstallPath );
	}
	return FS_OK;
}
Example #7
0
void hs_move(dbref executor, char *arg_left, char *arg_right)
{
  huniverse *uid;
  hcelestial *cel;
  hship *dship;
  hship *ship;
  int i, dx, dy, dz;
  dbref obj;
  dbref udb, ndb;
  char *r, *s;
  int len;
  dbref bot, top;

  obj = match_result(executor, arg_left, TYPE_THING, MAT_EVERYTHING);
  if (!IsShip(obj) && !IsCelestial(obj) && !IsConsole(obj))
  {
    notify(executor, "HSPACE: Unable to move that object.");
    return;
  }
  
  s = arg_right;
  r = split_token(&s, '/');
  if (!r || !*r)
  {
    notify(executor, "HSPACE: No destination specified.");
    return;
  }
  
  len = strlen(r);
  
  ndb = match_result(executor, r, TYPE_THING, MAT_EVERYTHING);
  
  if (!RealGoodObject(ndb))
  {
    ndb = parse_dbref(r);
  }
  
  if (!RealGoodObject(ndb))
  {
    bot = 0;
    top = db_top;
  } else {
    bot = ndb;
    top = bot + 1;
  }
  
  uid = NULL;
  /* cycle through the db and try to match a space object */
  for (udb = bot; udb < top; udb++)
  {
    if (strncasecmp(Name(udb), r, len) && udb != ndb)
      continue;
    
    if (IsUniverse(udb))
    {
      uid = find_universe(udb);
    }
    else if (IsCelestial(udb))
    {
      cel = find_celestial(udb);
      if (cel)
      {
        uid = cel->uid;
        dx = cel->x;
        dy = cel->y;
        dz = cel->z;
      }
    }
    else if (IsShip(udb) || IsShipObj(udb))
    {
      dship = find_ship(udb);
      if (dship)
      {
        dx = dship->x;
        dy = dship->y;
        dz = dship->z;
        uid = dship->uid;
      }
    }
    else
    {
      /* false positive */
      continue;
    }
  
    break;
  }
  
  if (!uid)
  {
    notify(executor, "HSPACE: Unable to locate destination.");
    return;
  }
  
  if (s)
  {
    r = split_token(&s, ' ');
    if (r)
    {
      dx = parse_integer(r);
    
      r = split_token(&s, ' ');
      if (!r || !*r)
      {
        dy = 0;
        dz = 0;
      } else {
        dy = parse_integer(r);
    
        r = split_token(&s, ' ');
        if (!r || !*r)
          dz = 0;
        else
          dz = parse_integer(r);
      }
    } else {
      /* all blanks */
      dx = 0;
      dy = 0;
      dz = 0;
    }
  }
  
  if (IsShip(obj) || IsConsole(obj))
  {
    ship = find_ship(obj);
    move_ship(ship, uid, dx, dy, dz);
  }
  else if (IsCelestial(obj))
  {
    cel = find_celestial(obj);
    move_celestial(cel, uid, dx, dy, dz);
  }
  
  notify(executor, "HSPACE: Moved.");
}
Example #8
0
/* man console command */
void man_console(dbref player, char *where)
{
  hship *ship;
  hconsole *con;
  dbref   console;
  dbref   manner, manning;
  hweapon *pri, *sec;
  char *prompt;
  int ptype, stype, type;

  if (Typeof(player) != TYPE_PLAYER && hs_options.forbid_puppets)
  {
    notify(player, "Only players may man this console.");
    return;
  }
  
  console = match_result(player, where, TYPE_THING, MAT_NEAR_THINGS);

  switch (console)
  {
  case NOTHING:
    notify(player, "I don't see that here.");
    return;

  case AMBIGUOUS:
    notify(player, "I don't know which you mean!");
    return;
  }

  /* don't need to do this now because we want to allow you
     to reman consoles easily for equipment changes */

  /*manner = get_user(console);
  if (manner == player)
  {
    notify(player, "You are already manning that console.");
    return;
  }*/

  if (!IsConsole(console) && !IsShip(console))
  {
    notify(player, "You cannot man that.");
    return;
  }
  
  if (IsConsole(console))
  {
    con = find_console(console);
    if (!con)
    {
      notify(player, "That console has not been activated.");
      return;
    }
    
    pri = &(con->primary);
    sec = &(con->secondary);
    prompt = &(con->prompt);
    
    ship = find_ship(console);
  }
  else if (IsShip(console))
  {
    con = NULL;
    ship = find_ship_by_nav(console);
    
    if (ship)
    {
      pri = &(ship->primary);
      sec = &(ship->secondary);
      prompt = &(ship->prompt);
    }
    
  } else{
    ship = NULL;
  }
  
  if (!ship)
  {
    notify(player, "Invalid ship object. Please contact your flight mechanic immediately!");
    return;
  }
    

  if (InCombat(ship))
  {
    notify(player, "Can't reload weapons in combat!");
    stype = sec->type;
    ptype = pri->type;
  } else {
    ptype = load_weapon(player, pri, HS_PRIMARY);
    stype = load_weapon(player, sec, HS_SECONDARY);
  }
  
  type = HasFlag(ptype | stype, HS_ANY_WEAPON);

  if (con)
  {
    /* this is an auxiliary console */
    /* no missiles on the aux consoles */
    if (HasFlag(type, HS_MISSILE))
    {
      clear_weapon(pri);
      clear_weapon(sec);
      
      notify(player, "You may not man an auxiliary console with missiles equipped.");
      return;
    }
    
    if (HasFlag(type, HS_WIRETAP))
      con->type = HS_OPS;
    else if (HasFlag(type, HS_CAPACITOR))
      con->type = HS_ENG;
    else if (HasFlag(type, HS_CANNON | HS_EMITTER | HS_WEAPON))
      con->type = HS_GUN;
    else
      con->type = HS_CIV;
    
  } else {
    /* this is a nav console */
    /* no cans, caps or taps */
    
    if (HasFlag(type, HS_CANNON))
    {
      clear_weapon(pri);
      clear_weapon(sec);
      
      notify(player, "You may not man a navigation console with a cannon equipped.");
      return;
    }
  }
  
  /* the equipment slots check out, and the console
     has been set to the appropriate type, if needed */

  if (prompt)
  {
    *prompt = HasFlag(atr_parse_integer(player, "HSPROMPT_FREQUENCY", 1), HS_PROMPT_FREQUENCY);
    FlagOn(*prompt, atr_parse_flags(player, hs_prompt_flags, "HSPROMPT_FLAGS"));
  }
  
  manning = get_console(player);
  if (manning != NOTHING)
  {
    manner = get_user(manning);
    if (manner == player)
    {
      con = find_console(manning);
      if (con)
      {
        load_weapon(manning, &(con->primary), HS_PRIMARY);
        load_weapon(manning, &(con->secondary), HS_SECONDARY);
      }
      
      set_user(manning, NOTHING);
      
      notify(player, tprintf("You unman the %s.", Name(manning)));
      notify_except(manning, Location(manning), player,
              tprintf("%s unmans the %s.", Name(player), Name(manning)), 0);
    }
  }
  
  /* set the HSPACE attribute in case something was fishy */
  if (!IsSim(ship->objnum))
  {
    atr_add(player, "HSPACE", unparse_dbref(ship->objnum), hs_options.space_wiz, 0);
  }

  set_user(console, player);

  execute_trigger(console, "AMAN", ship);

  if (con)
  {
    notify(player, tprintf("You man the %s (%s%s%s).", Name(console),
          ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL));
    notify_except(console, Location(console), player,
    	  tprintf("%s mans the %s (%s%s%s).", Name(player), Name(console),
    	  ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL), 0);
  } else {
    notify(player, tprintf("You man the %s.", Name(console)));
    notify_except(console, Location(console), player,
    	  tprintf("%s mans the %s.", Name(player), Name(console)), 0);
  }
}
//=========================================================
//=========================================================
void C_GameInstructor::Update( float frametime )
{
	VPROF_BUDGET( "C_GameInstructor::Update", "GameInstructor" );
 
	UpdateHiddenByOtherElements();
 
	// Instructor desactivado.
	if ( !gameinstructor_enable.GetBool() || m_bNoDraw || m_bHiddenDueToOtherElements )
		return;
 
	if ( gameinstructor_find_errors.GetBool() )
	{
		FindErrors();
		gameinstructor_find_errors.SetValue(0);
	}
 
	if ( IsConsole() )
	{
		// On X360 we want to save when they're not connected
		// They aren't in game
		if ( !engine->IsInGame() )
			WriteSaveData();
		else
		{
			const char *levelName = engine->GetLevelName();
 
			// The are in game, but it's a background map
			if ( levelName && levelName[0] && engine->IsLevelMainMenuBackground() )
				WriteSaveData();
		}
	}
 
	if ( m_bSpectatedPlayerChanged )
	{
		// Safe spot to clean out stale lessons if spectator changed
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Spectated player changed...\n" );
		}
 
		CloseAllOpenOpportunities();
		m_bSpectatedPlayerChanged = false;
	}
 
	// Loop through all the lesson roots and reset their active status
	for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
	{
		CBaseLesson *pLesson		= m_OpenOpportunities[ i ];
		CBaseLesson *pRootLesson	= pLesson->GetRoot();
 
		if ( pRootLesson->InstanceType() == LESSON_INSTANCE_SINGLE_ACTIVE )
			pRootLesson->SetInstanceActive(false);
	}
 
	int iCurrentPriority = 0;
 
	// Loop through all the open lessons
	for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
	{
		CBaseLesson *pLesson = m_OpenOpportunities[ i ];
 
		// This opportunity has closed
		if ( !pLesson->IsOpenOpportunity() || pLesson->IsTimedOut() )
		{
			CloseOpportunity( pLesson );
			continue;
		}
 
		// Lesson should be displayed, so it can affect priority
		CBaseLesson *pRootLesson	= pLesson->GetRoot();
		bool bShouldDisplay			= pLesson->ShouldDisplay();
		bool bIsLocked				= pLesson->IsLocked();
 
		if ( ( bShouldDisplay || bIsLocked ) && 
			 ( pLesson->GetPriority() >= m_iCurrentPriority || pLesson->NoPriority() || bIsLocked ) && 
			 ( pRootLesson && ( pRootLesson->InstanceType() != LESSON_INSTANCE_SINGLE_ACTIVE || !pRootLesson->IsInstanceActive() ) ) )
		{
			// Lesson is at the highest priority level, isn't violating instance rules, and has met all the prerequisites
			if ( UpdateActiveLesson( pLesson, pRootLesson ) || pRootLesson->IsLearned() )
			{
				// Lesson is active
				if ( pLesson->IsVisible() || pRootLesson->IsLearned() )
				{
					pRootLesson->SetInstanceActive( true );
 
					// This active or learned lesson has the highest priority so far
					if ( iCurrentPriority < pLesson->GetPriority() && !pLesson->NoPriority() )
						iCurrentPriority = pLesson->GetPriority();
				}
			}
			else
			{
				// On second thought, this shouldn't have been displayed
				bShouldDisplay = false;
			}
		}
		else
		{
			// Lesson shouldn't be displayed right now
			UpdateInactiveLesson( pLesson );
		}
	}
 
	// Set the priority for next frame
	if ( gameinstructor_verbose.GetInt() > 1 && m_iCurrentPriority != iCurrentPriority )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Priority changed from " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "%i ", m_iCurrentPriority );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "to " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "%i", iCurrentPriority );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ".\n" );
	}
 
	m_iCurrentPriority = iCurrentPriority;
}
Example #10
0
//-----------------------------------------------------------------
// Purpose: Returns true if there's an active joystick connected.
//-----------------------------------------------------------------
bool CInput::EnableJoystickMode()
{
	return IsConsole() || in_joystick.GetBool();
}