Beispiel #1
0
////////////////////////////////////////////////////////////////////////////////
// Ctor
GaMatchmakingState::GaMatchmakingState()
{
	name( "GaMatchmakingState" );

	SocketFileDescriptor_ = 0;
	ClientID_ = BcErrorCode;
	RemoteHandshakeAddr_ = 0;
	RemoteHandshakePort_ = 0;
	LocalHandshakeAddr_ = 0;
	LocalHandshakePort_ = 0;
	//MappedHandshakeAddr_ = 0;
	//MappedHandshakePort_ = 0;
	LANHandshakeAddr_ = 0;
	LANHandshakePort_ = 0;

	HandshakeState_ = HSS_STUN;

	BcMemZero( &Callbacks_, sizeof( Callbacks_ ) );
	Callbacks_.event_connect = event_connect;
	Callbacks_.event_nick = event_nick;
	Callbacks_.event_nick = event_quit;
	Callbacks_.event_join = event_join;
	Callbacks_.event_part = event_part;
	Callbacks_.event_mode = event_mode;
	Callbacks_.event_umode = event_umode;
	Callbacks_.event_topic = event_topic;
	Callbacks_.event_kick = event_kick;
	Callbacks_.event_channel = event_channel;
	Callbacks_.event_privmsg = event_privmsg;
	Callbacks_.event_notice = event_notice;
	Callbacks_.event_channel_notice = event_channel_notice;
	Callbacks_.event_invite = event_invite;
	Callbacks_.event_ctcp_req = event_ctcp_req;
	Callbacks_.event_ctcp_rep = event_ctcp_rep;
	Callbacks_.event_ctcp_action = event_ctcp_action;
	Callbacks_.event_unknown = event_unknown;
	Callbacks_.event_numeric = event_numeric;
	Callbacks_.event_dcc_chat_req = event_dcc_chat_req;
	Callbacks_.event_dcc_send_req = event_dcc_send_req;

	ConnectTimer_ = 0.0f;
	InviteTimer_ = BcAbs( BcRandom::Global.randReal() ) * 5.0f + 5.0f;
	HandshakeTimer_ = 0.0f;

	pSession_ = NULL;

#if PLATFORM_WINDOWS
	BcRandom::Global = BcRandom( ::GetTickCount() );
#endif
}
Beispiel #2
0
int main(int argc, char** argv)
{
	// Start.
	std::string CommandLine;

	for( int Idx = 0; Idx < argc; ++Idx )
	{
		CommandLine += argv[ Idx ];
		CommandLine += " ";
	}

	GInstance_ = (BcHandle)0;

	// Set command line params.
	SysArgs_ = CommandLine;

	// HACK: Append a space to sys args for find to work.
	SysArgs_ += " ";
	
	// If we have no log, setup a default one.
#if !PSY_PRODUCTION
	if( BcLog::pImpl() == NULL )
	{
		new BcLogImpl();
	}
	// Some default suppression.
	BcLog::pImpl()->setCategorySuppression( "Reflection", BcTrue );

	// Setup basic log Category.
	BcLogScopedCategory LogCategory( "Main" );
#endif

	// Initialise RNG.
#if !PSY_DEBUG
	BcRandom::Global = BcRandom( 1337 ); // TODO LINUX
#endif

	// Additional input devices.
	GInputMindwave_.reset( new OsInputMindwaveLinux() );

	// Create reflection database
	ReManager::Init();

#if PSY_USE_PROFILER
	// new profiler.
	new SysProfilerChromeTracing();
#endif

	// Unit tests prior to full kernel initialisation.
	if( SysArgs_.find( "-unittest " ) != std::string::npos )
	{
		extern void MainUnitTests();
		MainUnitTests();
		return 0;
	}

	// Create kernel.
	new SysKernel( GPsySetupParams.TickRate_ );

	// Register systems for creation.
	SYS_REGISTER( "DsCore", DsCoreImpl );
	SYS_REGISTER( "DsCoreLogging", DsCoreLoggingImpl );
	SYS_REGISTER( "OsCore", OsCoreImplSDL );
	SYS_REGISTER( "FsCore", FsCoreImplLinux );
	SYS_REGISTER( "CsCore", CsCore );
	SYS_REGISTER( "RsCore", RsCoreImpl );
	SYS_REGISTER( "SsCore", SsCoreImplSoLoud );
	SYS_REGISTER( "ScnCore", ScnCore );

	// Main shared.
	MainShared();

	OsCore::pImpl()->subscribe( sysEVT_SYSTEM_POST_OPEN, OnPostOsOpen_CreateClient );
	OsCore::pImpl()->subscribe( sysEVT_SYSTEM_POST_CLOSE, OnPostOsClose_DestroyClient );
	OsCore::pImpl()->subscribe( sysEVT_SYSTEM_PRE_UPDATE, OnPreOsUpdate_PumpMessages );
	ScnCore::pImpl()->subscribe( sysEVT_SYSTEM_POST_OPEN, OnPostOpenScnCore_LaunchGame );

	// Init game.
	PsyGameInit();

	//
	if( ( GPsySetupParams.Flags_ & psySF_MANUAL ) == 0 )
	{
		// Run kernel unthreaded.
		SysKernel::pImpl()->run( BcFalse );
	}

	// Delete kernel.
	delete SysKernel::pImpl();

	// Delete log.
	delete BcLog::pImpl();

	// Done.
	return 0;
}