From: <Mee...@us...> - 2009-11-22 14:04:03
|
Revision: 3338 http://sc2.svn.sourceforge.net/sc2/?rev=3338&view=rev Author: Meep-Eep Date: 2009-11-22 14:03:56 +0000 (Sun, 22 Nov 2009) Log Message: ----------- Cleanups. Modified Paths: -------------- trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/sis.c Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/element.h 2009-11-22 14:03:56 UTC (rev 3338) @@ -128,6 +128,11 @@ 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; Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/planets/lander.c 2009-11-22 14:03:56 UTC (rev 3338) @@ -600,6 +600,46 @@ } 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) { INTERSECT_CONTROL LanderControl; @@ -731,8 +771,7 @@ continue; } } - else if (scan == BIOLOGICAL_SCAN - && ElementPtr->hit_points) + else if (scan == BIOLOGICAL_SCAN && ElementPtr->hit_points) { BYTE danger_vals[] = { @@ -782,42 +821,8 @@ ].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; } Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/planets/planets.h 2009-11-22 14:03:56 UTC (rev 3338) @@ -100,6 +100,7 @@ #include "../units.h" #include "elemdata.h" +#include "lifeform.h" #include "plandata.h" #include "sundata.h" @@ -174,6 +175,8 @@ // 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 @@ // 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; Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/planets/scan.c 2009-11-22 14:03:56 UTC (rev 3338) @@ -1246,17 +1246,65 @@ } } +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 @@ 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 @@ 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); } } Modified: trunk/sc2/src/uqm/sis.c =================================================================== --- trunk/sc2/src/uqm/sis.c 2009-11-22 12:53:53 UTC (rev 3337) +++ trunk/sc2/src/uqm/sis.c 2009-11-22 14:03:56 UTC (rev 3338) @@ -670,8 +670,7 @@ (((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 @@ 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |