Creates or destroys a player camera depending on what the situation calls for
| 1749 | |
| 1750 | // Creates or destroys a player camera depending on what the situation calls for |
| 1751 | void SetupPlayerCamera() { |
| 1752 | object *playerobj = &Objects[Players[Player_num].objnum]; |
| 1753 | |
| 1754 | if (Player_has_camera) { |
| 1755 | if (Player_camera_objnum == -1) { |
| 1756 | // We have to create a new camera |
| 1757 | int objnum = ObjCreate(OBJ_CAMERA, 0, playerobj->roomnum, &playerobj->pos, &playerobj->orient); |
| 1758 | if (objnum < 0) { |
| 1759 | // Couldn't create a camera for some reason |
| 1760 | Player_has_camera = false; |
| 1761 | Player_camera_objnum = 0; |
| 1762 | return; |
| 1763 | } else { |
| 1764 | Player_camera_objnum = objnum; |
| 1765 | Camera_sample_index = MAX_CAMERA_SUB_SAMPLES; |
| 1766 | Player_camera_last_sample_time = 0; |
| 1767 | Player_camera_last_follow_time = 0; |
| 1768 | Camera_follow_index = 0; |
| 1769 | |
| 1770 | for (int i = 0; i < MAX_CAMERA_SAMPLES; i++) { |
| 1771 | Camera_sample_matrix[i] = playerobj->orient; |
| 1772 | Camera_sample_vectors[i] = playerobj->pos; |
| 1773 | Camera_sample_rooms[i] = playerobj->roomnum; |
| 1774 | } |
| 1775 | } |
| 1776 | } |
| 1777 | |
| 1778 | if (Viewer_object == playerobj) { |
| 1779 | // Set viewer to be camera |
| 1780 | Viewer_object = &Objects[Player_camera_objnum]; |
| 1781 | } |
| 1782 | |
| 1783 | UpdatePlayerCameraPosition(); |
| 1784 | } else { |
| 1785 | if (Player_camera_objnum != -1) { |
| 1786 | SetObjectDeadFlag(&Objects[Player_camera_objnum]); |
| 1787 | Player_camera_objnum = -1; |
| 1788 | } |
| 1789 | } |
| 1790 | } |
| 1791 | |
| 1792 | // Does actions for the given player slot |
| 1793 | void DoPlayerFrameForOne(int slot) { |
no test coverage detected