Battle & ship code cleanup: GOOD_GUY/BAD_GUY flags removed from Hyperspace; some comments

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3274 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-04 23:51:26 +00:00
parent 6a822abc49
commit 51751b3858
2 changed files with 31 additions and 7 deletions
+2 -2
View File
@@ -1575,14 +1575,14 @@ RaceCommunication (void)
COUNT NumShips; COUNT NumShips;
ENCOUNTER *EncounterPtr; 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 (); hEncounter = GetHeadEncounter ();
LockEncounter (hEncounter, &EncounterPtr); LockEncounter (hEncounter, &EncounterPtr);
NumShips = LONIBBLE (EncounterPtr->SD.Index); NumShips = LONIBBLE (EncounterPtr->SD.Index);
for (i = 0; i < NumShips; ++i) 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, CloneShipFragment (EncounterPtr->SD.Type,
&GLOBAL (npc_built_ship_q), &GLOBAL (npc_built_ship_q),
EncounterPtr->ShipList[i].crew_level); EncounterPtr->ShipList[i].crew_level);
+29 -5
View File
@@ -404,8 +404,10 @@ cleanup_hyperspace (void)
LockElement (EncounterPtr->hElement, &ElementPtr); 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); RemoveEncounter (hEncounter);
InsertEncounter (hEncounter, GetHeadEncounter ()); 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 static void
encounter_collision (ELEMENT *ElementPtr0, POINT *pPt0, encounter_collision (ELEMENT *ElementPtr0, POINT *pPt0,
ELEMENT *ElementPtr1, POINT *pPt1) ELEMENT *ElementPtr1, POINT *pPt1)
@@ -893,7 +913,10 @@ encounter_collision (ELEMENT *ElementPtr0, POINT *pPt0,
UnlockEncounter (hEncounter); 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); ZeroVelocityComponents (&ElementPtr0->velocity);
} }
(void) pPt0; /* Satisfying compiler (unused parameter) */ (void) pPt0; /* Satisfying compiler (unused parameter) */
@@ -1162,8 +1185,9 @@ DeleteEncounter:
&delta_x, &delta_y, 1); &delta_x, &delta_y, 1);
if (ElementPtr->thrust_wait) if (ElementPtr->thrust_wait)
--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; COUNT cur_facing, delta_facing;
cur_facing = ANGLE_TO_FACING ( cur_facing = ANGLE_TO_FACING (