当前位置: 首页>>代码示例>>C++>>正文


C++ TArray::Push方法代码示例

本文整理汇总了C++中TArray::Push方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::Push方法的具体用法?C++ TArray::Push怎么用?C++ TArray::Push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TArray的用法示例。


在下文中一共展示了TArray::Push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseArgListDef

static void ParseArgListDef(FScanner &sc, PClassActor *cls,
	TArray<PType *> &args, TArray<DWORD> &argflags)
{
	if (!sc.CheckToken(')'))
	{
		while (sc.TokenType != ')')
		{
			int flags = 0;
			PType *type = NULL;
			PClass *restrict = NULL;

			// Retrieve flags before type name
			for (;;)
			{
				if (sc.CheckToken(TK_Coerce) || sc.CheckToken(TK_Native))
				{
				}
				else
				{
					break;
				}
			}
			// Read the variable type
			sc.MustGetAnyToken();
			switch (sc.TokenType)
			{
			case TK_Bool:
				type = TypeBool;
				break;

			case TK_Int:
				type = TypeSInt32;
				break;

			case TK_Float:
				type = TypeFloat64;
				break;

			case TK_Sound:		type = TypeSound;		break;
			case TK_String:		type = TypeString;		break;
			case TK_Name:		type = TypeName;		break;
			case TK_State:		type = TypeState;		break;
			case TK_Color:		type = TypeColor;		break;
			case TK_Class:
				sc.MustGetToken('<');
				sc.MustGetToken(TK_Identifier);	// Get class name
				restrict = PClass::FindClass(sc.String);
				if (restrict == NULL)
				{
					sc.ScriptMessage("Unknown class type %s", sc.String);
					FScriptPosition::ErrorCounter++;
				}
				else
				{
					type = NewClassPointer(restrict);
				}
				sc.MustGetToken('>');
				break;
			case TK_Ellipsis:
				// Making the final type NULL signals a varargs function.
				type = NULL;
				sc.MustGetToken(')');
				sc.UnGet();
				break;
			default:
				sc.ScriptMessage ("Unknown variable type %s", sc.TokenName(sc.TokenType, sc.String).GetChars());
				type = TypeSInt32;
				FScriptPosition::ErrorCounter++;
				break;
			}
			// Read the optional variable name
			if (!sc.CheckToken(',') && !sc.CheckToken(')'))
			{
				sc.MustGetToken(TK_Identifier);
			}
			else
			{
				sc.UnGet();
			}

			if (sc.CheckToken('='))
			{
				flags |= VARF_Optional;
				FxExpression *def = ParseParameter(sc, cls, type, true);
				delete def;
			}

			args.Push(type);
			argflags.Push(flags);
			sc.MustGetAnyToken();
			if (sc.TokenType != ',' && sc.TokenType != ')')
			{
				sc.ScriptError ("Expected ',' or ')' but got %s instead", sc.TokenName(sc.TokenType, sc.String).GetChars());
			}
		}
	}
	sc.MustGetToken(';');
}
开发者ID:StrikerMan780,项目名称:zdoom,代码行数:98,代码来源:thingdef_parse.cpp

示例2: if

FCDODiffControl::FCDODiffControl( 
		const UObject* InOldCDO
		, const UObject* InNewCDO
		, TArray< TSharedPtr<FBlueprintDifferenceTreeEntry> >& OutTreeEntries
		, TArray< TSharedPtr<FBlueprintDifferenceTreeEntry> >& OutRealDifferences
		, FOnCDODiffControlChanged SelectionCallback )
	: OldDetails(InOldCDO, FDetailsDiff::FOnDisplayedPropertiesChanged() )
	, NewDetails(InNewCDO, FDetailsDiff::FOnDisplayedPropertiesChanged() )
{
	// @todo: (doc): rename InDifferences
	TArray< FSingleObjectDiffEntry > DifferingProperties;
	OldDetails.DiffAgainst(NewDetails, DifferingProperties);

	// OrderedProperties will contain differences in the order they are displayed:
	TArray< const FSingleObjectDiffEntry* > OrderedProperties;

	// create differing properties list based on what is displayed by the old properties..
	TArray<FPropertySoftPath> OldProperties = OldDetails.GetDisplayedProperties();
	TArray<FPropertySoftPath> NewProperties = NewDetails.GetDisplayedProperties();

	const auto FindDiffering = [](TArray< FSingleObjectDiffEntry > const& InDifferenceEntries, const FPropertySoftPath& PropertyIdentifer) -> const FSingleObjectDiffEntry*
	{
		for (const auto& Difference : InDifferenceEntries)
		{
			if (Difference.Identifier == PropertyIdentifer)
			{
				return &Difference;
			}
		}
		return nullptr;
	};

	// zip the two sets of properties, zip iterators are not trivial to write in c++,
	// so this procedural stuff will have to do:
	int IterOld = 0;
	int IterNew = 0;
	while (IterOld != OldProperties.Num() || IterNew != NewProperties.Num())
	{
		if (IterOld != OldProperties.Num() && IterNew != NewProperties.Num()
			&& OldProperties[IterOld] == NewProperties[IterNew])
		{
			if (const FSingleObjectDiffEntry* Differing = FindDiffering(DifferingProperties, OldProperties[IterOld]))
			{
				OrderedProperties.Push(Differing);
			}
			++IterOld;
			++IterNew;
		}
		else
		{
			if (IterOld != OldProperties.Num())
			{
				bool bFoundDifference = false;
				if (const FSingleObjectDiffEntry* OldDiffering = FindDiffering(DifferingProperties, OldProperties[IterOld]))
				{
					bFoundDifference = true;
					OrderedProperties.Push(OldDiffering);
					++IterOld;
				}
				else if (IterNew != NewProperties.Num())
				{
					if (const FSingleObjectDiffEntry* NewDiffering = FindDiffering(DifferingProperties, NewProperties[IterNew]))
					{
						bFoundDifference = true;
						OrderedProperties.Push(NewDiffering);
						++IterNew;
					}
				}
				if (!bFoundDifference)
				{
					++IterOld;
					++IterNew;
				}
			}
			else
			{
				check(IterNew != NewProperties.Num());
				if (const FSingleObjectDiffEntry* Differing = FindDiffering(DifferingProperties, NewProperties[IterNew]))
				{
					OrderedProperties.Push(Differing);
				}
				++IterNew;
			}
		}
	}

	const auto CreateCDODifferenceWidget = [](FSingleObjectDiffEntry DiffEntry, FText ObjectName) -> TSharedRef<SWidget>
	{
		return SNew(STextBlock)
			.Text(DiffViewUtils::PropertyDiffMessage(DiffEntry, ObjectName))
			.ColorAndOpacity(DiffViewUtils::Differs());
	};

	const auto FocusDetailsDifferenceEntry = [](FPropertySoftPath Identifier, FCDODiffControl* Control, FOnCDODiffControlChanged InSelectionCallback)
	{
		// This allows the owning control to focus the correct tab (or do whatever else it likes):
		InSelectionCallback.ExecuteIfBound();
		Control->HighlightDifference(Identifier);
	};

//.........这里部分代码省略.........
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:101,代码来源:SBlueprintDiff.cpp

示例3: ZANDRONUM_ParseMasterServerResponse

//*****************************************************************************
//
bool ZANDRONUM_ParseMasterServerResponse( BYTESTREAM_s *pByteStream, TArray<SERVER_s>&aServerInfo, TArray<QUERY_s>&aQueryInfo )
{
	ULONG			i;
	LONG			lCommand;
	SERVER_s	ServerInfo;
	QUERY_s		QueryInfo;
	time_t		tNow;

	lCommand = NETWORK_ReadLong( pByteStream );
	switch ( lCommand )
	{
	case MSC_BEGINSERVERLISTPART:
		const ULONG ulPacketNum = NETWORK_ReadByte( pByteStream );

		if ( ulPacketNum == 0 )
		{
			// Add a new query.
			QueryInfo.qTotal.lNumPlayers = 0;
			QueryInfo.qTotal.lNumServers = 0;
			QueryInfo.qTotal.lNumSpectators = 0;

			for ( unsigned int g = 0; g < NUM_GAMETYPES; g++ )
			{	
				QueryInfo.qByGameMode[g].lNumPlayers = 0;
				QueryInfo.qByGameMode[g].lNumServers = 0;
				QueryInfo.qByGameMode[g].lNumSpectators = 0;
			}

			time( &QueryInfo.tTime );
			aQueryInfo.Push( QueryInfo );

			// Clear out the server list.
			aServerInfo.Clear( );
		}

		time( &tNow );

		while ( true )
		{
			const LONG lCommand = NETWORK_ReadByte( pByteStream );

			switch ( lCommand )
			{
			case MSC_SERVER:
				{
					ServerInfo.ulActiveState = AS_WAITINGFORREPLY;

					// Read in address information.
					ServerInfo.Address.abIP[0] = NETWORK_ReadByte( pByteStream );
					ServerInfo.Address.abIP[1] = NETWORK_ReadByte( pByteStream );
					ServerInfo.Address.abIP[2] = NETWORK_ReadByte( pByteStream );
					ServerInfo.Address.abIP[3] = NETWORK_ReadByte( pByteStream );
					ServerInfo.Address.usPort = htons( NETWORK_ReadShort( pByteStream ));

					ServerInfo.tLastQuery = tNow;

					// Add this server's info to our list, and query it.			
					i = aServerInfo.Push( ServerInfo );
					ZANDRONUM_QueryServer( &aServerInfo[i] );
				}
				break;

			case MSC_SERVERBLOCK:
				{
					// Read in address information.
					ULONG ulPorts = 0;
					while (( ulPorts = NETWORK_ReadByte( pByteStream ) ))
					{
						ServerInfo.Address.abIP[0] = NETWORK_ReadByte( pByteStream );
						ServerInfo.Address.abIP[1] = NETWORK_ReadByte( pByteStream );
						ServerInfo.Address.abIP[2] = NETWORK_ReadByte( pByteStream );
						ServerInfo.Address.abIP[3] = NETWORK_ReadByte( pByteStream );
						for ( ULONG ulIdx = 0; ulIdx < ulPorts; ++ulIdx )
						{
							ServerInfo.ulActiveState = AS_WAITINGFORREPLY;
							ServerInfo.Address.usPort = htons( NETWORK_ReadShort( pByteStream ));

							ServerInfo.tLastQuery = tNow;

							// Add this server's info to our list, and query it.			
							i = aServerInfo.Push( ServerInfo );
							ZANDRONUM_QueryServer( &aServerInfo[i] );
						}
					}

				}
				break;

			case MSC_ENDSERVERLISTPART:
				return false;

			case MSC_ENDSERVERLIST:
				Printf( "Received %d Zandronum servers.\n", aServerInfo.Size( ));

				// Since we got the server list, return true.
				return true;

			default:
//.........这里部分代码省略.........
开发者ID:WChrisK,项目名称:Zandronum,代码行数:101,代码来源:protocol_zandronum.cpp

示例4: ParseTextMap

	void ParseTextMap(MapData *map)
	{
		char *buffer = new char[map->Size(ML_TEXTMAP)];

		isTranslated = true;
		isExtended = false;
		floordrop = false;

		map->Read(ML_TEXTMAP, buffer);
		sc.OpenMem(Wads.GetLumpFullName(map->lumpnum), buffer, map->Size(ML_TEXTMAP));
		delete [] buffer;
		sc.SetCMode(true);
		if (sc.CheckString("namespace"))
		{
			sc.MustGetStringName("=");
			sc.MustGetString();
			namespc = sc.String;
			switch(namespc)
			{
			case NAME_ZDoom:
				namespace_bits = Zd;
				isTranslated = false;
				break;
			case NAME_ZDoomTranslated:
				level.flags2 |= LEVEL2_DUMMYSWITCHES;
				namespace_bits = Zdt;
				break;
			case NAME_Vavoom:
				namespace_bits = Va;
				isTranslated = false;
				break;
			case NAME_Hexen:
				namespace_bits = Hx;
				isTranslated = false;
				break;
			case NAME_Doom:
				namespace_bits = Dm;
				P_LoadTranslator("xlat/doom_base.txt");
				level.flags2 |= LEVEL2_DUMMYSWITCHES;
				floordrop = true;
				break;
			case NAME_Heretic:
				namespace_bits = Ht;
				P_LoadTranslator("xlat/heretic_base.txt");
				level.flags2 |= LEVEL2_DUMMYSWITCHES;
				floordrop = true;
				break;
			case NAME_Strife:
				namespace_bits = St;
				P_LoadTranslator("xlat/strife_base.txt");
				level.flags2 |= LEVEL2_DUMMYSWITCHES|LEVEL2_RAILINGHACK;
				floordrop = true;
				break;
			default:
				Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameTypeName());
				switch (gameinfo.gametype)
				{
				default:			// Shh, GCC
				case GAME_Doom:
				case GAME_Chex:
					namespace_bits = Dm;
					P_LoadTranslator("xlat/doom_base.txt");
					break;
				case GAME_Heretic:
					namespace_bits = Ht;
					P_LoadTranslator("xlat/heretic_base.txt");
					break;
				case GAME_Strife:
					namespace_bits = St;
					P_LoadTranslator("xlat/strife_base.txt");
					break;
				case GAME_Hexen:
					namespace_bits = Hx;
					isTranslated = false;
					break;
				}
			}
			sc.MustGetStringName(";");
		}
		else
		{
			Printf("Map does not define a namespace.\n");
		}

		while (sc.GetString())
		{
			if (sc.Compare("thing"))
			{
				FMapThing th;
				unsigned userdatastart = MapThingsUserData.Size();
				ParseThing(&th);
				MapThingsConverted.Push(th);
				if (userdatastart < MapThingsUserData.Size())
				{ // User data added
					MapThingsUserDataIndex[MapThingsConverted.Size()-1] = userdatastart;
					// Mark end of the user data for this map thing
					FMapThingUserData ud;
					ud.Property = NAME_None;
					ud.Value = 0;
					MapThingsUserData.Push(ud);
//.........这里部分代码省略.........
开发者ID:DaZombieKiller,项目名称:lxDoom,代码行数:101,代码来源:p_udmf.cpp

示例5: R_InitColormaps

void R_InitColormaps ()
{
	// [RH] Try and convert BOOM colormaps into blending values.
	//		This is a really rough hack, but it's better than
	//		not doing anything with them at all (right?)

	FakeCmap cm;

	R_DeinitColormaps();

	cm.name[0] = 0;
	cm.blend = 0;
	fakecmaps.Push(cm);

	uint32_t NumLumps = Wads.GetNumLumps();

	for (uint32_t i = 0; i < NumLumps; i++)
	{
		if (Wads.GetLumpNamespace(i) == ns_colormaps)
		{
			char name[9];
			name[8] = 0;
			Wads.GetLumpName (name, i);

			if (Wads.CheckNumForName (name, ns_colormaps) == (int)i)
			{
				strncpy(cm.name, name, 8);
				cm.blend = 0;
				cm.lump = i;
				fakecmaps.Push(cm);
			}
		}
	}

	int rr = 0, gg = 0, bb = 0;
	for(int x=0;x<256;x++)
	{
		rr += GPalette.BaseColors[x].r;
		gg += GPalette.BaseColors[x].g;
		bb += GPalette.BaseColors[x].b;
	}
	rr >>= 8;
	gg >>= 8;
	bb >>= 8;

	int palette_brightness = (rr*77 + gg*143 + bb*35) / 255;

	// To calculate the blend it will just average the colors of the first map
	if (fakecmaps.Size() > 1)
	{
		uint8_t map[256];

		for (unsigned j = 1; j < fakecmaps.Size(); j++)
		{
			if (Wads.LumpLength (fakecmaps[j].lump) >= 256)
			{
				int k, r, g, b;
				FWadLump lump = Wads.OpenLumpNum (fakecmaps[j].lump);
				lump.Read(map, 256);
				r = g = b = 0;

				for (k = 0; k < 256; k++)
				{
					r += GPalette.BaseColors[map[k]].r;
					g += GPalette.BaseColors[map[k]].g;
					b += GPalette.BaseColors[map[k]].b;
				}
				r /= 256;
				g /= 256;
				b /= 256;
				// The calculated average is too dark so brighten it according to the palettes's overall brightness
				int maxcol = MAX<int>(MAX<int>(palette_brightness, r), MAX<int>(g, b));
				
				fakecmaps[j].blend = PalEntry (255, r * 255 / maxcol, g * 255 / maxcol, b * 255 / maxcol);
			}
		}
	}

	// build default special maps (e.g. invulnerability)

	for (unsigned i = 0; i < countof(SpecialColormapParms); ++i)
	{
		AddSpecialColormap(SpecialColormapParms[i].Start[0], SpecialColormapParms[i].Start[1],
			SpecialColormapParms[i].Start[2], SpecialColormapParms[i].End[0],
			SpecialColormapParms[i].End[1], SpecialColormapParms[i].End[2]);
	}
	// desaturated colormaps. These are used for texture composition
	for(int m = 0; m < 31; m++)
	{
		uint8_t *shade = DesaturateColormap[m];
		for (int c = 0; c < 256; c++)
		{
			int intensity = (GPalette.BaseColors[c].r * 77 +
						GPalette.BaseColors[c].g * 143 +
						GPalette.BaseColors[c].b * 37) / 256;

			int r = (GPalette.BaseColors[c].r * (31-m) + intensity *m) / 31;
			int g = (GPalette.BaseColors[c].g * (31-m) + intensity *m) / 31;
			int b = (GPalette.BaseColors[c].b * (31-m) + intensity *m) / 31;
			shade[c] = ColorMatcher.Pick(r, g, b);
//.........这里部分代码省略.........
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:101,代码来源:colormaps.cpp

示例6: ParseCompatibility

void ParseCompatibility()
{
	TArray<FMD5Holder> md5array;
	FMD5Holder md5;
	FCompatValues flags;
	int i, x;
	unsigned int j;

	BCompatMap.Clear();
	CompatParams.Clear();

	// The contents of this file are not cumulative, as it should not
	// be present in user-distributed maps.
	FScanner sc(Wads.GetNumForFullName("compatibility.txt"));

	while (sc.GetString())	// Get MD5 signature
	{
		do
		{
			if (strlen(sc.String) != 32)
			{
				sc.ScriptError("MD5 signature must be exactly 32 characters long");
			}
			for (i = 0; i < 32; ++i)
			{
				if (sc.String[i] >= '0' && sc.String[i] <= '9')
				{
					x = sc.String[i] - '0';
				}
				else
				{
					sc.String[i] |= 'a' ^ 'A';
					if (sc.String[i] >= 'a' && sc.String[i] <= 'f')
					{
						x = sc.String[i] - 'a' + 10;
					}
					else
					{
						x = 0;
						sc.ScriptError("MD5 signature must be a hexadecimal value");
					}
				}
				if (!(i & 1))
				{
					md5.Bytes[i / 2] = x << 4;
				}
				else
				{
					md5.Bytes[i / 2] |= x;
				}
			}
			md5array.Push(md5);
			sc.MustGetString();
		} while (!sc.Compare("{"));
		memset(flags.CompatFlags, 0, sizeof(flags.CompatFlags));
		flags.ExtCommandIndex = ~0u;
		while (sc.GetString())
		{
			if ((i = sc.MatchString(&Options[0].Name, sizeof(*Options))) >= 0)
			{
				flags.CompatFlags[Options[i].WhichSlot] |= Options[i].CompatFlags;
			}
			else if (sc.Compare("clearlineflags"))
			{
				if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size();
				CompatParams.Push(CP_CLEARFLAGS);
				sc.MustGetNumber();
				CompatParams.Push(sc.Number);
				sc.MustGetNumber();
				CompatParams.Push(sc.Number);
			}
			else if (sc.Compare("setlineflags"))
			{
				if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size();
				CompatParams.Push(CP_SETFLAGS);
				sc.MustGetNumber();
				CompatParams.Push(sc.Number);
				sc.MustGetNumber();
				CompatParams.Push(sc.Number);
			}
			else if (sc.Compare("setlinespecial"))
			{
				if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size();
				CompatParams.Push(CP_SETSPECIAL);
				sc.MustGetNumber();
				CompatParams.Push(sc.Number);

				sc.MustGetString();
				CompatParams.Push(P_FindLineSpecial(sc.String, NULL, NULL));
				for (int i = 0; i < 5; i++)
				{
					sc.MustGetNumber();
					CompatParams.Push(sc.Number);
				}
			}
			else if (sc.Compare("clearlinespecial"))
			{
				if (flags.ExtCommandIndex == ~0u) flags.ExtCommandIndex = CompatParams.Size();
				CompatParams.Push(CP_CLEARSPECIAL);
				sc.MustGetNumber();
//.........这里部分代码省略.........
开发者ID:BenJamesbabala,项目名称:ViZDoom,代码行数:101,代码来源:compatibility.cpp

示例7: AssignMinimalAdjacencyGroups

/**
 * Assigns a group index to each triangle such that it's the same group as its adjacent triangles.
 * The group indices are between zero and the minimum number of indices needed.
 * @return The number of groups used.
 */
static uint32 AssignMinimalAdjacencyGroups(const TArray<uint32>& Adjacency,TArray<int32>& OutTriangleGroups)
{
	const uint32 NumTriangles = Adjacency.Num() / 3;
	check(Adjacency.Num() == NumTriangles * 3);

	// Initialize the triangle group array.
	OutTriangleGroups.Empty(NumTriangles);
	for(uint32 TriangleIndex = 0;TriangleIndex < NumTriangles;TriangleIndex++)
	{
		OutTriangleGroups.Add(INDEX_NONE);
	}

	uint32 NumGroups = 0;
	while(true)
	{
		const uint32 CurrentGroupIndex = NumGroups;
		TArray<uint32> PendingGroupTriangles;

		// Find the next ungrouped triangle to start the group with.
		for(uint32 TriangleIndex = 0;TriangleIndex < NumTriangles;TriangleIndex++)
		{
			if(OutTriangleGroups[TriangleIndex] == INDEX_NONE)
			{
				PendingGroupTriangles.Push(TriangleIndex);
				break;
			}
		}

		if(!PendingGroupTriangles.Num())
		{
			break;
		}
		else
		{
			// Recursively expand the group to include all triangles adjacent to the group's triangles.
			while(PendingGroupTriangles.Num())
			{
				const uint32 TriangleIndex = PendingGroupTriangles.Pop();

				OutTriangleGroups[TriangleIndex] = CurrentGroupIndex;

				for(int32 EdgeIndex = 0;EdgeIndex < 3;EdgeIndex++)
				{
					const int32 AdjacentTriangleIndex = Adjacency[TriangleIndex * 3 + EdgeIndex];
					if(AdjacentTriangleIndex != INDEX_NONE)
					{
						const int32 AdjacentTriangleGroupIndex = OutTriangleGroups[AdjacentTriangleIndex];
						check(AdjacentTriangleGroupIndex == INDEX_NONE || AdjacentTriangleGroupIndex == CurrentGroupIndex);
						if(AdjacentTriangleGroupIndex == INDEX_NONE)
						{
							PendingGroupTriangles.Push(AdjacentTriangleIndex);
						}
					}
				}
			};

			NumGroups++;
		}
	};

	return NumGroups;
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:67,代码来源:D3D9MeshUtils.cpp

示例8: server_rcon_HandleLogin

static void server_rcon_HandleLogin( int iCandidateIndex, const char *pszHash )
{
	// If there's no slot, the candidate must have timed out, or is hacking. Bye!
	if ( iCandidateIndex == -1 )
		return;

	// Combine the salt and password, and hash it.
	FString fsString, fsCorrectHash;
	fsString.Format( "%s%s", g_Candidates[iCandidateIndex].szSalt, sv_rconpassword.GetGenericRep(CVAR_String).String );	
	CMD5Checksum::GetMD5( reinterpret_cast<const BYTE *>(fsString.GetChars()), fsString.Len(), fsCorrectHash );

	// Compare that to what he sent us.
	// Printf("Mine: %s\nTheirs: %s\n", fsCorrectHash, pszHash );
	NETWORK_ClearBuffer( &g_MessageBuffer );
	// [BB] Do not allow the server to let anybody use RCON in case sv_rconpassword is empty.
	if ( fsCorrectHash.Compare( pszHash ) || ( strlen( sv_rconpassword.GetGenericRep(CVAR_String).String ) == 0 ) )
	{
		// Wrong password.
		NETWORK_WriteByte( &g_MessageBuffer.ByteStream, SVRC_INVALIDPASSWORD );
		NETWORK_LaunchPacket( &g_MessageBuffer, g_Candidates[iCandidateIndex].Address ); // [RC] Note: Be sure to finish any packets before calling Printf(). Otherwise SERVER_RCON_Print will clear your buffer.

		// To prevent mass password flooding, ignore the IP for a few seconds.
		g_BadRequestFloodQueue.addAddress( g_Candidates[iCandidateIndex].Address, gametic / 1000 );

		Printf( "Failed RCON login from %s. Ignoring IP for 10 seconds...\n", NETWORK_AddressToString( g_Candidates[iCandidateIndex].Address ));
	}
	else
	{		
		// [BB] Since we log when RCON clients disconnect, we should also log when they connect.
		// Do this before we do anything else so that this message is sent to the new RCON client
		// with the console history.
		Printf( "RCON client at %s connected.\n", NETWORK_AddressToString( g_Candidates[iCandidateIndex].Address ));

		// Correct password. Promote him to an authed client.
		RCONCLIENT_s Client;
		Client.Address = g_Candidates[iCandidateIndex].Address;
		Client.iLastMessageTic = gametic;
		g_AuthedClients.Push( Client );

		NETWORK_ClearBuffer( &g_MessageBuffer );
		NETWORK_WriteByte( &g_MessageBuffer.ByteStream, SVRC_LOGGEDIN );

		// Tell him some info about the server.
		NETWORK_WriteByte( &g_MessageBuffer.ByteStream, PROTOCOL_VERSION );
		NETWORK_WriteString( &g_MessageBuffer.ByteStream, sv_hostname.GetGenericRep( CVAR_String ).String );
		
		// Send updates.
		NETWORK_WriteByte( &g_MessageBuffer.ByteStream, NUM_RCON_UPDATES );
		for ( int i = 0; i < NUM_RCON_UPDATES; i++ )
			server_WriteUpdateInfo( &g_MessageBuffer.ByteStream, i );

		// Send the console history.
		NETWORK_WriteByte( &g_MessageBuffer.ByteStream, g_RecentConsoleLines.size() );
		for( std::list<FString>::iterator i = g_RecentConsoleLines.begin(); i != g_RecentConsoleLines.end(); ++i )
			NETWORK_WriteString( &g_MessageBuffer.ByteStream, *i );

		NETWORK_LaunchPacket( &g_MessageBuffer, g_Candidates[iCandidateIndex].Address );
		SERVER_RCON_UpdateInfo( SVRCU_ADMINCOUNT );
	}

	// Remove his temporary slot.	
	g_Candidates.Delete( iCandidateIndex );
}
开发者ID:WChrisK,项目名称:Zandronum,代码行数:63,代码来源:sv_rcon.cpp

示例9: InitThingdef

void InitThingdef()
{
	PType *TypeActor = NewPointer(RUNTIME_CLASS(AActor));

	PStruct *sstruct = NewNativeStruct("Sector", nullptr);
	auto sptr = NewPointer(sstruct);
	sstruct->AddNativeField("soundtarget", TypeActor, myoffsetof(sector_t, SoundTarget));
	
	// expose the global validcount variable.
	PField *vcf = new PField("validcount", TypeSInt32, VARF_Native | VARF_Static, (intptr_t)&validcount);
	GlobalSymbols.AddSymbol(vcf);

	// expose the global Multiplayer variable.
	PField *multif = new PField("multiplayer", TypeBool, VARF_Native | VARF_ReadOnly | VARF_Static, (intptr_t)&multiplayer);
	GlobalSymbols.AddSymbol(multif);

	// set up a variable for the global level data structure
	PStruct *lstruct = NewNativeStruct("LevelLocals", nullptr);
	PField *levelf = new PField("level", lstruct, VARF_Native | VARF_Static, (intptr_t)&level);
	GlobalSymbols.AddSymbol(levelf);

	// set up a variable for the DEH data
	PStruct *dstruct = NewNativeStruct("DehInfo", nullptr);
	PField *dehf = new PField("deh", dstruct, VARF_Native | VARF_Static, (intptr_t)&deh);

	GlobalSymbols.AddSymbol(dehf);

	// set up a variable for the global players array.
	PStruct *pstruct = NewNativeStruct("PlayerInfo", nullptr);
	pstruct->Size = sizeof(player_t);
	pstruct->Align = alignof(player_t);
	PArray *parray = NewArray(pstruct, MAXPLAYERS);
	PField *playerf = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players);
	GlobalSymbols.AddSymbol(playerf);

	// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
	// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
	pstruct = NewNativeStruct("Sector", nullptr);
	pstruct->AddNativeField("lines", NewPointer(NewArray(NewPointer(NewNativeStruct("line", nullptr), false), 0x40000), false), myoffsetof(sector_t, lines), VARF_Native);

	parray = NewArray(TypeBool, MAXPLAYERS);
	playerf = new PField("playeringame", parray, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&playeringame);
	GlobalSymbols.AddSymbol(playerf);

	playerf = new PField("gameaction", TypeUInt8, VARF_Native | VARF_Static, (intptr_t)&gameaction);
	GlobalSymbols.AddSymbol(playerf);

	playerf = new PField("consoleplayer", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&consoleplayer);
	GlobalSymbols.AddSymbol(playerf);

	// Argh. It sucks when bad hacks need to be supported. WP_NOCHANGE is just a bogus pointer but it used everywhere as a special flag.
	// It cannot be defined as constant because constants can either be numbers or strings but nothing else, so the only 'solution'
	// is to create a static variable from it and reference that in the script. Yuck!!!
	static AWeapon *wpnochg = WP_NOCHANGE;
	playerf = new PField("WP_NOCHANGE", NewPointer(RUNTIME_CLASS(AWeapon), false), VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&wpnochg);
	GlobalSymbols.AddSymbol(playerf);

	// this needs to be done manually until it can be given a proper type.
	RUNTIME_CLASS(AActor)->AddNativeField("DecalGenerator", NewPointer(TypeVoid), myoffsetof(AActor, DecalGenerator));

	// synthesize a symbol for each flag from the flag name tables to avoid redundant declaration of them.
	for (auto &fl : FlagLists)
	{
		if (fl.Use & 2)
		{
			for(int i=0;i<fl.NumDefs;i++)
			{
				if (fl.Defs[i].structoffset > 0) // skip the deprecated entries in this list
				{
					const_cast<PClass*>(*fl.Type)->AddNativeField(FStringf("b%s", fl.Defs[i].name), (fl.Defs[i].fieldsize == 4 ? TypeSInt32 : TypeSInt16), fl.Defs[i].structoffset, fl.Defs[i].varflags, fl.Defs[i].flagbit);
				}
			}
		}
	}

	FAutoSegIterator probe(CRegHead, CRegTail);

	while (*++probe != NULL)
	{
		if (((ClassReg *)*probe)->InitNatives)
			((ClassReg *)*probe)->InitNatives();
	}

	// Sort the flag lists
	for (size_t i = 0; i < NUM_FLAG_LISTS; ++i)
	{
		qsort (FlagLists[i].Defs, FlagLists[i].NumDefs, sizeof(FFlagDef), flagcmp);
	}

	// Create a sorted list of properties
	if (properties.Size() == 0)
	{
		FAutoSegIterator probe(GRegHead, GRegTail);

		while (*++probe != NULL)
		{
			properties.Push((FPropertyInfo *)*probe);
		}
		properties.ShrinkToFit();
		qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
//.........这里部分代码省略.........
开发者ID:dwing4g,项目名称:gzdoom,代码行数:101,代码来源:thingdef_data.cpp

示例10:

/** Creates a vertex element list for the D3D9MeshUtils vertex format. */
static void GetD3D9MeshVertexDeclarations(TArray<D3DVERTEXELEMENT9>& OutVertexElements)
{
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,Position), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[0]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[1]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[2]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[3]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 3));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[4]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 4));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[5]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 5));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[6]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 6));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,UVs[7]), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 7));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,Color), D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,SmoothingMask), D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,TangentX), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,TangentY), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0));
	OutVertexElements.Push(ConstructD3DVertexElement(0, STRUCT_OFFSET(FUtilVertex,TangentZ), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0));
	OutVertexElements.Push(ConstructD3DVertexElement(0xFF,0,D3DDECLTYPE_UNUSED,0,0,0));
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:19,代码来源:D3D9MeshUtils.cpp

示例11: ParseTeamDefinition

void FTeam::ParseTeamDefinition (FScanner &Scan)
{
	FTeam Team;
	int valid = -1;
	Scan.MustGetString ();
	Team.m_Name = Scan.String;
	Scan.MustGetStringName ("{");

	while (!Scan.CheckString ("}"))
	{
		Scan.MustGetString ();

		switch (Scan.MatchString (TeamInfoOptions))
		{
		case TEAMINFO_Game:
			Scan.MustGetString ();
			if (Scan.Compare("Any")) valid = 1;
			else if (CheckGame(Scan.String, false)) valid = 1;
			else if (valid == -1) valid = 0;
			break;

		case TEAMINFO_PlayerColor:
			Scan.MustGetString ();
			Team.m_iPlayerColor = V_GetColor (NULL, Scan.String);
			break;

		case TEAMINFO_TextColor:
			Scan.MustGetString ();
			Team.m_TextColor.AppendFormat ("[%s]", Scan.String);
			break;

		case TEAMINFO_Logo:
			Scan.MustGetString ();
			Team.m_Logo = Scan.String;
			break;

		case TEAMINFO_AllowCustomPlayerColor:
			Team.m_bAllowCustomPlayerColor = true;
			break;

		case TEAMINFO_PlayerStartThingNumber:
			Scan.MustGetNumber ();
			break;

		case TEAMINFO_RailColor:
		case TEAMINFO_FlagItem:
		case TEAMINFO_SkullItem:
		case TEAMINFO_SmallFlagHUDIcon:
		case TEAMINFO_SmallSkullHUDIcon:
		case TEAMINFO_LargeFlagHUDIcon:
		case TEAMINFO_LargeSkullHUDIcon:
		case TEAMINFO_WinnerPic:
		case TEAMINFO_LoserPic:
		case TEAMINFO_WinnerTheme:
		case TEAMINFO_LoserTheme:
			Scan.MustGetString ();
			break;

		default:
			Scan.ScriptError ("ParseTeamDefinition: Unknown team option '%s'.\n", Scan.String);
			break;
		}
	}

	if (valid) Teams.Push (Team);
}
开发者ID:1Akula1,项目名称:gzdoom,代码行数:66,代码来源:teaminfo.cpp

示例12: ParsePropertyParams

static bool ParsePropertyParams(FScanner &sc, FPropertyInfo *prop, AActor *defaults, Baggage &bag)
{
	static TArray<FPropParam> params;
	static TArray<FString> strings;

	params.Clear();
	strings.Clear();
	params.Reserve(1);
	params[0].i = 0;
	if (prop->params[0] != '0')
	{
		const char * p = prop->params;
		bool nocomma;
		bool optcomma;
		while (*p)
		{
			FPropParam conv;
			FPropParam pref;

			nocomma = false;
			conv.s = NULL;
			pref.s = NULL;
			pref.i = -1;
			bag.ScriptPosition = sc;
			switch ((*p) & 223)
			{
			case 'X':	// Expression in parentheses or number.
				{
					FxExpression *x = NULL;

					if (sc.CheckString ("("))
					{
						x = new FxDamageValue(new FxIntCast(ParseExpression(sc, bag.Info)), true);
						sc.MustGetStringName(")");
					}
					else
					{
						sc.MustGetNumber();
						if (sc.Number != 0)
						{
							x = new FxDamageValue(new FxConstant(sc.Number, bag.ScriptPosition), false);
						}
					}
					conv.exp = x;
					params.Push(conv);
				}
				break;

			case 'I':
				sc.MustGetNumber();
				conv.i = sc.Number;
				break;

			case 'F':
				sc.MustGetFloat();
				conv.d = sc.Float;
				break;

			case 'Z':	// an optional string. Does not allow any numerical value.
				if (sc.CheckFloat())
				{
					nocomma = true;
					sc.UnGet();
					break;
				}
				// fall through

			case 'S':
				sc.MustGetString();
				conv.s = strings[strings.Reserve(1)] = sc.String;
				break;

			case 'T':
				sc.MustGetString();
				conv.s = strings[strings.Reserve(1)] = strbin1(sc.String);
				break;

			case 'C':
				if (sc.CheckNumber ())
				{
					int R, G, B;
					R = clamp (sc.Number, 0, 255);
					sc.CheckString (",");
					sc.MustGetNumber ();
					G = clamp (sc.Number, 0, 255);
					sc.CheckString (",");
					sc.MustGetNumber ();
					B = clamp (sc.Number, 0, 255);
					conv.i = MAKERGB(R, G, B);
					pref.i = 0;
				}
				else
				{
					sc.MustGetString ();
					conv.s = strings[strings.Reserve(1)] = sc.String;
					pref.i = 1;
				}
				break;

			case 'M':	// special case. An expression-aware parser will not need this.
//.........这里部分代码省略.........
开发者ID:StrikerMan780,项目名称:zdoom,代码行数:101,代码来源:thingdef_parse.cpp

示例13: gl_InitPortals

void gl_InitPortals()
{
	FPortalMap collection;

	if (level.nodes.Size() == 0) return;

	
	CollectPortalSectors(collection);
	glSectorPortals.Clear();

	FPortalMap::Iterator it(collection);
	FPortalMap::Pair *pair;
	int c = 0;
	int planeflags = 0;
	while (it.NextPair(pair))
	{
		for(unsigned i=0;i<pair->Value.Size(); i++)
		{
			if (pair->Value[i].mPlane == sector_t::floor) planeflags |= 1;
			else if (pair->Value[i].mPlane == sector_t::ceiling) planeflags |= 2;
		}
		for (int i=1;i<=2;i<<=1)
		{
			// add separate glSectorPortals for floor and ceiling.
			if (planeflags & i)
			{
				FPortal *portal = new FPortal;
				portal->mDisplacement = pair->Key.mDisplacement;
				portal->plane = (i==1? sector_t::floor : sector_t::ceiling);	/**/
				portal->glportal = NULL;
				glSectorPortals.Push(portal);
				for(unsigned j=0;j<pair->Value.Size(); j++)
				{
					sector_t *sec = pair->Value[j].mSub;
					int plane = pair->Value[j].mPlane;
					if (portal->plane == plane)
					{
						for(int k=0;k<sec->subsectorcount; k++)
						{
							subsector_t *sub = sec->subsectors[k];
							gl_BuildPortalCoverage(&sub->portalcoverage[plane], sub, pair->Key.mDisplacement);
						}
						sec->portals[plane] = portal;
					}
				}
			}
		}
	}

	// Now group the line glSectorPortals (each group must be a continuous set of colinear linedefs with no gaps)
	glLinePortals.Clear();
	linePortalToGL.Clear();
	TArray<int> tempindex;

	tempindex.Reserve(linePortals.Size());
	memset(&tempindex[0], -1, linePortals.Size() * sizeof(int));

	for (unsigned i = 0; i < linePortals.Size(); i++)
	{
		auto port = linePortals[i];
		bool gotsome;

		if (tempindex[i] == -1)
		{
			tempindex[i] = glLinePortals.Size();
			line_t *pSrcLine = linePortals[i].mOrigin;
			line_t *pLine = linePortals[i].mDestination;
			FGLLinePortal &glport = glLinePortals[glLinePortals.Reserve(1)];
			glport.lines.Push(&linePortals[i]);

			// We cannot do this grouping for non-linked glSectorPortals because they can be changed at run time.
			if (linePortals[i].mType == PORTT_LINKED && pLine != nullptr)
			{
				glport.v1 = pLine->v1;
				glport.v2 = pLine->v2;
				do
				{
					// now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match
					gotsome = false;
					for (unsigned j = 0; j < linePortals.Size(); j++)
					{
						if (tempindex[j] == -1)
						{
							line_t *pSrcLine2 = linePortals[j].mOrigin;
							line_t *pLine2 = linePortals[j].mDestination;
							// angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical glSectorPortals aren't found here.)
							unsigned srcang = pSrcLine->Delta().Angle().BAMs();
							unsigned dstang = pLine->Delta().Angle().BAMs();
							if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) ||
								(pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1))
							{
								// The line connects, now check the translation
								unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs();
								unsigned dstang2 = pLine2->Delta().Angle().BAMs();
								if (srcang == srcang2 && dstang == dstang2)
								{
									// The lines connect and  both source and destination are colinear, so this is a match
									gotsome = true;
									tempindex[j] = tempindex[i];
									if (pLine->v1 == pLine2->v2) glport.v1 = pLine2->v1;
//.........这里部分代码省略.........
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:101,代码来源:gl_portaldata.cpp

示例14: PO_Init

void MapLoader::PO_Init (void)
{
	int NumPolyobjs = 0;
	TArray<FMapThing *> polythings;
	for (auto &mthing : MapThingsConverted)
	{
		if (mthing.EdNum == 0 || mthing.EdNum == -1 || mthing.info == nullptr) continue;

		FDoomEdEntry *mentry = mthing.info;
		switch (mentry->Special)
		{
		case SMT_PolyAnchor:
		case SMT_PolySpawn:
		case SMT_PolySpawnCrush:
		case SMT_PolySpawnHurt:
			polythings.Push(&mthing);
			if (mentry->Special != SMT_PolyAnchor)
				NumPolyobjs++;
		}
	}

	int polyIndex;

	// [RH] Make this faster
	InitSideLists ();

	Level->Polyobjects.Resize(NumPolyobjs);
	for (auto &po : Level->Polyobjects) po.Level = Level;	// must be done before the init loop below.

	polyIndex = 0; // index polyobj number
	// Find the startSpot points, and spawn each polyobj
	for (int i=polythings.Size()-1; i >= 0; i--)
	{
		// 9301 (3001) = no crush, 9302 (3002) = crushing, 9303 = hurting touch
		int type = polythings[i]->info->Special;
		if (type >= SMT_PolySpawn && type <= SMT_PolySpawnHurt)
		{ 
			// Polyobj StartSpot Pt.
			Level->Polyobjects[polyIndex].StartSpot.pos = polythings[i]->pos;
			SpawnPolyobj(polyIndex, polythings[i]->angle, type);
			polyIndex++;
		} 
	}
	for (int i = polythings.Size() - 1; i >= 0; i--)
	{
		int type = polythings[i]->info->Special;
		if (type == SMT_PolyAnchor)
		{ 
			// Polyobj Anchor Pt.
			TranslateToStartSpot (polythings[i]->angle, polythings[i]->pos);
		}
	}

	// check for a startspot without an anchor point
	for (auto &poly : Level->Polyobjects)
	{
		if (poly.OriginalPts.Size() == 0)
		{
			Printf (TEXTCOLOR_RED "PO_Init: StartSpot located without an Anchor point: %d\n", poly.tag);
		}
	}
	InitPolyBlockMap();

	// [RH] Don't need the side lists anymore
	KnownPolySides.Reset();

	// mark all subsectors which have a seg belonging to a polyobj
	// These ones should not be rendered on the textured automap.
	for (auto &ss : Level->subsectors)
	{
		for(uint32_t j=0;j<ss.numlines; j++)
		{
			if (ss.firstline[j].sidedef != NULL &&
				ss.firstline[j].sidedef->Flags & WALLF_POLYOBJ)
			{
				ss.flags |= SSECF_POLYORG;
				break;
			}
		}
	}
	// clear all polyobj specials so that they do not obstruct using other lines.
	for (auto &line : Level->lines)
	{
		if (line.special == Polyobj_ExplicitLine || line.special == Polyobj_StartLine)
		{
			line.special = 0;
		}
	}
}
开发者ID:coelckers,项目名称:gzdoom,代码行数:89,代码来源:polyobjects.cpp

示例15: PostLoad

void USoundCue::PostLoad()
{
	Super::PostLoad();

	// Game doesn't care if there are NULL graph nodes
#if WITH_EDITOR
	if (GIsEditor )
	{
		if (SoundCueGraph)
		{
			// Deal with SoundNode types being removed - iterate in reverse as nodes may be removed
			for (int32 idx = SoundCueGraph->Nodes.Num() - 1; idx >= 0; --idx)
			{
				USoundCueGraphNode* Node = Cast<USoundCueGraphNode>(SoundCueGraph->Nodes[idx]);

				if (Node && Node->SoundNode == NULL)
				{
					FBlueprintEditorUtils::RemoveNode(NULL, Node, true);
				}
			}
		}
		else
		{
			// we should have a soundcuegraph unless we are contained in a package which is missing editor only data
			check( GetOutermost()->HasAnyPackageFlags(PKG_FilterEditorOnly) );
		}

		// Always load all sound waves in the editor
		for (USoundNode* SoundNode : AllNodes)
		{
			if (USoundNodeAssetReferencer* AssetReferencerNode = Cast<USoundNodeAssetReferencer>(SoundNode))
			{
				AssetReferencerNode->LoadAsset();
			}
		}
	}
	else
#endif
	{
		TArray<USoundNode*> NodesToEvaluate;
		NodesToEvaluate.Push(FirstNode);

		while (NodesToEvaluate.Num() > 0)
		{
			if (USoundNode* SoundNode = NodesToEvaluate.Pop(false))
			{
				if (USoundNodeAssetReferencer* AssetReferencerNode = Cast<USoundNodeAssetReferencer>(SoundNode))
				{
					AssetReferencerNode->LoadAsset();
				}
				else if (USoundNodeQualityLevel* QualityLevelNode = Cast<USoundNodeQualityLevel>(SoundNode))
				{
					// Only pick the node connected for current quality, currently don't support changing audio quality on the fly
					static const int32 CachedQualityLevel = GEngine->GetGameUserSettings()->GetAudioQualityLevel();
					if (CachedQualityLevel < QualityLevelNode->ChildNodes.Num())
					{
						NodesToEvaluate.Add(QualityLevelNode->ChildNodes[CachedQualityLevel]);
					}
				}
				else
				{
					NodesToEvaluate.Append(SoundNode->ChildNodes);
				}
			}
		}
	}
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:67,代码来源:SoundCue.cpp


注:本文中的TArray::Push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。