From: <av...@us...> - 2009-11-04 23:51:35
|
Revision: 3274 http://sc2.svn.sourceforge.net/sc2/?rev=3274&view=rev Author: avolkov Date: 2009-11-04 23:51:26 +0000 (Wed, 04 Nov 2009) Log Message: ----------- Battle & ship code cleanup: GOOD_GUY/BAD_GUY flags removed from Hyperspace; some comments Modified Paths: -------------- trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/hyper.c Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2009-11-04 21:42:39 UTC (rev 3273) +++ trunk/sc2/src/uqm/comm.c 2009-11-04 23:51:26 UTC (rev 3274) @@ -1575,14 +1575,14 @@ 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); Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2009-11-04 21:42:39 UTC (rev 3273) +++ trunk/sc2/src/uqm/hyper.c 2009-11-04 23:51:26 UTC (rev 3274) @@ -404,8 +404,10 @@ 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 @@ } } +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 @@ 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 @@ &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 ( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |