您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ARRAYCOUNT函数代码示例

51自学网 2021-06-01 19:36:15
  C++
这篇教程C++ ARRAYCOUNT函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ARRAYCOUNT函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAYCOUNT函数的具体用法?C++ ARRAYCOUNT怎么用?C++ ARRAYCOUNT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: GetBirchTreeImage

void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks){	int Height = 5 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3);		// Prealloc, so that we don't realloc too often later:	a_LogBlocks.reserve(Height);	a_OtherBlocks.reserve(80);		// The entire trunk, out of logs:	for (int i = Height - 1; i >= 0; --i)	{		a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_BIRCH));	}	int h = a_BlockY + Height;		// Top layer - just the Plus:	PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);	a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH));  // There's no log at this layer	h--;		// Second layer - log, Plus and maybe Corners:	PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);	PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);	h--;		// Third and fourth layers - BigO2 and maybe 2*Corners:	for (int Row = 0; Row < 2; Row++)	{		PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);		PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x3fffffff + Row * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH);		h--;	}  // for Row - 2*}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:33,


示例2: testFullRotation

/** Tests rotating the direction 360 degrees. */static void testFullRotation(){	// Rotate 90 degrees CCW four times:	for (size_t i = 0; i < ARRAYCOUNT(g_AllDirections); ++i)	{		auto d = g_AllDirections[i];		for (int j = 0; j < 4; ++j)		{			d = cPiece::cConnector::RotateDirectionCCW(d);		}		EXPECT(d == g_AllDirections[i]);	}	// Rotate 90 degrees CW four times:	for (size_t i = 0; i < ARRAYCOUNT(g_AllDirections); ++i)	{		auto d = g_AllDirections[i];		for (int j = 0; j < 4; ++j)		{			d = cPiece::cConnector::RotateDirectionCW(d);		}		EXPECT(d == g_AllDirections[i]);	}	// Rotate 180 degrees twice:	for (size_t i = 0; i < ARRAYCOUNT(g_AllDirections); ++i)	{		auto d = g_AllDirections[i];		d = cPiece::cConnector::RotateDirection(d);		d = cPiece::cConnector::RotateDirection(d);		EXPECT(d == g_AllDirections[i]);	}}
开发者ID:Pokechu22,项目名称:cuberite,代码行数:34,


示例3: StrToLower

eMonsterType cMonster::StringToMobType(const AString & a_Name){	AString lcName = StrToLower(a_Name);	// Search MCServer name:	for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)	{		if (strcmp(g_MobTypeNames[i].m_lcName, lcName.c_str()) == 0)		{			return g_MobTypeNames[i].m_Type;		}	}	// Not found. Search Vanilla name:	for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)	{		if (strcmp(StrToLower(g_MobTypeNames[i].m_VanillaName).c_str(), lcName.c_str()) == 0)		{			return g_MobTypeNames[i].m_Type;		}	}	// Not found:	return mtInvalidType;}
开发者ID:4264,项目名称:cuberite,代码行数:25,


示例4: GetDarkoakTreeImage

void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks){	// Pick a height	int Height = 5 + (a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY, a_BlockZ + 32 * a_Seq) / 11) % 4;	// Create the trunk	for (int i = 0; i < Height; i++)	{		a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_NEW_LOG, E_META_NEW_LOG_DARK_OAK_WOOD));		a_LogBlocks.push_back(sSetBlock(a_BlockX + 1, a_BlockY + i, a_BlockZ, E_BLOCK_NEW_LOG, E_META_NEW_LOG_DARK_OAK_WOOD));		a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ + 1, E_BLOCK_NEW_LOG, E_META_NEW_LOG_DARK_OAK_WOOD));		a_LogBlocks.push_back(sSetBlock(a_BlockX + 1, a_BlockY + i, a_BlockZ + 1, E_BLOCK_NEW_LOG, E_META_NEW_LOG_DARK_OAK_WOOD));	}	// Create branches	for (int i = 0; i < 3; i++)	{		int x = (a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY * i, a_BlockZ + 32 * a_Seq) % 3) - 1;		int z = (a_Noise.IntNoise3DInt(a_BlockX - 32 * a_Seq, a_BlockY * i, a_BlockZ - 32 * a_Seq) % 3) - 1;		// The branches would end up in the trunk.		if ((x >= a_BlockX) && (x <= a_BlockX + 1) && (z >= a_BlockZ) && (z <= a_BlockZ + 1))		{			NOISE_DATATYPE Val1 = a_Noise.IntNoise2D(x, z);			if (Val1 < 0)			{				x = a_BlockX + ((Val1 < -0.5) ? -1 : 3);			}			else			{				z = a_BlockZ + ((Val1 < 0.5) ? -1 : 3);			}		}		int y = Height - (a_Noise.IntNoise3DInt(a_BlockX + x, a_BlockY * i, a_BlockZ - z) % (Height - (Height / 4)));		for (int Y = y; Y < Height; Y++)		{			a_LogBlocks.push_back(sSetBlock(a_BlockX + x, a_BlockY + Y, a_BlockZ + z, E_BLOCK_NEW_LOG, E_META_NEW_LOG_DARK_OAK_WOOD));		}	}	int hei = a_BlockY + Height - 2;	// The lower two leaves layers are BigO4 with log in the middle and possibly corners:	for (int i = 0; i < 2; i++)	{		PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO4, ARRAYCOUNT(BigO4), E_BLOCK_NEW_LEAVES, E_META_NEW_LEAVES_DARK_OAK_WOOD);		PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_NEW_LEAVES, E_META_NEW_LEAVES_DARK_OAK_WOOD);		hei++;	}  // for i < 2	// The top leaves layer is a BigO3 with leaves in the middle and possibly corners:	PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO3, ARRAYCOUNT(BigO3), E_BLOCK_NEW_LEAVES, E_META_NEW_LEAVES_DARK_OAK_WOOD);	PushCornerBlocks(a_BlockX, hei, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 3, E_BLOCK_NEW_LEAVES, E_META_NEW_LEAVES_DARK_OAK_WOOD);	a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_NEW_LEAVES, E_META_NEW_LEAVES_DARK_OAK_WOOD));}
开发者ID:Haxi52,项目名称:cuberite,代码行数:57,


示例5: ARRAYCOUNT

void cCompoGenClassic::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc::Shape & a_Shape){	/* The classic composition means:		- 1 layer of grass, 3 of dirt and the rest stone, if the height > sealevel + beachheight		- 3 sand and a 1 sandstone, rest stone if between sealevel and sealevel + beachheight		- water from waterlevel to height, then 3 sand, 1 sandstone, the rest stone, if water depth < beachdepth		- water from waterlevel, then 3 dirt, the rest stone otherwise		- bedrock at the bottom	*/	a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);	a_ChunkDesc.SetHeightFromShape(a_Shape);	// The patterns to use for different situations, must be same length!	const BLOCKTYPE PatternGround[] = {m_BlockTop,    m_BlockMiddle, m_BlockMiddle, m_BlockMiddle} ;	const BLOCKTYPE PatternBeach[]  = {m_BlockBeach,  m_BlockBeach,  m_BlockBeach,  m_BlockBeachBottom} ;	const BLOCKTYPE PatternOcean[]  = {m_BlockMiddle, m_BlockMiddle, m_BlockMiddle, m_BlockBottom} ;	static int PatternLength = ARRAYCOUNT(PatternGround);	ASSERT(ARRAYCOUNT(PatternGround) == ARRAYCOUNT(PatternBeach));	ASSERT(ARRAYCOUNT(PatternGround) == ARRAYCOUNT(PatternOcean));	for (int z = 0; z < cChunkDef::Width; z++)	{		for (int x = 0; x < cChunkDef::Width; x++)		{			int Height = a_ChunkDesc.GetHeight(x, z);			const BLOCKTYPE * Pattern;			if (Height > m_SeaLevel + m_BeachHeight)			{				Pattern = PatternGround;			}			else if (Height > m_SeaLevel - m_BeachDepth)			{				Pattern = PatternBeach;			}			else			{				Pattern = PatternOcean;			}			// Fill water from sealevel down to height (if any):			for (int y = m_SeaLevel; y >= Height; --y)			{				a_ChunkDesc.SetBlockType(x, y, z, m_BlockSea);			}			// Fill from height till the bottom:			for (int y = Height; y >= 1; y--)			{				a_ChunkDesc.SetBlockType(x, y, z, (Height - y < PatternLength) ? Pattern[Height - y] : m_BlockBottom);			}			// The last layer is always bedrock:			a_ChunkDesc.SetBlockType(x, 0, z, E_BLOCK_BEDROCK);		}  // for x	}  // for z}
开发者ID:AddictXQ,项目名称:cuberite,代码行数:57,


示例6: memset

NOISE_DATATYPE cHeiGenBiomal::GetHeightAt(int a_RelX, int a_RelZ, int a_ChunkX, int a_ChunkZ, const cHeiGenBiomal::BiomeNeighbors & a_BiomeNeighbors){	// Sum up how many biomes of each type there are in the neighborhood:	int BiomeCounts[biNumBiomes];	memset(BiomeCounts, 0, sizeof(BiomeCounts));	int Sum = 0;	for (int z = -8; z <= 8; z++)	{		int FinalZ = a_RelZ + z + cChunkDef::Width;		int IdxZ = FinalZ / cChunkDef::Width;		int ModZ = FinalZ % cChunkDef::Width;		int WeightZ = 9 - abs(z);		for (int x = -8; x <= 8; x++)		{			int FinalX = a_RelX + x + cChunkDef::Width;			int IdxX = FinalX / cChunkDef::Width;			int ModX = FinalX % cChunkDef::Width;			EMCSBiome Biome = cChunkDef::GetBiome(a_BiomeNeighbors[IdxX][IdxZ], ModX, ModZ);			if ((Biome < 0) || (Biome >= ARRAYCOUNT(BiomeCounts)))			{				continue;			}			int WeightX = 9 - abs(x);			BiomeCounts[Biome] += WeightX + WeightZ;			Sum += WeightX + WeightZ;		}  // for x	}  // for z		// For each biome type that has a nonzero count, calc its height and add it:	if (Sum > 0)	{		NOISE_DATATYPE Height = 0;		int BlockX = a_ChunkX * cChunkDef::Width + a_RelX;		int BlockZ = a_ChunkZ * cChunkDef::Width + a_RelZ;		for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)		{			if (BiomeCounts[i] == 0)			{				continue;			}			NOISE_DATATYPE oct1 = m_Noise.CubicNoise2D(BlockX * m_GenParam[i].m_HeightFreq1, BlockZ * m_GenParam[i].m_HeightFreq1) * m_GenParam[i].m_HeightAmp1;			NOISE_DATATYPE oct2 = m_Noise.CubicNoise2D(BlockX * m_GenParam[i].m_HeightFreq2, BlockZ * m_GenParam[i].m_HeightFreq2) * m_GenParam[i].m_HeightAmp2;			NOISE_DATATYPE oct3 = m_Noise.CubicNoise2D(BlockX * m_GenParam[i].m_HeightFreq3, BlockZ * m_GenParam[i].m_HeightFreq3) * m_GenParam[i].m_HeightAmp3;			Height += BiomeCounts[i] * (m_GenParam[i].m_BaseHeight + oct1 + oct2 + oct3);		}		NOISE_DATATYPE res = Height / Sum;		return std::min((NOISE_DATATYPE)250, std::max(res, (NOISE_DATATYPE)5));	}		// No known biome around? Weird. Return a bogus value:	ASSERT(!"cHeiGenBiomal: Biome sum failed, no known biome around");	return 5;}
开发者ID:Hillvith,项目名称:MCServer,代码行数:53,


示例7: subpage_stats

/* * Print the allocated/freed map of a single kernel heap page. */staticvoidsubpage_stats(struct pageref *pr){	vaddr_t prpage, fla;	struct freelist *fl;	int blktype;	unsigned i, n, index;	uint32_t freemap[PAGE_SIZE / (SMALLEST_SUBPAGE_SIZE*32)];	checksubpage(pr);	KASSERT(spinlock_do_i_hold(&kmalloc_spinlock));	/* clear freemap[] */	for (i=0; i<ARRAYCOUNT(freemap); i++) {		freemap[i] = 0;	}	prpage = PR_PAGEADDR(pr);	blktype = PR_BLOCKTYPE(pr);	KASSERT(blktype >= 0 && blktype < NSIZES);	/* compute how many bits we need in freemap and assert we fit */	n = PAGE_SIZE / sizes[blktype];	KASSERT(n <= 32 * ARRAYCOUNT(freemap));	if (pr->freelist_offset != INVALID_OFFSET) {		fla = prpage + pr->freelist_offset;		fl = (struct freelist *)fla;		for (; fl != NULL; fl = fl->next) {			fla = (vaddr_t)fl;			index = (fla-prpage) / sizes[blktype];			KASSERT(index<n);			freemap[index/32] |= (1<<(index%32));		}	}	kprintf("at 0x%08lx: size %-4lu  %u/%u free/n",		(unsigned long)prpage, (unsigned long) sizes[blktype],		(unsigned) pr->nfree, n);	kprintf("   ");	for (i=0; i<n; i++) {		int val = (freemap[i/32] & (1<<(i%32)))!=0;		kprintf("%c", val ? '.' : '*');		if (i%64==63 && i<n-1) {			kprintf("/n   ");		}	}	kprintf("/n");}
开发者ID:arroyobrian,项目名称:truckload,代码行数:54,


示例8: ASSERT

void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_Socket, sockaddr * a_Addr, int a_Len, void * a_Self){	// Cast to true self:	cServerHandleImpl * Self = reinterpret_cast<cServerHandleImpl *>(a_Self);	ASSERT(Self != nullptr);	ASSERT(Self->m_SelfPtr != nullptr);	// Get the textual IP address and port number out of a_Addr:	char IPAddress[128];	UInt16 Port = 0;	switch (a_Addr->sa_family)	{		case AF_INET:		{			sockaddr_in * sin = reinterpret_cast<sockaddr_in *>(a_Addr);			evutil_inet_ntop(AF_INET, &(sin->sin_addr), IPAddress, ARRAYCOUNT(IPAddress));			Port = ntohs(sin->sin_port);			break;		}		case AF_INET6:		{			sockaddr_in6 * sin6 = reinterpret_cast<sockaddr_in6 *>(a_Addr);			evutil_inet_ntop(AF_INET6, &(sin6->sin6_addr), IPAddress, ARRAYCOUNT(IPAddress));			Port = ntohs(sin6->sin6_port);			break;		}	}	// Call the OnIncomingConnection callback to get the link callbacks to use:	cTCPLink::cCallbacksPtr LinkCallbacks = Self->m_ListenCallbacks->OnIncomingConnection(IPAddress, Port);	if (LinkCallbacks == nullptr)	{		// Drop the connection:		evutil_closesocket(a_Socket);		return;	}	// Create a new cTCPLink for the incoming connection:	cTCPLinkImplPtr Link = std::make_shared<cTCPLinkImpl>(a_Socket, LinkCallbacks, Self->m_SelfPtr, a_Addr, static_cast<socklen_t>(a_Len));	{		cCSLock Lock(Self->m_CS);		Self->m_Connections.push_back(Link);	}  // Lock(m_CS)	LinkCallbacks->OnLinkCreated(Link);	Link->Enable(Link);	// Call the OnAccepted callback:	Self->m_ListenCallbacks->OnAccepted(*Link);}
开发者ID:502647092,项目名称:cuberite,代码行数:49,


示例9: GetAppleBushImage

void GetAppleBushImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks){	a_OtherBlocks.reserve(3 + ARRAYCOUNT(BigO2) + ARRAYCOUNT(BigO1));		int hei = a_BlockY;	a_LogBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LOG, E_META_LOG_JUNGLE));	PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);	hei++;		a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));	PushCoordBlocks(a_BlockX, hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);	hei++;		a_OtherBlocks.push_back(sSetBlock(a_BlockX, hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:15,


示例10: testBackAndForth

/** Tests that rotating a direction in one way and then the opposite way produces the original direction. */static void testBackAndForth(){	for (size_t i = 0; i < ARRAYCOUNT(g_AllDirections); ++i)	{		auto rotated = cPiece::cConnector::RotateDirectionCW(g_AllDirections[i]);		auto back = cPiece::cConnector::RotateDirectionCCW(rotated);		EXPECT(back == g_AllDirections[i]);	}	for (size_t i = 0; i < ARRAYCOUNT(g_AllDirections); ++i)	{		auto rotated = cPiece::cConnector::RotateDirectionCCW(g_AllDirections[i]);		auto back = cPiece::cConnector::RotateDirectionCW(rotated);		EXPECT(back == g_AllDirections[i]);	}}
开发者ID:Pokechu22,项目名称:cuberite,代码行数:16,


示例11: GenHeightMap

void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap){	if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ))	{		for (unsigned int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)		{			a_HeightMap[i] = 0;		}		return;	}	PrepareState(a_ChunkX, a_ChunkZ);	int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);	for (int z = 0; z < cChunkDef::Width; z++)	{		for (int x = 0; x < cChunkDef::Width; x++)		{			cChunkDef::SetHeight(a_HeightMap, x, z, MaxY);			for (int y = MaxY; y > 0; y--)			{				if (m_NoiseArray[y * 17 * 17 + z * 17 + x] <= 0)				{					cChunkDef::SetHeight(a_HeightMap, x, z, y);					break;				}			}  // for y		}  // for x	}  // for z}
开发者ID:stpinker,项目名称:MCServer,代码行数:30,


示例12: GenBiomes

void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap){	for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)	{		a_BiomeMap[i] = m_Biome;	}}
开发者ID:FX-Master,项目名称:MCServer,代码行数:7,


示例13: BuildTemperatureHumidityMaps

void cBioGenMultiStepMap::BuildTemperatureHumidityMaps(int a_ChunkX, int a_ChunkZ, IntMap & a_TemperatureMap, IntMap & a_HumidityMap){	// Linear interpolation over 8x8 blocks; use double for better precision:	DblMap TemperatureMap;	DblMap HumidityMap;	for (int z = 0; z < 17; z += 8)	{		float NoiseCoordZ = (float)(a_ChunkZ * cChunkDef::Width + z) / m_LandBiomesSize;		for (int x = 0; x < 17; x += 8)		{			float NoiseCoordX = (float)(a_ChunkX * cChunkDef::Width + x) / m_LandBiomesSize;					double NoiseT = m_Noise1.CubicNoise2D(    NoiseCoordX,     NoiseCoordZ);			NoiseT += 0.5 * m_Noise2.CubicNoise2D(2 * NoiseCoordX, 2 * NoiseCoordZ);			NoiseT += 0.1 * m_Noise3.CubicNoise2D(8 * NoiseCoordX, 8 * NoiseCoordZ);			TemperatureMap[x + 17 * z] = NoiseT;			double NoiseH = m_Noise4.CubicNoise2D(    NoiseCoordX,     NoiseCoordZ);			NoiseH += 0.5 * m_Noise5.CubicNoise2D(2 * NoiseCoordX, 2 * NoiseCoordZ);			NoiseH += 0.1 * m_Noise6.CubicNoise2D(8 * NoiseCoordX, 8 * NoiseCoordZ);			HumidityMap[x + 17 * z] = NoiseH;		}  // for x	}  // for z	LinearUpscale2DArrayInPlace<17, 17, 8, 8>(TemperatureMap);	LinearUpscale2DArrayInPlace<17, 17, 8, 8>(HumidityMap);		// Re-map into integral values in [0 .. 255] range:	for (size_t idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++)	{		a_TemperatureMap[idx] = std::max(0, std::min(255, (int)(128 + TemperatureMap[idx] * 128)));		a_HumidityMap[idx]    = std::max(0, std::min(255, (int)(128 + HumidityMap[idx]    * 128)));	}}
开发者ID:FX-Master,项目名称:MCServer,代码行数:33,


示例14: DimensionToString

AString DimensionToString(eDimension a_Dimension){	// Decode using a built-in map:	static struct	{		eDimension m_Dimension;		const char * m_String;	} DimensionMap[] =	{		{ dimOverworld, "Overworld" },		{ dimNether, "Nether" },		{ dimEnd, "End" },	};	for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++)	{		if (DimensionMap[i].m_Dimension == a_Dimension)		{			return DimensionMap[i].m_String;		}	}  // for i - DimensionMap[]	// Not found	LOGWARNING("Unknown dimension: /"%i/". Setting to Overworld", static_cast<int>(a_Dimension));	return "Overworld";}
开发者ID:36451,项目名称:MCServer,代码行数:26,


示例15: GenHeightMap

void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap){	for (size_t i = 0; i < ARRAYCOUNT(a_HeightMap); i++)	{		a_HeightMap[i] = m_Height;	}}
开发者ID:JABirchall,项目名称:MCServer,代码行数:7,


示例16: CanStartFireInBlock

bool cFireSimulator::CanStartFireInBlock(cChunk * a_NearChunk, int a_RelX, int a_RelY, int a_RelZ){	BLOCKTYPE  BlockType;	NIBBLETYPE BlockMeta;	if (!a_NearChunk->UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockType, BlockMeta))	{		// The chunk is not accessible		return false;	}		if (BlockType != E_BLOCK_AIR)	{		// Only an air block can be replaced by a fire block		return false;	}		for (size_t i = 0; i < ARRAYCOUNT(gNeighborCoords); i++)	{		if (!a_NearChunk->UnboundedRelGetBlock(a_RelX + gNeighborCoords[i].x, a_RelY + gNeighborCoords[i].y, a_RelZ + gNeighborCoords[i].z, BlockType, BlockMeta))		{			// Neighbor inaccessible, skip it while evaluating			continue;		}		if (IsFuel(BlockType))		{			return true;		}	}  // for i - Coords[]	return false;}
开发者ID:Haxi52,项目名称:cuberite,代码行数:30,


示例17: AutoGlobalContext

void AutowiringEnclosure::OnTestEnd(const testing::TestInfo& info) {  // Verify we can grab the test case back out and that the pointer is correct:  Autowired<TestInfoProxy> ti;  Autowired<AutowiringEnclosureExceptionFilter> ecef;  auto ctxt = ecef ? ecef->GetContext() : nullptr;  // Unconditionally reset the global context as the current context  AutoGlobalContext()->SetCurrent();  // Global initialization tests are special, we don't bother checking closure principle on them:  if(!strcmp("GlobalInitTest", info.test_case_name()))    return;  // Need to make sure we got back our exception filter before continuing:  ASSERT_TRUE(ecef.IsAutowired()) << "Failed to find the enclosed context exception filter; unit test may have incorrectly reset the enclosing context before returning";  // Now try to tear down the test context enclosure:  ctxt->SignalShutdown();  // Do not allow teardown to take more than 250 milliseconds or so  if(!ctxt->Wait(std::chrono::milliseconds(250))) {    // Critical error--took too long to tear down    assert(false);  }  static const char s_autothrow[] = "AUTOTHROW_";  if(!strncmp(s_autothrow, info.name(), ARRAYCOUNT(s_autothrow) - 1))    // Throw expected, end here    return;  // If an exception occurred somewhere, report it:  ASSERT_FALSE(ecef->m_excepted)    << "An unhandled exception occurred in this context" << std::endl    << "[" << (ecef->m_ti ? ecef->m_ti->name() : "unknown") << "] " << ecef->m_what;}
开发者ID:cuculesa,项目名称:autowiring,代码行数:35,


示例18: FillColumnPattern

void cCompoGenBiomal::FillColumnClay(int a_RelX, int a_RelZ, int a_Height, cChunkDef::BlockTypes & a_BlockTypes){	BLOCKTYPE Pattern[] =	{		E_BLOCK_HARDENED_CLAY,		E_BLOCK_HARDENED_CLAY,		E_BLOCK_HARDENED_CLAY,		E_BLOCK_HARDENED_CLAY,	} ;	FillColumnPattern(a_RelX, a_RelZ, a_Height, a_BlockTypes, Pattern, ARRAYCOUNT(Pattern));		for (int y = a_Height - ARRAYCOUNT(Pattern); y > 0; y--)	{		cChunkDef::SetBlock(a_BlockTypes, a_RelX, y, a_RelZ, E_BLOCK_STONE);	}}
开发者ID:Solexid,项目名称:MCServer,代码行数:16,


示例19: NodeAddModule

void NodeAddModule(const tchar_t* Path,int Id,int64_t Date,bool_t Load,bool_t Tmp){	context* p = Context();	LockEnter(p->NodeLock);	if (ArrayAppend(&p->NodeModule,NULL,sizeof(nodemodule),256))	{		int No = ARRAYCOUNT(p->NodeModule,nodemodule)-1;		nodemodule* Module = ARRAYBEGIN(p->NodeModule,nodemodule)+No;		memset(Module,0,sizeof(nodemodule));		Module->Id = Id;		Module->Date = Date;		Module->Tmp = Tmp;		StringAdd(1,MODULE_PATH,No,Path);		if (Load)		{			p->LoadModuleNo = No;			Module->Module = NodeLoadModule(Path,&Module->Id,&Module->Func,&Module->Db);			p->LoadModuleNo = 0;#ifdef PLUGINCLEANUP			FreeModule(Module);#endif		}	}	LockLeave(p->NodeLock);}
开发者ID:Jsoucek,项目名称:q3ce,代码行数:26,


示例20: StringToBiome

EMCSBiome StringToBiome(const AString & a_BiomeString){	// If it is a number, return it:	int res = atoi(a_BiomeString.c_str());	if ((res != 0) || (a_BiomeString.compare("0") == 0))	{		if ((res >= biFirstBiome) && (res < biNumBiomes))		{			return (EMCSBiome)res;		}		else if ((res >= biFirstVariantBiome) && (res < biNumVariantBiomes))		{			return (EMCSBiome)res;		}		// It was an invalid number		return biInvalidBiome;	}		for (size_t i = 0; i < ARRAYCOUNT(g_BiomeMap); i++)	{		if (NoCaseCompare(g_BiomeMap[i].m_String, a_BiomeString) == 0)		{			return g_BiomeMap[i].m_Biome;		}	}  // for i - BiomeMap[]	return biInvalidBiome;}
开发者ID:DjKiDD,项目名称:MCServer,代码行数:27,


示例21: FindModule

static NOINLINE int FindModule(context* p,const tchar_t* Path,int Id){	// important to find from the begining for Palm OS 	// so the exising plugins are found first	int No,Count;	int Result = -1;	LockEnter(p->NodeLock);	Count = ARRAYCOUNT(p->NodeModule,nodemodule);	if (!Path) Path = T("");	for (No=0;No<Count;++No)	{		bool_t SameId = ARRAYBEGIN(p->NodeModule,nodemodule)[No].Id == Id;		bool_t SameName = TcsICmp(Path,StringDef(MODULE_PATH,No))==0;		if (SameId && Id!=0) // same Id means same module			SameName = 1;		if (SameName && !Id)			SameId = 1;		if (SameId && SameName)		{			Result = No;			break;		}	}	LockLeave(p->NodeLock);	return Result;}
开发者ID:Jsoucek,项目名称:q3ce,代码行数:30,


示例22: GetBurnStepTime

int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ){	if (a_RelY > 0)	{		BLOCKTYPE BlockBelow = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);		if (IsForever(BlockBelow))		{			// Is burning atop of netherrack, burn forever (re-check in 10 sec)			return 10000;		}		if (IsFuel(BlockBelow))		{			return m_BurnStepTimeFuel;		}	}	if ((a_RelY < cChunkDef::Height - 1) && IsFuel(a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ)))	{		return m_BurnStepTimeFuel;	}		for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++)	{		BLOCKTYPE  BlockType;		NIBBLETYPE BlockMeta;		if (a_Chunk->UnboundedRelGetBlock(a_RelX + gCrossCoords[i].x, a_RelY, a_RelZ + gCrossCoords[i].z, BlockType, BlockMeta))		{			if (IsFuel(BlockType))			{				return m_BurnStepTimeFuel;			}		}	}  // for i - gCrossCoords[]	return m_BurnStepTimeNonfuel;}
开发者ID:Xury,项目名称:MCServer,代码行数:34,


示例23:

void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap){	for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)	{		a_BiomeMap[i] = biExtremeHills;	}}
开发者ID:DjKiDD,项目名称:MCServer,代码行数:7,


示例24: cmd_mount

staticintcmd_mount(int nargs, char **args){	char *fstype;	char *device;	unsigned i;	if (nargs != 3) {		kprintf("Usage: mount fstype device:/n");		return EINVAL;	}	fstype = args[1];	device = args[2];	/* Allow (but do not require) colon after device name */	if (device[strlen(device)-1]==':') {		device[strlen(device)-1] = 0;	}	for (i=0; i<ARRAYCOUNT(mounttable); i++) {		if (!strcmp(mounttable[i].name, fstype)) {			return mounttable[i].func(device);		}	}	kprintf("Unknown filesystem type %s/n", fstype);	return EINVAL;}
开发者ID:prasad223,项目名称:os161_Docker,代码行数:29,


示例25: StringToType

cObjective::eType cObjective::StringToType(const AString & a_Name){	static struct	{		eType m_Type;		const char * m_String;	} TypeMap [] =	{		{otDummy,              "dummy"              },		{otDeathCount,         "deathCount"         },		{otPlayerKillCount,    "playerKillCount"    },		{otTotalKillCount,     "totalKillCount"     },		{otHealth,             "health"             },		{otAchievement,        "achievement"        },		{otStat,               "stat"               },		{otStatItemCraft,      "stat.craftItem"     },		{otStatItemUse,        "stat.useItem"       },		{otStatItemBreak,      "stat.breakItem"     },		{otStatBlockMine,      "stat.mineBlock"     },		{otStatEntityKill,     "stat.killEntity"    },		{otStatEntityKilledBy, "stat.entityKilledBy"}	};	for (size_t i = 0; i < ARRAYCOUNT(TypeMap); i++)	{		if (NoCaseCompare(TypeMap[i].m_String, a_Name) == 0)		{			return TypeMap[i].m_Type;		}	}  // for i - TypeMap[]	return otDummy;}
开发者ID:ChriPiv,项目名称:MCServer,代码行数:31,


示例26: ASSERT

void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef){	ASSERT(a_CharMapDef != NULL);		// Initialize the charmap to all-invalid values:	for (size_t i = 0; i < ARRAYCOUNT(a_CharMapOut); i++)	{		a_CharMapOut[i].m_BlockType = 0;		a_CharMapOut[i].m_BlockMeta = 16;  // Mark unassigned entries with a meta that is impossible otherwise	}		// Process the lines in the definition:	AStringVector Lines = StringSplitAndTrim(a_CharMapDef, "/n");	for (AStringVector::const_iterator itr = Lines.begin(), end = Lines.end(); itr != end; ++itr)	{		AStringVector CharDef = StringSplitAndTrim(*itr, ":");		size_t NumElements = CharDef.size();		if ((NumElements < 2) || CharDef[0].empty() || CharDef[1].empty())		{			LOGWARNING("Bad prefab CharMap definition line: /"%s/", skipping.", itr->c_str());			continue;		}		unsigned char Src = (unsigned char)CharDef[0][0];		ASSERT(a_CharMapOut[Src].m_BlockMeta == 16);  // This letter has not been assigned yet?		a_CharMapOut[Src].m_BlockType = (BLOCKTYPE)atoi(CharDef[1].c_str());		NIBBLETYPE BlockMeta = 0;		if ((NumElements >= 3) && !CharDef[2].empty())		{			BlockMeta = (NIBBLETYPE)atoi(CharDef[2].c_str());			ASSERT((BlockMeta <= 15));		}		a_CharMapOut[Src].m_BlockMeta = BlockMeta;	}  // for itr - Lines[]}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:34,


示例27: HeightMap

    virtual void HeightMap(const cChunkDef::HeightMap * a_Heightmap) override    {        // Copy the entire heightmap, distribute it into the 3x3 chunk blob:        typedef struct {            HEIGHTTYPE m_Row[16];        } ROW;        const ROW * InputRows  = reinterpret_cast<const ROW *>(a_Heightmap);        ROW * OutputRows = reinterpret_cast<ROW *>(m_HeightMap);        int InputIdx = 0;        int OutputIdx = m_ReadingChunkX + m_ReadingChunkZ * cChunkDef::Width * 3;        for (int z = 0; z < cChunkDef::Width; z++)        {            OutputRows[OutputIdx] = InputRows[InputIdx++];            OutputIdx += 3;        }  // for z        // Find the highest block in the entire chunk, use it as a base for m_MaxHeight:        HEIGHTTYPE MaxHeight = m_MaxHeight;        for (size_t i = 0; i < ARRAYCOUNT(*a_Heightmap); i++)        {            if ((*a_Heightmap)[i] > MaxHeight)            {                MaxHeight = (*a_Heightmap)[i];            }        }        m_MaxHeight = MaxHeight;    }
开发者ID:4264,项目名称:cuberite,代码行数:27,


示例28: TestError_s

void TestError_s( void ){    wchar_t     error[ 256 ];    size_t      errlen;    int     violations = NumViolations;    errlen = wcserrorlen_s( EBADF );    VERIFY( errlen != 0 );    VERIFY( wcserror_s( error, ARRAYCOUNT( error ), EBADF ) == 0 ); /* get an error string */    VERIFY( wcslen( error ) != 0 );    VERIFY( wcserror_s( error, errlen - 1, EBADF ) != 0 ); /* truncated error string */    VERIFY( wcscmp( error + errlen - 5, L"..." ) == 0 ); /* really truncated? */    VERIFY( NumViolations == violations );    //rt constraints    VERIFY( wcserror_s( NULL, errlen - 1, EBADF ) != 0 );    VERIFY( NumViolations == ++violations );    VERIFY( wcserror_s( error, 0, EBADF ) != 0 );    VERIFY( NumViolations == ++violations );#if RSIZE_MAX != SIZE_MAX    VERIFY( wcserror_s( error, ~0, EBADF ) != 0 );    VERIFY( NumViolations == ++violations );#endif}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:30,


示例29: CreateStructure

cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, int a_OriginZ){	// Generate the biomes for the chunk surrounding the origin:	int ChunkX, ChunkZ;	cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ);	cChunkDef::BiomeMap Biomes;	m_BiomeGen.GenBiomes(ChunkX, ChunkZ, Biomes);	// Check if all the biomes are ocean:	// If just one is not, no base is created, because it's likely that an unfriendly biome is too close	for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)	{		switch (Biomes[i])		{			case biOcean:			case biDeepOcean:			{				// These biomes allow underwater bases				break;			}			default:			{				// base-unfriendly biome, bail out with zero structure:				return cStructurePtr();			}		}  // switch (Biomes[i])	}  // for i - Biomes[]	// Create a base based on the chosen prefabs:	return cStructurePtr(new cUnderwaterBase(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize));}
开发者ID:Kortak,项目名称:MCServer,代码行数:31,



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


C++ ARRAYLEN函数代码示例
C++ AROW函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。