Ejemplo n.º 1
0
void GameLoop()
{
	ProcessAsyncSaveFinish();

	/* autosave game? */
	if (_do_autosave) {
		_do_autosave = false;
		DoAutosave();
		SetWindowDirty(WC_STATUS_BAR, 0);
	}

	/* switch game mode? */
	if (_switch_mode != SM_NONE) {
		SwitchToMode(_switch_mode);
		_switch_mode = SM_NONE;
	}

	IncreaseSpriteLRU();
	InteractiveRandom();

	extern int _caret_timer;
	_caret_timer += 3;
	CursorTick();

#ifdef ENABLE_NETWORK
	/* Check for UDP stuff */
	if (_network_available) NetworkUDPGameLoop();

	if (_networking && !IsGeneratingWorld()) {
		/* Multiplayer */
		NetworkGameLoop();
	} else {
		if (_network_reconnect > 0 && --_network_reconnect == 0) {
			/* This means that we want to reconnect to the last host
			 * We do this here, because it means that the network is really closed */
			NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_SPECTATOR);
		}
		/* Singleplayer */
		StateGameLoop();
	}

	/* Check chat messages roughly once a second. */
	static uint check_message = 0;
	if (++check_message > 1000 / MILLISECONDS_PER_TICK) {
		check_message = 0;
		NetworkChatMessageLoop();
	}
#else
	StateGameLoop();
#endif /* ENABLE_NETWORK */

	if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();

	if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects();

	InputLoop();

	_sound_driver->MainLoop();
	MusicLoop();
}
Ejemplo n.º 2
0
int main()
{
	// Store console handle
	hostConsole = GetStdHandle( STD_OUTPUT_HANDLE );

	// Set output text colour
	SetConsoleTextAttribute( hostConsole, HOST_CONSOLE_TEXT_COLOUR );

	// Initiate injector
	CRemoteLoad hl2Loader( "hl2.exe" );

	// If the bridge is already loaded, unload it
	hl2Loader.Unload( "sourceconsole_bridge.dll" );

	// Load bridge
	if ( hl2Loader.Load( "sourceconsole_bridge.dll" ) )
	{
		printf( "Injected bridge..\n" );

		// Initate host
		if ( InitiateHost() )
		{
			// Listen for input
			InputLoop();
		}

		// Unload bridge
		hl2Loader.Unload( "sourceconsole_bridge.dll" );

		// Shutdown host
		ShutdownHost();
	}
	else
	{
		printf( "Failed to inject bridge\n" );
	}

	printf( "Press any key to exit.." );
	_getch();

	return 0;
}