TODO Not working very well yet :s
| 119 | |
| 120 | // TODO Not working very well yet :s |
| 121 | Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a_Over) |
| 122 | { |
| 123 | if ((a_Y < 0) || (a_Y >= cChunkDef::Height)) |
| 124 | { |
| 125 | return NONE; |
| 126 | } |
| 127 | BLOCKTYPE BlockID = m_World.GetBlock(a_X, a_Y, a_Z); |
| 128 | if (!IsAllowedBlock(BlockID)) // No Fluid -> No Flowing direction :D |
| 129 | { |
| 130 | return NONE; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | Disabled because of causing problems and being useless atm |
| 135 | char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); //If there is nothing or fluid below it -> dominating flow is down :D |
| 136 | if (BlockBelow == E_BLOCK_AIR || IsAllowedBlock(BlockBelow)) |
| 137 | return Y_MINUS; |
| 138 | */ |
| 139 | |
| 140 | NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); //Current Block Meta so only lower points will be counted |
| 141 | int X = 0, Z = 0; //Lowest Pos will be stored here |
| 142 | |
| 143 | if (IsAllowedBlock(m_World.GetBlock(a_X, a_Y + 1, a_Z)) && a_Over) //check for upper block to flow because this also affects the flowing direction |
| 144 | { |
| 145 | return GetFlowingDirection(a_X, a_Y + 1, a_Z, false); |
| 146 | } |
| 147 | |
| 148 | std::vector< Vector3i * > Points; |
| 149 | |
| 150 | Points.reserve(4); //Already allocate 4 places :D |
| 151 | |
| 152 | //add blocks around the checking pos |
| 153 | Points.push_back(new Vector3i(a_X - 1, a_Y, a_Z)); |
| 154 | Points.push_back(new Vector3i(a_X + 1, a_Y, a_Z)); |
| 155 | Points.push_back(new Vector3i(a_X, a_Y, a_Z + 1)); |
| 156 | Points.push_back(new Vector3i(a_X, a_Y, a_Z - 1)); |
| 157 | |
| 158 | for (std::vector<Vector3i *>::iterator it = Points.begin(); it < Points.end(); it++) |
| 159 | { |
| 160 | Vector3i *Pos = (*it); |
| 161 | char BlockID = m_World.GetBlock(Pos->x, Pos->y, Pos->z); |
| 162 | if(IsAllowedBlock(BlockID)) |
| 163 | { |
| 164 | char Meta = m_World.GetBlockMeta(Pos->x, Pos->y, Pos->z); |
| 165 | |
| 166 | if(Meta > LowestPoint) |
| 167 | { |
| 168 | LowestPoint = Meta; |
| 169 | X = Pos->x; |
| 170 | Z = Pos->z; |
| 171 | } |
| 172 | }else if(BlockID == E_BLOCK_AIR) |
| 173 | { |
| 174 | LowestPoint = 9; //This always dominates |
| 175 | X = Pos->x; |
| 176 | Z = Pos->z; |
| 177 | |
| 178 | } |
no test coverage detected