Builds a list of mirror faces for each room and allocs memory accordingly
| 3655 | } |
| 3656 | // Builds a list of mirror faces for each room and allocs memory accordingly |
| 3657 | void ConsolidateMineMirrors() { |
| 3658 | int i, t; |
| 3659 | mprintf(0, "Consolidating mine mirrors!\n"); |
| 3660 | for (i = 0; i < MAX_ROOMS; i++) { |
| 3661 | room *rp = &Rooms[i]; |
| 3662 | if (!rp->used) |
| 3663 | continue; |
| 3664 | if (rp->mirror_faces_list) { |
| 3665 | mem_free(rp->mirror_faces_list); |
| 3666 | rp->mirror_faces_list = NULL; |
| 3667 | rp->num_mirror_faces = 0; |
| 3668 | } |
| 3669 | if (rp->mirror_face == -1) |
| 3670 | continue; |
| 3671 | // Count the number of faces that have the same texture as the mirror face |
| 3672 | int num_mirror_faces = 0; |
| 3673 | for (t = 0; t < rp->num_faces; t++) { |
| 3674 | face *fp = &rp->faces[t]; |
| 3675 | if (fp->tmap == rp->faces[rp->mirror_face].tmap) |
| 3676 | num_mirror_faces++; |
| 3677 | } |
| 3678 | if (num_mirror_faces == 0) { |
| 3679 | // No faces found? Weird. |
| 3680 | rp->mirror_face = 0; |
| 3681 | continue; |
| 3682 | } |
| 3683 | rp->mirror_faces_list = (uint16_t *)mem_malloc(num_mirror_faces * sizeof(uint16_t)); |
| 3684 | ASSERT(rp->mirror_faces_list); |
| 3685 | rp->num_mirror_faces = num_mirror_faces; |
| 3686 | // Now go through and fill in our list |
| 3687 | int count = 0; |
| 3688 | for (t = 0; t < rp->num_faces; t++) { |
| 3689 | face *fp = &rp->faces[t]; |
| 3690 | if (fp->tmap == rp->faces[rp->mirror_face].tmap) |
| 3691 | rp->mirror_faces_list[count++] = t; |
| 3692 | } |
| 3693 | } |
| 3694 | } |
| 3695 | |
| 3696 | /* |
| 3697 | // Takes a face and adds the appropriate vertices for drawing in the fog zone |
no outgoing calls
no test coverage detected