diff --git a/sc2/src/uqm/comm.c b/sc2/src/uqm/comm.c index e82c8700b..13febe38a 100644 --- a/sc2/src/uqm/comm.c +++ b/sc2/src/uqm/comm.c @@ -1575,14 +1575,14 @@ RaceCommunication (void) COUNT NumShips; ENCOUNTER *EncounterPtr; + // The encounter globe that the flagship collided with is moved + // to the head of the queue in hyper.c:cleanup_hyperspace() hEncounter = GetHeadEncounter (); LockEncounter (hEncounter, &EncounterPtr); NumShips = LONIBBLE (EncounterPtr->SD.Index); for (i = 0; i < NumShips; ++i) { - // XXX: Bug 996 lives here: crew is set to default (0) - // None of ship info is actually used! CloneShipFragment (EncounterPtr->SD.Type, &GLOBAL (npc_built_ship_q), EncounterPtr->ShipList[i].crew_level); diff --git a/sc2/src/uqm/hyper.c b/sc2/src/uqm/hyper.c index 73c906742..d699a498b 100644 --- a/sc2/src/uqm/hyper.c +++ b/sc2/src/uqm/hyper.c @@ -404,8 +404,10 @@ cleanup_hyperspace (void) LockElement (EncounterPtr->hElement, &ElementPtr); - if (ElementPtr->state_flags & BAD_GUY) - { + if (ElementPtr->hTarget) + { // This is the encounter that collided with flagship + // Move the encounter to the head of the queue so that + // comm.c:RaceCommunication() gets the right one. RemoveEncounter (hEncounter); InsertEncounter (hEncounter, GetHeadEncounter ()); } @@ -861,6 +863,24 @@ encounter_transition (ELEMENT *ElementPtr) } } +static HELEMENT +getSisElement (void) +{ + HSTARSHIP hSis; + HELEMENT hShip; + STARSHIP *StarShipPtr; + + hSis = GetHeadLink (&race_q[RPG_PLAYER_NUM]); + if (!hSis) + return NULL; + + StarShipPtr = LockStarShip (&race_q[RPG_PLAYER_NUM], hSis); + hShip = StarShipPtr->hShip; + UnlockStarShip (&race_q[RPG_PLAYER_NUM], hSis); + + return hShip; +} + static void encounter_collision (ELEMENT *ElementPtr0, POINT *pPt0, ELEMENT *ElementPtr1, POINT *pPt1) @@ -893,7 +913,10 @@ encounter_collision (ELEMENT *ElementPtr0, POINT *pPt0, UnlockEncounter (hEncounter); } - ElementPtr0->state_flags |= BAD_GUY; + // Mark this element as collided with flagship + // XXX: We could simply set hTarget to 1 or to ElementPtr1, + // but that would be too hacky ;) + ElementPtr0->hTarget = getSisElement (); ZeroVelocityComponents (&ElementPtr0->velocity); } (void) pPt0; /* Satisfying compiler (unused parameter) */ @@ -1162,8 +1185,9 @@ DeleteEncounter: &delta_x, &delta_y, 1); if (ElementPtr->thrust_wait) --ElementPtr->thrust_wait; - else if (!(ElementPtr->state_flags & BAD_GUY)) - { + else if (!ElementPtr->hTarget) + { // This is an encounter that did not collide with flagship + // The colliding encounter does not move COUNT cur_facing, delta_facing; cur_facing = ANGLE_TO_FACING (