|
46 | 46 | //------------------------------------------------------------------------------------------------- |
47 | 47 | MissileLauncherBuildingUpdate::MissileLauncherBuildingUpdate( Thing *thing, const ModuleData* moduleData ) : SpecialPowerUpdateModule( thing, moduleData ) |
48 | 48 | { |
| 49 | + const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); |
| 50 | + |
49 | 51 | m_doorState = DOOR_CLOSED; |
50 | 52 | m_timeoutState = DOOR_CLOSED; |
51 | 53 | m_timeoutFrame = 0; |
52 | | - m_openIdleAudio = getMissileLauncherBuildingUpdateModuleData()->m_openIdleAudio; |
| 54 | + m_openIdleAudio = d->m_openIdleAudio; |
53 | 55 | m_openIdleAudio.setObjectID(getObject()->getID()); |
| 56 | + m_specialPowerModule = getObject()->getSpecialPowerModule(d->m_specialPowerTemplate); |
| 57 | + DEBUG_ASSERTCRASH(m_specialPowerModule, ("Missing special power")); |
54 | 58 | } |
55 | 59 |
|
56 | 60 | //------------------------------------------------------------------------------------------------- |
@@ -201,14 +205,14 @@ void MissileLauncherBuildingUpdate::switchToState(DoorStateType dst) |
201 | 205 | //------------------------------------------------------------------------------------------------- |
202 | 206 | Bool MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower( const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions ) |
203 | 207 | { |
204 | | -#if RETAIL_COMPATIBLE_CRC |
205 | 208 | // TheSuperHackers @bugfix Mauller 29/06/2025 prevent a game crash when told to launch before ready to do so |
206 | | - if (!m_specialPowerModule) { |
207 | | - Object* us = getObject(); |
208 | | - us->getSpecialPowerModule(specialPowerTemplate)->setReadyFrame(0xFFFFFFFF); |
| 209 | + if( getObject()->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) ) |
| 210 | + { |
| 211 | +#if RETAIL_COMPATIBLE_CRC |
| 212 | + getObject()->getSpecialPowerModule(specialPowerTemplate)->setReadyFrame(~0u); |
| 213 | +#endif |
209 | 214 | return FALSE; |
210 | 215 | } |
211 | | -#endif |
212 | 216 |
|
213 | 217 | if( m_specialPowerModule->getSpecialPowerTemplate() != specialPowerTemplate ) |
214 | 218 | { |
@@ -236,23 +240,16 @@ Bool MissileLauncherBuildingUpdate::isPowerCurrentlyInUse( const CommandButton * |
236 | 240 | //------------------------------------------------------------------------------------------------- |
237 | 241 | UpdateSleepTime MissileLauncherBuildingUpdate::update( void ) |
238 | 242 | { |
239 | | - const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); |
240 | | - |
241 | | - UnsignedInt now = TheGameLogic->getFrame(); |
242 | | - |
243 | 243 | // If we are under construction, any decision we make about door status could be wrong. |
244 | 244 | // Our special power module is randomly going to be initialized or not (which would result |
245 | 245 | // in him reporting a 0 frame ready, which means we will start open). |
246 | 246 | if( getObject()->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) ) |
247 | 247 | return UPDATE_SLEEP_NONE; |
248 | 248 |
|
249 | | - if (!m_specialPowerModule) |
250 | | - { |
251 | | - m_specialPowerModule = getObject()->getSpecialPowerModule(d->m_specialPowerTemplate); |
252 | | - DEBUG_ASSERTCRASH(m_specialPowerModule, ("Missing special power")); |
253 | | - } |
| 249 | + const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); |
| 250 | + |
| 251 | + UnsignedInt now = TheGameLogic->getFrame(); |
254 | 252 |
|
255 | | - if (m_specialPowerModule) |
256 | 253 | { |
257 | 254 | UnsignedInt readyFrame = m_specialPowerModule->getReadyFrame(); |
258 | 255 | UnsignedInt whenToStartOpening = (readyFrame >= d->m_doorOpenTime) ? (readyFrame - d->m_doorOpenTime) : 0; |
@@ -313,9 +310,6 @@ void MissileLauncherBuildingUpdate::xfer( Xfer *xfer ) |
313 | 310 | // extend base class |
314 | 311 | UpdateModule::xfer( xfer ); |
315 | 312 |
|
316 | | - // do not need to tie the m_specialPowerModule pointer cause it gets tied |
317 | | - // SpecialPowerModuleInterface *m_specialPowerModule; |
318 | | - |
319 | 313 | // door state |
320 | 314 | xfer->xferUser( &m_doorState, sizeof( DoorStateType ) ); |
321 | 315 |
|
|
0 commit comments