04-17-2014, 05:11 AM 
		
	
	
		@xoft
What is wrong with this code?
	
	
	
	
What is wrong with this code?
int Bookshelves = 0;
	cBlockArea Area;
	Area.Read(a_World, PosX - 2, PosX + 2, PosY, PosY + 1, PosZ - 2, PosZ + 2);
	static const struct
	{
		int m_BookX, m_BookY, m_BookZ;  // Coords to check for bookcases
		int m_AirX, m_AirY, m_AirZ;  // Coords to check for air; if not air, the bookcase won't be counted
	} CheckCoords[] =
	{
		{ -2, 0, -2, -1, 0, -1 },  // Bookcase at {-2, 0, -2}, air at {-1, 0, -1}
		{ -1, 0, -2, -1, 0, -1 },  // Bookcase at {-1, 0, -2}, air at {-1, 0, -1}
		{ 0, 0, -2, 0, 0, -1 },    // Bookcase at {0, 0, -2}, air at {0, 0, -1}
		{ 1, 0, -2, 1, 0, -1 },    // Bookcase at {1, 0, -2}, air at {1, 0, -1}
		{ 2, 0, -2, 1, 0, -1 },    // Bookcase at {2, 0, -2}, air at {1, 0, -1}
		{ 2, 0, -1, 1, 0, -1 },    // Bookcase at {2, 0, -1}, air at {1, 0, -1}
		{ 2, 0, 0, 1, 0, 0 },      // Bookcase at {2, 0, 0}, air at {1, 0, 0}
		{ 2, 0, 1, 1, 0, 1 },      // Bookcase at {2, 0, 1}, air at {1, 0, 1}
		{ 2, 0, 2, 1, 0, 1 },      // Bookcase at {2, 0, 2}, air at {1, 0, 1}
		{ 1, 0, 2, 1, 0, 1 },      // Bookcase at {1, 0, 2}, air at {1, 0, 1}
		{ 0, 0, 2, 0, 0, 1 },      // Bookcase at {0, 0, 2}, air at {0, 0, 1}
		{ -1, 0, 2, -1, 0, 1 },    // Bookcase at {-1, 0, 2}, air at {-1, 0, 1}
		{ -2, 0, 2, -1, 0, 1 },    // Bookcase at {-2, 0, 2}, air at {-1, 0, 1}
		{ -2, 0, 1, -1, 0, 1 },    // Bookcase at {-2, 0, 1}, air at {-1, 0, 1}
		{ -2, 0, 0, -1, 0, 0 },    // Bookcase at {-2, 0, 0}, air at {-1, 0, 0}
		{ -2, 0, -1, -1, 0, -1 },   // Bookcase at {-2, 0, -1}, air at {-1, 0, -1}
		{ -2, 1, -2, -1, 1, -1 },  // Bookcase at {-2, 1, -2}, air at {-1, 1, -1}
		{ -1, 1, -2, -1, 1, -1 },  // Bookcase at {-1, 1, -2}, air at {-1, 1, -1}
		{ 0, 1, -2, 0, 1, -1 },    // Bookcase at {0, 1, -2}, air at {0, 1, -1}
		{ 1, 1, -2, 1, 1, -1 },    // Bookcase at {1, 1, -2}, air at {1, 1, -1}
		{ 2, 1, -2, 1, 1, -1 },    // Bookcase at {2, 1, -2}, air at {1, 1, -1}
		{ 2, 1, -1, 1, 1, -1 },    // Bookcase at {2, 1, -1}, air at {1, 1, -1}
		{ 2, 1, 0, 1, 1, 0 },      // Bookcase at {2, 1, 0}, air at {1, 1, 0}
		{ 2, 1, 1, 1, 1, 1 },      // Bookcase at {2, 1, 1}, air at {1, 1, 1}
		{ 2, 1, 2, 1, 1, 1 },      // Bookcase at {2, 1, 2}, air at {1, 1, 1}
		{ 1, 1, 2, 1, 1, 1 },      // Bookcase at {1, 1, 2}, air at {1, 1, 1}
		{ 0, 1, 2, 0, 1, 1 },      // Bookcase at {0, 1, 2}, air at {0, 1, 1}
		{ -1, 1, 2, -1, 1, 1 },    // Bookcase at {-1, 1, 2}, air at {-1, 1, 1}
		{ -2, 1, 2, -1, 1, 1 },    // Bookcase at {-2, 1, 2}, air at {-1, 1, 1}
		{ -2, 1, 1, -1, 1, 1 },    // Bookcase at {-2, 1, 1}, air at {-1, 1, 1}
		{ -2, 1, 0, -1, 1, 0 },    // Bookcase at {-2, 1, 0}, air at {-1, 1, 0}
		{ -2, 1, -1, -1, 1, -1 }   // Bookcase at {-2, 1, -1}, air at {-1, 1, -1}
	};
	for (size_t i = 0; i < ARRAYCOUNT(CheckCoords); i++)
	{
		if (
			(Area.GetRelBlockType(CheckCoords[i].m_AirX, CheckCoords[i].m_AirY, CheckCoords[i].m_AirZ) == E_BLOCK_AIR) &&  // There's air in the checkspot
			(Area.GetRelBlockType(CheckCoords[i].m_BookX, CheckCoords[i].m_BookY, CheckCoords[i].m_BookZ) == E_BLOCK_BOOKCASE)  // There's bookcase in the wanted place
			)
		{
			Bookshelves++;
			cRoot::Get()->BroadcastChat("Bookshelf");
		}
	}  // for i - CheckCoords
	
