Places a room a short distance from the specified room & face The new room is not attached to anything Parameters: baseroomp,baseface - the new room is dropped off of this face droproom_num - the room to be dropped
| 1792 | // Parameters: baseroomp,baseface - the new room is dropped off of this face |
| 1793 | // droproom_num - the room to be dropped |
| 1794 | void DropRoom(room *baseroomp, int baseface, int droproom_num) { |
| 1795 | int roomnum; |
| 1796 | room *newroomp; |
| 1797 | vector oldcenter, facecenter, newcenter, offset; |
| 1798 | float rad; |
| 1799 | |
| 1800 | // Create a new room |
| 1801 | roomnum = GetFreeRoom(0); |
| 1802 | if (roomnum == -1) { |
| 1803 | OutrageMessageBox("Cannot drop room: No free rooms."); |
| 1804 | return; |
| 1805 | } |
| 1806 | newroomp = &Rooms[roomnum]; |
| 1807 | |
| 1808 | // Copy data to new room |
| 1809 | CopyRoom(newroomp, &Rooms[droproom_num]); |
| 1810 | |
| 1811 | // Compute offset |
| 1812 | rad = ComputeRoomBoundingSphere(&oldcenter, newroomp); |
| 1813 | #ifndef NEWEDITOR |
| 1814 | ComputeCenterPointOnFace(&facecenter, baseroomp, baseface); |
| 1815 | #else |
| 1816 | ComputeFaceBoundingCircle(&facecenter, baseroomp, baseface); |
| 1817 | #endif |
| 1818 | newcenter = facecenter - (baseroomp->faces[baseface].normal * (rad + DROP_ROOM_OFFSET)); |
| 1819 | offset = newcenter - oldcenter; |
| 1820 | |
| 1821 | // Add in offset to all the points |
| 1822 | for (int i = 0; i < newroomp->num_verts; i++) |
| 1823 | newroomp->verts[i] += offset; |
| 1824 | |
| 1825 | // Set current room to new room |
| 1826 | #ifndef NEWEDITOR |
| 1827 | Curroomp = newroomp; |
| 1828 | Curface = Curedge = Curvert = 0; |
| 1829 | Curportal = -1; |
| 1830 | #else |
| 1831 | theApp.m_pLevelWnd->SetPrim(newroomp, 0, -1, 0, 0); |
| 1832 | #endif |
| 1833 | |
| 1834 | // We're done |
| 1835 | World_changed = 1; |
| 1836 | } |
| 1837 | |
| 1838 | // Place a room on the terrain for orientation before attachment |
| 1839 | // Parameters: cellnum - the cell where the room is being placed |
no test coverage detected