Esempio n. 1
0
//
// First function called upon actor spawn.
//
void ASiegeNativeActor::InitExecution()
{
	guard(ASiegeNativeActor::InitExecution);

	AActor::InitExecution(); //Validate that actor has been properly spawned in a level
	
	if ( Level->bBegunPlay )
	{
		debugf( NAME_SiegeNative, TEXT("[ERROR] This actor will only apply the hook if spawned via ServerActors!!!"));
		return;
	}
	
	if ( Level->Game && ((Level->NetMode == NM_DedicatedServer) || (Level->NetMode == NM_ListenServer)) )
	{
		RegisterNames();

		debugf( NAME_SiegeNative, TEXT("Level validated, searching for Siege gametype...") );
		for( SiegeClass=Level->Game->GetClass() ; SiegeClass; SiegeClass=SiegeClass->GetSuperClass() ) //Level.Game.IsA('SiegeGI')
			if( appStricmp(SiegeClass->GetName(), TEXT("SiegeGI")) == 0 )
				break;
		if ( SiegeClass )
		{
			debugf( NAME_SiegeNative, TEXT("Siege gametype found: %s, prefetching and validating assets..."), Level->Game->GetClass()->GetFullName() );

			//Let main SiegeIV hold a reference to our class to prevent elimination via garbage collector
			{for( TFieldIterator<UObjectProperty> It(SiegeClass); It && It->GetOwnerClass()==SiegeClass; ++It )
				if ( appStricmp( It->GetName(), TEXT("GCBind")) == 0 )
				{
					//Register in both gameinfo and defaults (SiegeGI.GCBind = class'SiegeNativeActor';)
					*((UObject**) (((DWORD)Level->Game) + It->Offset)) = GetClass();
					*((UObject**) (((DWORD)Level->Game->GetClass()->GetDefaultObject()) + It->Offset)) = GetClass();
					break;
				}
			}
			
			//Get some important offsets
			ActorChannelsOffset = UNetConnection::StaticClass()->GetPropertiesSize() - 16068; //Ends up being 20 in v440/v451
			SGI_Cores_Offset = FindStrictScriptVariable( SiegeClass, TEXT("Cores"))->Offset;


			//Setup individual classes
			UPackage* SiegePackage = (UPackage*) SiegeClass->GetOuter();
			Setup_sgPRI				( SiegePackage, GetLevel());
			Setup_sgCategoryInfo	( SiegePackage, GetLevel());
			Setup_sgBuilding		( SiegePackage, GetLevel());
			Setup_sgProtector		( SiegePackage, GetLevel());
			Setup_sgBaseBuildRule	( SiegePackage, GetLevel());
			Setup_sgBuildRuleCount	( SiegePackage, GetLevel());
			Setup_sgPlayerData		( SiegePackage, GetLevel());
			Setup_sgTranslocator	( SiegePackage, GetLevel());
		}
	}

	unguardobj;
}
/**
 * Looks at the parameters and displays help based upon those parameters
 *
 * @param CmdLine the string containing the parameters for the commandlet
 */
INT UHelpCommandlet::Main(const FString& CmdLine)
{
	TArray<FString> Params;
	TArray<FString> Ignored;
	// Parse the command line into an array of strings
	ParseCommandLine(*CmdLine,Params,Ignored);
	// Validate the number of params passed in
	if (Params.Num() >= 1)
	{
		// Load everything up so we can find both native and script classes
		LoadAllClasses();
		warnf(TEXT(""));
		// Check for either "list" or "commandletname"
		if (Params.Num() == 1)
		{
			// Check for listing all commandlets
			if (appStricmp(TEXT("list"),*Params(0)) == 0)
			{
				ListAllCommandlets();
			}
			else
			{
				// Try to load the commandlet so we can get the help info
				UClass* TheClass = LoadCommandlet(*Params(0));
				if (TheClass != NULL)
				{
					DumpCommandletInfo(TheClass->GetDefaultObject<UCommandlet>());
				}
			}
		}
		// Must be the webhelp option
		else
		{
			// Try to load the commandlet so we can get the URL info
			UClass* TheClass = LoadCommandlet(*Params(1));
			if (TheClass != NULL)
			{
				// Get the default object so we can look at its props
				UCommandlet* DefObject = TheClass->GetDefaultObject<UCommandlet>();
				if (DefObject->HelpWebLink.Len() > 0)
				{
					// Open a browser to the site specified in the default properties
					appLaunchURL(*DefObject->HelpWebLink);
				}
			}
		}
	}
	else
	{
		warnf(TEXT("\r\nUsage:\r\n\r\n%s"),*HelpUsage);
	}
	return 0;
}
void FFileManagerWindows::InternalFindFiles( TArray<FString>& Result, const TCHAR* Filename, UBOOL Files, UBOOL Directories )
{
	HANDLE Handle=NULL;
	WIN32_FIND_DATAW Data;
	Handle=FindFirstFileW(Filename,&Data);
	if( Handle!=INVALID_HANDLE_VALUE )
	{
		do
		{
			if
			(   appStricmp(Data.cFileName,TEXT("."))
			&&  appStricmp(Data.cFileName,TEXT(".."))
			&&  ((Data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)?Directories:Files) )
			{
				new(Result)FString(Data.cFileName);
			}
		}
		while( FindNextFileW(Handle,&Data) );
	}
	if( Handle!=INVALID_HANDLE_VALUE )
	{
		FindClose( Handle );
	}
}