| 393 | } |
| 394 | |
| 395 | void cRandomMap::AdjacentCost(cPosition* node, std::vector< micropather::StateCost > *neighbors) { |
| 396 | const int dx[8] = { 8, 8, 0, -8, -8, -8, 0, 8 }; |
| 397 | const int dy[8] = { 0, 8, 8, 8, 0, -8, -8, -8 }; |
| 398 | const float cost[8] = { 1.0f, 1.41f, 1.0f, 1.41f, 1.0f, 1.41f, 1.0f, 1.41f }; |
| 399 | |
| 400 | for (int i = 0; i < 8; ++i) { |
| 401 | int nx = node->mX + dx[i]; |
| 402 | int ny = node->mY + dy[i]; |
| 403 | |
| 404 | if (nx < 0 || ny < 0) |
| 405 | continue; |
| 406 | |
| 407 | int pass = Passable(nx, ny); |
| 408 | if (pass > 0) { |
| 409 | if (pass == 1) |
| 410 | { |
| 411 | // Normal floor |
| 412 | micropather::StateCost nodeCost = { cPosition(nx, ny), cost[i] }; |
| 413 | neighbors->push_back(nodeCost); |
| 414 | } |
| 415 | else |
| 416 | { |
| 417 | // Normal floor |
| 418 | micropather::StateCost nodeCost = { cPosition(nx, ny), cost[i] + pass }; |
| 419 | neighbors->push_back(nodeCost); |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | void cRandomMap::PrintStateInfo(cPosition* node) { |
| 426 | printf("(%d,%d)", node->mX, node->mY); |
no test coverage detected