| 1124 | } |
| 1125 | |
| 1126 | bool matcen::SetStatus(int status, bool f_enable) // Not all flags are settable |
| 1127 | { |
| 1128 | status &= ~(MSTAT_DONE_PROD | MSTAT_NEVER_PROD); |
| 1129 | m_last_active_check_result = (m_status & MSTAT_ACTIVE) != 0; |
| 1130 | |
| 1131 | if (f_enable) { |
| 1132 | bool f_recompute = false; |
| 1133 | |
| 1134 | if ((m_prod_mode == MMODE_NOTPROD) && (status & MSTAT_ACTIVE) && !(m_status & MSTAT_ACTIVE)) { |
| 1135 | f_recompute = true; |
| 1136 | } |
| 1137 | |
| 1138 | m_status |= status; |
| 1139 | |
| 1140 | if (f_recompute) { |
| 1141 | ComputeNextProdInfo(); |
| 1142 | } |
| 1143 | } else { |
| 1144 | m_status &= ~status; |
| 1145 | } |
| 1146 | |
| 1147 | #ifdef NEWEDITOR |
| 1148 | |
| 1149 | ASSERT(!(m_status & MSTAT_ACTIVE)); |
| 1150 | |
| 1151 | #else |
| 1152 | |
| 1153 | bool cur_active = (m_status & MSTAT_ACTIVE) != 0; |
| 1154 | |
| 1155 | if (cur_active && !m_last_active_check_result) { |
| 1156 | if (m_type == MT_OBJECT) { |
| 1157 | object *obj = ObjGet(m_objref); |
| 1158 | |
| 1159 | if (obj) |
| 1160 | m_sound_active_handle = Sound_system.Play3dSound(m_sounds[MATCEN_ACTIVE_SOUND], SND_PRIORITY_NORMAL, obj); |
| 1161 | } else { |
| 1162 | pos_state pos; |
| 1163 | matrix idmat = Identity_matrix; |
| 1164 | |
| 1165 | int croom = m_create_room; |
| 1166 | if (!ROOMNUM_OUTSIDE(m_create_room) && (Rooms[m_create_room].flags & RF_EXTERNAL)) { |
| 1167 | croom = GetTerrainRoomFromPos(&m_create_pnt); |
| 1168 | } |
| 1169 | |
| 1170 | pos.position = &m_create_pnt; |
| 1171 | pos.orient = &idmat; |
| 1172 | pos.roomnum = croom; |
| 1173 | |
| 1174 | m_sound_active_handle = Sound_system.Play3dSound(m_sounds[MATCEN_ACTIVE_SOUND], SND_PRIORITY_NORMAL, &pos); |
| 1175 | } |
| 1176 | } else if (!cur_active && m_last_active_check_result) { |
| 1177 | Sound_system.StopSoundLooping(m_sound_active_handle); |
| 1178 | } |
| 1179 | |
| 1180 | #endif // NEWEDITOR |
| 1181 | |
| 1182 | return true; |
| 1183 | } |
no test coverage detected