本文整理汇总了C++中UnlockElement函数的典型用法代码示例。如果您正苦于以下问题:C++ UnlockElement函数的具体用法?C++ UnlockElement怎么用?C++ UnlockElement使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UnlockElement函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findPlayerShip
// playerNr should be 0 or 1
STARSHIP*
findPlayerShip (SIZE playerNr)
{
HELEMENT hElement, hNextElement;
for (hElement = GetHeadElement (); hElement; hElement = hNextElement)
{
ELEMENT *ElementPtr;
LockElement (hElement, &ElementPtr);
hNextElement = GetSuccElement (ElementPtr);
if ((ElementPtr->state_flags & PLAYER_SHIP) &&
ElementPtr->playerNr == playerNr)
{
STARSHIP *StarShipPtr;
GetElementStarShip (ElementPtr, &StarShipPtr);
UnlockElement (hElement);
return StarShipPtr;
}
UnlockElement (hElement);
}
return NULL;
}
示例2: initialize_turret_missile
static COUNT
initialize_turret_missile (PELEMENT ShipPtr, HELEMENT MissileArray[])
{
#define MISSILE_HITS 2
#define MISSILE_DAMAGE 3
#define MISSILE_OFFSET 1
ELEMENTPTR TurretPtr;
STARSHIPPTR StarShipPtr;
MISSILE_BLOCK MissileBlock;
GetElementStarShip (ShipPtr, &StarShipPtr);
MissileBlock.cx = ShipPtr->next.location.x;
MissileBlock.cy = ShipPtr->next.location.y;
MissileBlock.farray = StarShipPtr->RaceDescPtr->ship_data.weapon;
LockElement (GetSuccElement (ShipPtr), &TurretPtr);
if (TurretPtr->turn_wait == 0
&& (StarShipPtr->cur_status_flags & SPECIAL)
&& (StarShipPtr->cur_status_flags & (LEFT | RIGHT)))
{
if (StarShipPtr->cur_status_flags & RIGHT)
++TurretPtr->thrust_wait;
else
--TurretPtr->thrust_wait;
TurretPtr->turn_wait = TURRET_WAIT + 1;
}
MissileBlock.face = MissileBlock.index =
NORMALIZE_FACING (StarShipPtr->ShipFacing
+ TurretPtr->thrust_wait);
UnlockElement (GetSuccElement (ShipPtr));
MissileBlock.sender = (ShipPtr->state_flags & (GOOD_GUY | BAD_GUY))
| IGNORE_SIMILAR;
MissileBlock.pixoffs = TURRET_OFFSET;
MissileBlock.speed = MISSILE_SPEED;
MissileBlock.hit_points = MISSILE_HITS;
MissileBlock.damage = MISSILE_DAMAGE;
MissileBlock.life = MISSILE_LIFE;
MissileBlock.preprocess_func = NULL_PTR;
MissileBlock.blast_offs = MISSILE_OFFSET;
MissileArray[0] = initialize_missile (&MissileBlock);
if (MissileArray[0])
{
ELEMENTPTR HowitzerPtr;
LockElement (MissileArray[0], &HowitzerPtr);
HowitzerPtr->collision_func = howitzer_collision;
UnlockElement (MissileArray[0]);
}
return (1);
}
示例3: TimeSpaceMatterConflict
BOOLEAN
TimeSpaceMatterConflict (ELEMENT *ElementPtr)
{
HELEMENT hTestElement, hSuccElement;
INTERSECT_CONTROL ElementControl;
ElementControl.IntersectStamp.origin.x =
WORLD_TO_DISPLAY (ElementPtr->current.location.x);
ElementControl.IntersectStamp.origin.y =
WORLD_TO_DISPLAY (ElementPtr->current.location.y);
ElementControl.IntersectStamp.frame =
SetEquFrameIndex (ElementPtr->current.image.farray[0],
ElementPtr->current.image.frame);
ElementControl.EndPoint = ElementControl.IntersectStamp.origin;
for (hTestElement = GetHeadElement ();
hTestElement != 0; hTestElement = hSuccElement)
{
ELEMENT *TestElementPtr;
LockElement (hTestElement, &TestElementPtr);
hSuccElement = GetSuccElement (TestElementPtr);
if (TestElementPtr != ElementPtr
&& (CollidingElement (TestElementPtr)
/* ship in transition */
|| (TestElementPtr->state_flags & PLAYER_SHIP)))
{
INTERSECT_CONTROL TestElementControl;
TestElementControl.IntersectStamp.origin.x =
WORLD_TO_DISPLAY (TestElementPtr->current.location.x);
TestElementControl.IntersectStamp.origin.y =
WORLD_TO_DISPLAY (TestElementPtr->current.location.y);
TestElementControl.IntersectStamp.frame =
SetEquFrameIndex (TestElementPtr->current.image.farray[0],
TestElementPtr->current.image.frame);
TestElementControl.EndPoint = TestElementControl.IntersectStamp.origin;
if (DrawablesIntersect (&ElementControl,
&TestElementControl, MAX_TIME_VALUE))
{
UnlockElement (hTestElement);
break;
}
}
UnlockElement (hTestElement);
}
return (hTestElement != 0 ? TRUE : FALSE);
}
示例4: initialize_confusion
static COUNT
initialize_confusion (ELEMENT *ShipPtr, HELEMENT ConfusionArray[])
{
STARSHIP *StarShipPtr;
MISSILE_BLOCK ConfusionBlock;
GetElementStarShip (ShipPtr, &StarShipPtr);
ConfusionBlock.cx = ShipPtr->next.location.x;
ConfusionBlock.cy = ShipPtr->next.location.y;
ConfusionBlock.farray = StarShipPtr->RaceDescPtr->ship_data.special;
ConfusionBlock.index = 0;
ConfusionBlock.face = StarShipPtr->ShipFacing;
ConfusionBlock.sender = ShipPtr->playerNr;
ConfusionBlock.flags = IGNORE_SIMILAR;
ConfusionBlock.pixoffs = MELNORME_OFFSET;
ConfusionBlock.speed = CMISSILE_SPEED;
ConfusionBlock.hit_points = CMISSILE_HITS;
ConfusionBlock.damage = CMISSILE_DAMAGE;
ConfusionBlock.life = CMISSILE_LIFE;
ConfusionBlock.preprocess_func = confuse_preprocess;
ConfusionBlock.blast_offs = CMISSILE_OFFSET;
ConfusionArray[0] = initialize_missile (&ConfusionBlock);
if (ConfusionArray[0])
{
ELEMENT *CMissilePtr;
LockElement (ConfusionArray[0], &CMissilePtr);
CMissilePtr->collision_func = confusion_collision;
SetElementStarShip (CMissilePtr, StarShipPtr);
UnlockElement (ConfusionArray[0]);
}
return (1);
}
示例5: intercept_pkunk_death
static void
intercept_pkunk_death (ELEMENT *ElementPtr)
{
STARSHIP *StarShipPtr;
ElementPtr->state_flags &= ~DISAPPEARING;
ElementPtr->life_span = 1;
GetElementStarShip (ElementPtr, &StarShipPtr);
if (StarShipPtr->RaceDescPtr->ship_info.crew_level == 0)
{
ELEMENT *ShipPtr;
LockElement (StarShipPtr->hShip, &ShipPtr);
if (GRAVITY_MASS (ShipPtr->mass_points + 1))
{
ElementPtr->state_flags |= DISAPPEARING;
ElementPtr->life_span = 0;
}
else
{
ShipPtr->mass_points = MAX_SHIP_MASS + 1;
StarShipPtr->RaceDescPtr->preprocess_func = ShipPtr->preprocess_func;
StarShipPtr->RaceDescPtr->postprocess_func = ShipPtr->postprocess_func;
StarShipPtr->RaceDescPtr->init_weapon_func =
(COUNT (*) (ELEMENT *ElementPtr, HELEMENT Weapon[]))
ShipPtr->death_func;
ElementPtr->death_func = new_pkunk;
}
UnlockElement (StarShipPtr->hShip);
}
}
示例6: melnorme_postprocess
static void
melnorme_postprocess (ELEMENT *ElementPtr)
{
STARSHIP *StarShipPtr;
GetElementStarShip (ElementPtr, &StarShipPtr);
if ((StarShipPtr->cur_status_flags & SPECIAL)
&& StarShipPtr->special_counter == 0
&& DeltaEnergy (ElementPtr, -SPECIAL_ENERGY_COST))
{
HELEMENT Confusion;
initialize_confusion (ElementPtr, &Confusion);
if (Confusion)
{
ELEMENT *CMissilePtr;
LockElement (Confusion, &CMissilePtr);
ProcessSound (SetAbsSoundIndex (
StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), CMissilePtr);
UnlockElement (Confusion);
PutElement (Confusion);
StarShipPtr->special_counter =
StarShipPtr->RaceDescPtr->characteristics.special_wait;
}
}
}
示例7: blaster_collision
static void
blaster_collision (ELEMENT *ElementPtr0, POINT *pPt0,
ELEMENT *ElementPtr1, POINT *pPt1)
{
HELEMENT hBlastElement;
hBlastElement = weapon_collision (ElementPtr0, pPt0, ElementPtr1, pPt1);
if (hBlastElement)
{
ELEMENT *BlastElementPtr;
LockElement (hBlastElement, &BlastElementPtr);
switch (ElementPtr0->mass_points)
{
case BLASTER_DAMAGE * 1:
BlastElementPtr->life_span = 2;
BlastElementPtr->current.image.frame =
SetAbsFrameIndex (ElementPtr0->current.image.frame, 0);
BlastElementPtr->preprocess_func = NULL;
break;
case BLASTER_DAMAGE * 2:
BlastElementPtr->life_span = 6;
BlastElementPtr->current.image.frame =
IncFrameIndex (ElementPtr0->current.image.frame);
break;
case BLASTER_DAMAGE * 3:
BlastElementPtr->life_span = 7;
BlastElementPtr->current.image.frame =
SetAbsFrameIndex (ElementPtr0->current.image.frame, 20);
break;
}
UnlockElement (hBlastElement);
}
}
示例8: crystal_collision
static void
crystal_collision (ELEMENT *ElementPtr0, POINT *pPt0,
ELEMENT *ElementPtr1, POINT *pPt1)
{
HELEMENT hBlastElement;
hBlastElement =
weapon_collision (ElementPtr0, pPt0, ElementPtr1, pPt1);
if (hBlastElement)
{
ELEMENT *BlastElementPtr;
LockElement (hBlastElement, &BlastElementPtr);
BlastElementPtr->current.location = ElementPtr1->current.location;
BlastElementPtr->life_span = NUM_SPARKLES;
BlastElementPtr->turn_wait = BlastElementPtr->next_turn = 0;
{
BlastElementPtr->preprocess_func = animate;
}
BlastElementPtr->current.image.farray = ElementPtr0->next.image.farray;
BlastElementPtr->current.image.frame =
SetAbsFrameIndex (BlastElementPtr->current.image.farray[0],
2); /* skip stones */
UnlockElement (hBlastElement);
}
}
示例9: spin_preprocess
static void
spin_preprocess (ELEMENT *ElementPtr)
{
ELEMENT *ShipPtr;
STARSHIP *StarShipPtr;
GetElementStarShip (ElementPtr, &StarShipPtr);
LockElement (StarShipPtr->hShip, &ShipPtr);
if (ShipPtr->crew_level && ++StarShipPtr->RaceDescPtr->characteristics.special_wait > MAX_SAWS)
{
ElementPtr->life_span = 1;
ElementPtr->state_flags |= DISAPPEARING;
}
else
{
++ElementPtr->life_span;
if (ElementPtr->turn_wait)
--ElementPtr->turn_wait;
else
{
#define LAST_SPIN_INDEX 1
if (GetFrameIndex (ElementPtr->current.image.frame) < LAST_SPIN_INDEX)
ElementPtr->next.image.frame = IncFrameIndex (ElementPtr->current.image.frame);
else
ElementPtr->next.image.frame = SetAbsFrameIndex (ElementPtr->current.image.frame, 0);
ElementPtr->state_flags |= CHANGING;
ElementPtr->turn_wait = SAW_RATE;
}
}
UnlockElement (StarShipPtr->hShip);
}
示例10: DoRunAway
static void
DoRunAway (STARSHIP *StarShipPtr)
{
ELEMENT *ElementPtr;
LockElement (StarShipPtr->hShip, &ElementPtr);
if (GetPrimType (&DisplayArray[ElementPtr->PrimIndex]) == STAMP_PRIM
&& ElementPtr->life_span == NORMAL_LIFE
&& !(ElementPtr->state_flags & FINITE_LIFE)
&& ElementPtr->mass_points != MAX_SHIP_MASS * 10
&& !(ElementPtr->state_flags & APPEARING))
{
battle_counter[0]--;
ElementPtr->turn_wait = 3;
ElementPtr->thrust_wait = 4;
ElementPtr->colorCycleIndex = 0;
ElementPtr->preprocess_func = flee_preprocess;
ElementPtr->mass_points = MAX_SHIP_MASS * 10;
ZeroVelocityComponents (&ElementPtr->velocity);
StarShipPtr->cur_status_flags &=
~(SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED);
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex],
BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
// XXX: I think this is supposed to be the same as the
// first entry of the color cycle table in flee_preeprocess,
// but it is slightly different (0x0A as red value). - SvdB.
SetPrimType (&DisplayArray[ElementPtr->PrimIndex], STAMPFILL_PRIM);
StarShipPtr->ship_input_state = 0;
}
UnlockElement (StarShipPtr->hShip);
}
示例11: initialize_cannon
static COUNT
initialize_cannon (ELEMENT *ShipPtr, HELEMENT CannonArray[])
{
STARSHIP *StarShipPtr;
MISSILE_BLOCK MissileBlock;
GetElementStarShip (ShipPtr, &StarShipPtr);
MissileBlock.cx = ShipPtr->next.location.x;
MissileBlock.cy = ShipPtr->next.location.y;
MissileBlock.farray = StarShipPtr->RaceDescPtr->ship_data.weapon;
MissileBlock.face = StarShipPtr->ShipFacing;
MissileBlock.index = MissileBlock.face;
MissileBlock.sender = ShipPtr->playerNr;
MissileBlock.flags = IGNORE_SIMILAR;
MissileBlock.pixoffs = DRUUGE_OFFSET;
MissileBlock.speed = MISSILE_SPEED;
MissileBlock.hit_points = MISSILE_HITS;
MissileBlock.damage = MISSILE_DAMAGE;
MissileBlock.life = MISSILE_LIFE;
MissileBlock.preprocess_func = NULL;
MissileBlock.blast_offs = MISSILE_OFFSET;
CannonArray[0] = initialize_missile (&MissileBlock);
if (CannonArray[0])
{
ELEMENT *CannonPtr;
LockElement (CannonArray[0], &CannonPtr);
CannonPtr->collision_func = cannon_collision;
UnlockElement (CannonArray[0]);
}
return (1);
}
示例12: setMinStarShipLifeSpan
static void
setMinStarShipLifeSpan (STARSHIP *starShip, COUNT life_span)
{
ELEMENT *ship;
LockElement (starShip->hShip, &ship);
setMinShipLifeSpan (ship, life_span);
UnlockElement (starShip->hShip);
}
示例13: MoveSIS
void
MoveSIS (SIZE *pdx, SIZE *pdy)
{
SIZE new_dx, new_dy;
new_dx = *pdx;
GLOBAL_SIS (log_x) -= new_dx;
if (GLOBAL_SIS (log_x) < 0)
{
new_dx += (SIZE)GLOBAL_SIS (log_x);
GLOBAL_SIS (log_x) = 0;
}
else if (GLOBAL_SIS (log_x) > MAX_X_LOGICAL)
{
new_dx += (SIZE)(GLOBAL_SIS (log_x) - MAX_X_LOGICAL);
GLOBAL_SIS (log_x) = MAX_X_LOGICAL;
}
new_dy = *pdy;
GLOBAL_SIS (log_y) -= new_dy;
if (GLOBAL_SIS (log_y) < 0)
{
new_dy += (SIZE)GLOBAL_SIS (log_y);
GLOBAL_SIS (log_y) = 0;
}
else if (GLOBAL_SIS (log_y) > MAX_Y_LOGICAL)
{
new_dy += (SIZE)(GLOBAL_SIS (log_y) - MAX_Y_LOGICAL);
GLOBAL_SIS (log_y) = MAX_Y_LOGICAL;
}
if (new_dx != *pdx || new_dy != *pdy)
{
HELEMENT hElement, hNextElement;
*pdx = new_dx;
*pdy = new_dy;
for (hElement = GetTailElement ();
hElement != 0; hElement = hNextElement)
{
ELEMENT *ElementPtr;
LockElement (hElement, &ElementPtr);
if (!(ElementPtr->state_flags & PLAYER_SHIP))
hNextElement = GetPredElement (ElementPtr);
else
{
ElementPtr->next.location.x = (LOG_SPACE_WIDTH >> 1) - new_dx;
ElementPtr->next.location.y = (LOG_SPACE_HEIGHT >> 1) - new_dy;
hNextElement = 0;
}
UnlockElement (hElement);
}
}
示例14: count_marines
static BYTE
count_marines (STARSHIPPTR StarShipPtr, BOOLEAN FindSpot)
{
BYTE num_marines, id_use[MAX_MARINES];
HELEMENT hElement, hNextElement;
num_marines = MAX_MARINES;
while (num_marines--)
id_use[num_marines] = 0;
num_marines = 0;
for (hElement = GetTailElement (); hElement; hElement = hNextElement)
{
ELEMENTPTR ElementPtr;
LockElement (hElement, &ElementPtr);
hNextElement = GetPredElement (ElementPtr);
if (ElementPtr->current.image.farray == StarShipPtr->RaceDescPtr->ship_data.special
&& ElementPtr->life_span
&& !(ElementPtr->state_flags & (FINITE_LIFE | DISAPPEARING)))
{
if (ElementPtr->state_flags & NONSOLID)
{
id_use[ElementPtr->turn_wait] = 1;
}
if (++num_marines == MAX_MARINES)
{
UnlockElement (hElement);
hNextElement = 0;
}
}
UnlockElement (hElement);
}
if (FindSpot)
{
num_marines = 0;
while (id_use[num_marines])
++num_marines;
}
return (num_marines);
}
示例15: initialize_bug_missile
static COUNT
initialize_bug_missile (ELEMENT *ShipPtr, HELEMENT MissileArray[])
{
#define PKUNK_OFFSET 15
#define MISSILE_HITS 1
#define MISSILE_DAMAGE 1
#define MISSILE_OFFSET 1
COUNT i;
STARSHIP *StarShipPtr;
MISSILE_BLOCK MissileBlock;
GetElementStarShip (ShipPtr, &StarShipPtr);
MissileBlock.cx = ShipPtr->next.location.x;
MissileBlock.cy = ShipPtr->next.location.y;
MissileBlock.farray = StarShipPtr->RaceDescPtr->ship_data.weapon;
MissileBlock.index = 0;
MissileBlock.sender = ShipPtr->playerNr;
MissileBlock.flags = IGNORE_SIMILAR;
MissileBlock.pixoffs = PKUNK_OFFSET;
MissileBlock.speed = MISSILE_SPEED;
MissileBlock.hit_points = MISSILE_HITS;
MissileBlock.damage = MISSILE_DAMAGE;
MissileBlock.life = MISSILE_LIFE;
MissileBlock.preprocess_func = NULL;
MissileBlock.blast_offs = MISSILE_OFFSET;
for (i = 0; i < 3; ++i)
{
MissileBlock.face =
StarShipPtr->ShipFacing
+ (ANGLE_TO_FACING (QUADRANT) * i);
if (i == 2)
MissileBlock.face += ANGLE_TO_FACING (QUADRANT);
MissileBlock.face = NORMALIZE_FACING (MissileBlock.face);
if ((MissileArray[i] = initialize_missile (&MissileBlock)))
{
SIZE dx, dy;
ELEMENT *MissilePtr;
LockElement (MissileArray[i], &MissilePtr);
GetCurrentVelocityComponents (&ShipPtr->velocity, &dx, &dy);
DeltaVelocityComponents (&MissilePtr->velocity, dx, dy);
MissilePtr->current.location.x -= VELOCITY_TO_WORLD (dx);
MissilePtr->current.location.y -= VELOCITY_TO_WORLD (dy);
MissilePtr->preprocess_func = animate;
UnlockElement (MissileArray[i]);
}
}
return (3);
}