Cleanups.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3338 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -128,6 +128,11 @@ struct element
|
||||
union
|
||||
{
|
||||
BYTE mass_points;
|
||||
/* Planetside:
|
||||
* - for living bio: Index in CreatureData, possibly OR'ed
|
||||
* with CREATURE_AWARE
|
||||
* - for canned bio: value of creature
|
||||
*/
|
||||
BYTE sys_loc; /* IP: location in system */
|
||||
};
|
||||
BYTE turn_wait;
|
||||
|
||||
@@ -599,6 +599,46 @@ pickupBioNode (PLANETSIDE_DESC *pPSD, COUNT NumRetrieved)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
shotCreature (ELEMENT *ElementPtr, BYTE value,
|
||||
INTERSECT_CONTROL *LanderControl, PRIMITIVE *pPrim)
|
||||
{
|
||||
if (ElementPtr->hit_points == 0)
|
||||
{
|
||||
// Creature is already canned.
|
||||
return;
|
||||
}
|
||||
|
||||
--ElementPtr->hit_points;
|
||||
if (ElementPtr->hit_points == 0)
|
||||
{
|
||||
// Can creature.
|
||||
ElementPtr->mass_points = value;
|
||||
DisplayArray[ElementPtr->PrimIndex].Object.Stamp.frame =
|
||||
pSolarSysState->PlanetSideFrame[0];
|
||||
}
|
||||
else if (CreatureData[ElementPtr->mass_points & ~CREATURE_AWARE]
|
||||
.Attributes & SPEED_MASK)
|
||||
{
|
||||
COUNT angle;
|
||||
|
||||
angle = FACING_TO_ANGLE (GetFrameIndex (
|
||||
LanderControl->IntersectStamp.frame) -
|
||||
ANGLE_TO_FACING (FULL_CIRCLE));
|
||||
DeltaVelocityComponents (&ElementPtr->velocity,
|
||||
COSINE (angle, WORLD_TO_VELOCITY (1)),
|
||||
SINE (angle, WORLD_TO_VELOCITY (1)));
|
||||
ElementPtr->thrust_wait = 0;
|
||||
ElementPtr->mass_points |= CREATURE_AWARE;
|
||||
}
|
||||
|
||||
SetPrimType (pPrim, STAMPFILL_PRIM);
|
||||
SetPrimColor (pPrim, WHITE_COLOR);
|
||||
|
||||
PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_HITS),
|
||||
NotPositional (), NULL, GAME_SOUND_PRIORITY);
|
||||
}
|
||||
|
||||
static void
|
||||
CheckObjectCollision (COUNT index)
|
||||
{
|
||||
@@ -731,8 +771,7 @@ CheckObjectCollision (COUNT index)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (scan == BIOLOGICAL_SCAN
|
||||
&& ElementPtr->hit_points)
|
||||
else if (scan == BIOLOGICAL_SCAN && ElementPtr->hit_points)
|
||||
{
|
||||
BYTE danger_vals[] =
|
||||
{
|
||||
@@ -782,42 +821,8 @@ CheckObjectCollision (COUNT index)
|
||||
].ValueAndHitPoints)))
|
||||
{
|
||||
/* Collision of a stun bolt with a viable creature */
|
||||
if (ElementPtr->hit_points)
|
||||
{
|
||||
if (--ElementPtr->hit_points == 0)
|
||||
{
|
||||
ElementPtr->mass_points = value;
|
||||
DisplayArray[
|
||||
ElementPtr->PrimIndex
|
||||
].Object.Stamp.frame =
|
||||
pSolarSysState->PlanetSideFrame[0];
|
||||
}
|
||||
else if (CreatureData[
|
||||
ElementPtr->mass_points
|
||||
& ~CREATURE_AWARE
|
||||
].Attributes & SPEED_MASK)
|
||||
{
|
||||
COUNT angle;
|
||||
|
||||
angle = FACING_TO_ANGLE (GetFrameIndex (
|
||||
LanderControl.IntersectStamp.frame
|
||||
) - ANGLE_TO_FACING (FULL_CIRCLE));
|
||||
DeltaVelocityComponents (
|
||||
&ElementPtr->velocity,
|
||||
COSINE (angle, WORLD_TO_VELOCITY (1)),
|
||||
SINE (angle, WORLD_TO_VELOCITY (1)));
|
||||
ElementPtr->thrust_wait = 0;
|
||||
ElementPtr->mass_points |= CREATURE_AWARE;
|
||||
}
|
||||
|
||||
SetPrimType (pPrim, STAMPFILL_PRIM);
|
||||
SetPrimColor (pPrim, WHITE_COLOR);
|
||||
|
||||
PlaySound (SetAbsSoundIndex (
|
||||
LanderSounds, LANDER_HITS),
|
||||
NotPositional (), NULL,
|
||||
GAME_SOUND_PRIORITY);
|
||||
}
|
||||
shotCreature (ElementPtr, value, &LanderControl,
|
||||
pPrim);
|
||||
UnlockElement (hElement);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ typedef struct solarsys_state SOLARSYS_STATE;
|
||||
#include "../units.h"
|
||||
|
||||
#include "elemdata.h"
|
||||
#include "lifeform.h"
|
||||
#include "plandata.h"
|
||||
#include "sundata.h"
|
||||
|
||||
@@ -174,6 +175,8 @@ struct solarsys_state
|
||||
// as its argument, and overwritten by subsequent calls.
|
||||
PLANET_DESC *pBaseDesc;
|
||||
PLANET_DESC *pOrbitalDesc;
|
||||
// Points into PlanetDesc or MoonDesc to the planet currently
|
||||
// orbiting.
|
||||
SIZE FirstPlanetIndex, LastPlanetIndex;
|
||||
// The planets get sorted on their image.origin.y value.
|
||||
// PlanetDesc[FirstPlanetIndex] is the planet with the lowest
|
||||
@@ -198,7 +201,15 @@ struct solarsys_state
|
||||
// Functions to call to fill in various parts of this structure.
|
||||
// See generate.h, doc/devel/generate
|
||||
|
||||
FRAME PlanetSideFrame[6];
|
||||
FRAME PlanetSideFrame[3 + MAX_LIFE_VARIATION];
|
||||
/* Frames for planet-side elements.
|
||||
* [0] = bio cannister
|
||||
* [1] = energy node (world-specific)
|
||||
* [2] = unused (formerly static slave shield, presumed)
|
||||
* [3] = bio 1 (world-specific)
|
||||
* [4] = bio 2 (world-specific)
|
||||
* [5] = bio 3 (world-specific)
|
||||
*/
|
||||
UWORD Tint_rgb;
|
||||
UBYTE PauseRotate;
|
||||
FRAME TopoFrame;
|
||||
|
||||
+57
-40
@@ -1246,17 +1246,65 @@ ScanSystem (void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
generateBioNode (SOLARSYS_STATE *system, ELEMENT *NodeElementPtr,
|
||||
BYTE *life_init_tab)
|
||||
{
|
||||
COUNT i;
|
||||
COUNT creatureType;
|
||||
|
||||
creatureType = system->SysInfo.PlanetInfo.CurType;
|
||||
|
||||
if (CreatureData[creatureType].Attributes & SPEED_MASK)
|
||||
{
|
||||
// Place moving creatures at a random location.
|
||||
i = (COUNT)TFB_Random ();
|
||||
NodeElementPtr->current.location.x =
|
||||
(LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8;
|
||||
NodeElementPtr->current.location.y =
|
||||
(HIBYTE (i) % (MAP_HEIGHT - (8 << 1))) + 8;
|
||||
}
|
||||
|
||||
if (system->PlanetSideFrame[0] == 0)
|
||||
system->PlanetSideFrame[0] =
|
||||
CaptureDrawable (LoadGraphic (CANNISTER_MASK_PMAP_ANIM));
|
||||
|
||||
for (i = 0; i < MAX_LIFE_VARIATION
|
||||
&& life_init_tab[i] != (BYTE)(creatureType + 1);
|
||||
++i)
|
||||
{
|
||||
if (life_init_tab[i] != 0)
|
||||
continue;
|
||||
|
||||
life_init_tab[i] = (BYTE)creatureType + 1;
|
||||
|
||||
system->PlanetSideFrame[i + 3] = load_life_form (creatureType);
|
||||
break;
|
||||
}
|
||||
|
||||
NodeElementPtr->mass_points = (BYTE)creatureType;
|
||||
NodeElementPtr->hit_points = HINIBBLE (
|
||||
CreatureData[creatureType].ValueAndHitPoints);
|
||||
DisplayArray[NodeElementPtr->PrimIndex].
|
||||
Object.Stamp.frame = SetAbsFrameIndex (
|
||||
system->PlanetSideFrame[i + 3], (COUNT)TFB_Random ());
|
||||
}
|
||||
|
||||
void
|
||||
GeneratePlanetSide (void)
|
||||
{
|
||||
SIZE scan;
|
||||
BYTE life_init_tab[MAX_LIFE_VARIATION];
|
||||
// life_init_tab is filled with the creature types of already
|
||||
// selected creatures. If an entry is 0, none has been selected
|
||||
// yet, otherwise, it is 1 more than the creature type.
|
||||
|
||||
InitDisplayList ();
|
||||
if (pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED)
|
||||
return;
|
||||
|
||||
memset (life_init_tab, 0, sizeof (life_init_tab));
|
||||
|
||||
for (scan = BIOLOGICAL_SCAN; scan >= MINERAL_SCAN; --scan)
|
||||
{
|
||||
COUNT num_nodes;
|
||||
@@ -1315,7 +1363,7 @@ GeneratePlanetSide (void)
|
||||
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
|
||||
IncFrameIndex (NodeElementPtr->next.image.frame);
|
||||
}
|
||||
else
|
||||
else /* (scan == BIOLOGICAL_SCAN || scan == ENERGY_SCAN) */
|
||||
{
|
||||
NodeElementPtr->current.image.frame = f;
|
||||
NodeElementPtr->next.image.frame = SetRelFrameIndex (
|
||||
@@ -1325,54 +1373,23 @@ GeneratePlanetSide (void)
|
||||
if (scan == ENERGY_SCAN)
|
||||
{
|
||||
if (pSolarSysState->SysInfo.PlanetInfo.CurType == 1)
|
||||
{
|
||||
NodeElementPtr->mass_points = 0;
|
||||
}
|
||||
else if (pSolarSysState->SysInfo.PlanetInfo.CurType == 2)
|
||||
{
|
||||
// Special case: Fwiffo
|
||||
NodeElementPtr->mass_points = 1;
|
||||
}
|
||||
else
|
||||
NodeElementPtr->mass_points = MAX_SCROUNGED;
|
||||
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
|
||||
pSolarSysState->PlanetSideFrame[1];
|
||||
}
|
||||
else
|
||||
else /* (scan == BIOLOGICAL_SCAN) */
|
||||
{
|
||||
COUNT i, which_node;
|
||||
|
||||
which_node = pSolarSysState->SysInfo.PlanetInfo.CurType;
|
||||
|
||||
if (CreatureData[which_node].Attributes & SPEED_MASK)
|
||||
{
|
||||
i = (COUNT)TFB_Random ();
|
||||
NodeElementPtr->current.location.x =
|
||||
(LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8;
|
||||
NodeElementPtr->current.location.y =
|
||||
(HIBYTE (i) % (MAP_HEIGHT - (8 << 1))) + 8;
|
||||
}
|
||||
|
||||
if (pSolarSysState->PlanetSideFrame[0] == 0)
|
||||
pSolarSysState->PlanetSideFrame[0] =
|
||||
CaptureDrawable (LoadGraphic (
|
||||
CANNISTER_MASK_PMAP_ANIM));
|
||||
for (i = 0; i < MAX_LIFE_VARIATION
|
||||
&& life_init_tab[i] != (BYTE)(which_node + 1);
|
||||
++i)
|
||||
{
|
||||
if (life_init_tab[i] != 0)
|
||||
continue;
|
||||
|
||||
life_init_tab[i] = (BYTE)which_node + 1;
|
||||
|
||||
pSolarSysState->PlanetSideFrame[i + 3] =
|
||||
load_life_form (which_node);
|
||||
break;
|
||||
}
|
||||
|
||||
NodeElementPtr->mass_points = (BYTE)which_node;
|
||||
NodeElementPtr->hit_points = HINIBBLE (
|
||||
CreatureData[which_node].ValueAndHitPoints);
|
||||
DisplayArray[NodeElementPtr->PrimIndex].
|
||||
Object.Stamp.frame = SetAbsFrameIndex (
|
||||
pSolarSysState->PlanetSideFrame[i + 3],
|
||||
(COUNT)TFB_Random ());
|
||||
generateBioNode (pSolarSysState, NodeElementPtr,
|
||||
life_init_tab);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -670,8 +670,7 @@ DrawFlagshipStats (void)
|
||||
(((100 * ONE_SECOND * energy_regeneration) /
|
||||
((1 + energy_wait) * BATTLE_FRAME_RATE)) + 5) / 10;
|
||||
sprintf (buf, "%2u.%1u",
|
||||
energy_per_10_sec / 10,
|
||||
energy_per_10_sec % 10);
|
||||
energy_per_10_sec / 10, energy_per_10_sec % 10);
|
||||
}
|
||||
font_DrawText (&t);
|
||||
t.baseline.y += leading;
|
||||
@@ -723,9 +722,7 @@ DrawLanders (void)
|
||||
|
||||
i = GLOBAL_SIS (NumLanders);
|
||||
r.corner.x = (STATUS_WIDTH >> 1) - r.corner.x;
|
||||
s.origin.x = r.corner.x
|
||||
- (((r.extent.width * i)
|
||||
+ (2 * (i - 1))) >> 1);
|
||||
s.origin.x = r.corner.x - (((r.extent.width * i) + (2 * (i - 1))) >> 1);
|
||||
s.origin.y = 29;
|
||||
|
||||
width = r.extent.width + 2;
|
||||
|
||||
Reference in New Issue
Block a user