Me and Owl must of posted at the exact same time. I didn't even see it, but now I do. I think Owl's is best also
combining it like he did also saves some computing time. Since it just reads from memory and doesn't have to calculate.
What I posted is exactly what teutonicus proposed but I just made the calculations outside the function call for readability's sake. I don't think it's gonna be faster and if it is it'd be a despicable improvement, but I've learned to be willing to trade a few cycles for readability and code maintainability
You might want to explore what Brother Bob proposed: Implementing algebraic vectors into your code:
class vector3
{
public: // Make it right
int x;
int y;
int z;
};
// make a method in class world that combines blockGetAmount and blockExists
// the offset seem to be inside world so you don't even need to pass it as an argument.
bool World::BlockValidExists(vector3& v_pos, vector3& v_xof)
{
return (blockExists (v_pos, v_xof) && (blockGetAmount(v_pos, v_xof)!=-1));
}
// and then ...
vector3 xof_vector (world0->xOffset-location.x, world0->yOffset-location.y, world0->zOffset-location.z);
vector3 pos_vector (x-1, y, z);
if (world0->BlockValidExists(pos_vector, xof_vector))
{