| 500 | } |
| 501 | |
| 502 | int SearchQuadTree(int x1, int y1, int x2, int y2, int dir, int *ccount) { |
| 503 | int n[4], x[4], z[4]; |
| 504 | int i, first; |
| 505 | int anded; |
| 506 | int answer; |
| 507 | int si = 0, level; |
| 508 | int stack_x1[200]; |
| 509 | int stack_y1[200]; |
| 510 | int stack_x2[200]; |
| 511 | int stack_y2[200]; |
| 512 | int stack_level[200]; |
| 513 | float testdist = VisibleTerrainZ; |
| 514 | uint8_t ymin_int[4], ymax_int[4]; |
| 515 | int close; |
| 516 | uint8_t same_side; |
| 517 | uint8_t check_portal = 0; |
| 518 | g3Point *pnt; |
| 519 | int use_occlusion = 0; |
| 520 | int src_occlusion_index; |
| 521 | |
| 522 | if ((Terrain_checksum + 1) == Terrain_occlusion_checksum && !Terrain_from_mine) { |
| 523 | use_occlusion = 1; |
| 524 | int oz = (Viewer_object->pos.z / TERRAIN_SIZE) / OCCLUSION_SIZE; |
| 525 | int ox = (Viewer_object->pos.x / TERRAIN_SIZE) / OCCLUSION_SIZE; |
| 526 | |
| 527 | if (oz < 0 || oz >= OCCLUSION_SIZE || ox < 0 || ox >= OCCLUSION_SIZE) |
| 528 | use_occlusion = 0; |
| 529 | |
| 530 | src_occlusion_index = oz * OCCLUSION_SIZE + ox; |
| 531 | } |
| 532 | |
| 533 | PUSH_STACK_TREE(x1, y1, x2, y2, 0); |
| 534 | |
| 535 | while (si > 0) { |
| 536 | TotalDepth++; |
| 537 | |
| 538 | POP_STACK_TREE(); |
| 539 | ASSERT((x2 - x1) == (y2 - y1)); |
| 540 | |
| 541 | if ((x2 - x1) == 16) { |
| 542 | if (use_occlusion) { |
| 543 | int dest_occlusion_index = ((y1 / OCCLUSION_SIZE) * OCCLUSION_SIZE); |
| 544 | dest_occlusion_index += x1 / OCCLUSION_SIZE; |
| 545 | |
| 546 | int occ_byte = dest_occlusion_index / 8; |
| 547 | int occ_bit = dest_occlusion_index % 8; |
| 548 | |
| 549 | if (!(Terrain_occlusion_map[src_occlusion_index][occ_byte] & (1 << occ_bit))) |
| 550 | continue; |
| 551 | } |
| 552 | check_portal = 1; |
| 553 | } |
| 554 | |
| 555 | else if ((x2 - x1) == 8) { |
| 556 | answer = EvaluateBlock(x1, y1, MAX_TERRAIN_LOD - 4); |
| 557 | if (answer == -1) |
| 558 | continue; |
| 559 | else if (answer == 1) { |
no test coverage detected