本文整理汇总了C++中P_FindSectorFromTag函数的典型用法代码示例。如果您正苦于以下问题:C++ P_FindSectorFromTag函数的具体用法?C++ P_FindSectorFromTag怎么用?C++ P_FindSectorFromTag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了P_FindSectorFromTag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EV_DoFloorAndCeiling
int EV_DoFloorAndCeiling(line_t *line, byte *args, boolean raise)
{
boolean floor, ceiling;
int secnum;
sector_t *sec;
if(raise)
{
floor = EV_DoFloor(line, args, FLEV_RAISEFLOORBYVALUE);
secnum = -1;
while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0)
{
sec = §ors[secnum];
sec->specialdata = NULL;
}
ceiling = EV_DoCeiling(line, args, CLEV_RAISEBYVALUE);
}
else
{
floor = EV_DoFloor(line, args, FLEV_LOWERFLOORBYVALUE);
secnum = -1;
while ((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0)
{
sec = §ors[secnum];
sec->specialdata = NULL;
}
ceiling = EV_DoCeiling(line, args, CLEV_LOWERBYVALUE);
}
return (floor|ceiling);
}
示例2: P_RestorePlayerPosition
// restore the players position -- sector must be the same shape
void P_RestorePlayerPosition(void)
{
sector_t *sec;
int secnum;
// we always save and restore the psprites
memcpy(save_player->psprites, save_psprites, sizeof(save_player->psprites));
// restore player position from x,y offset
if(save_sectag == -1) return; // no sector relativeness
if((secnum = P_FindSectorFromTag(save_sectag, -1)) < 0)
{
// invalid: sector not found
return;
}
sec = §ors[secnum];
// restore position
P_UnsetThingPosition(save_player->mo);
save_player->mo->x = sec->soundorg.x + save_xoffset;
save_player->mo->y = sec->soundorg.y + save_yoffset;
// restore various other things
save_player->mo->angle = save_mobj.angle;
save_player->mo->momx = save_mobj.momx; // keep momentum
save_player->mo->momy = save_mobj.momy;
P_SetThingPosition(save_player->mo);
}
示例3: P_SavePlayerPosition
// save a player's position relative to a particular sector
void P_SavePlayerPosition(player_t *player, int sectag)
{
sector_t *sec;
int secnum;
save_player = player;
// save psprites whatever happens
memcpy(save_psprites, player->psprites, sizeof(player->psprites));
// save sector x,y offset
save_sectag = sectag;
if((secnum = P_FindSectorFromTag(sectag, -1)) < 0)
{
// invalid: sector not found
save_sectag = -1;
return;
}
sec = §ors[secnum];
// use soundorg x and y as 'centre' of sector
save_xoffset = player->mo->x - sec->soundorg.x;
save_yoffset = player->mo->y - sec->soundorg.y;
// save mobj so we can restore various bits of data
// haleyjd 02/04/13: not legit for C++; must replace if rehabilitated
#if 0
memcpy(&save_mobj, player->mo, sizeof(Mobj));
#endif
}
示例4: EV_LightTurnOnPartway
// killough 10/98:
//
// EV_LightTurnOnPartway()
//
// Turn sectors tagged to line lights on to specified or max neighbor level
//
// Passed the activating line's tag, and a light level fraction between
// 0 and 1. Sets the light to min on 0, max on 1, and interpolates in-
// between. Used for doors with gradual lighting effects.
//
// haleyjd 02/28/05: changed to take a tag instead of a line.
//
// Returns true
//
int EV_LightTurnOnPartway(int tag, fixed_t level)
{
int i;
if(level < 0) // clip at extremes
level = 0;
if(level > FRACUNIT)
level = FRACUNIT;
// search all sectors for ones with same tag as activating line
for(i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;)
{
sector_t *temp, *sector = sectors + i;
int j, bright = 0, min = sector->lightlevel;
for(j = 0; j < sector->linecount; ++j)
{
if((temp = getNextSector(sector->lines[j], sector)))
{
if(temp->lightlevel > bright)
bright = temp->lightlevel;
if(temp->lightlevel < min)
min = temp->lightlevel;
}
}
sector->lightlevel = // Set level in-between extremes
(level * bright + (FRACUNIT - level) * min) >> FRACBITS;
}
return 1;
}
示例5: EV_LightTurnOn
//
// TURN LINE'S TAG LIGHTS ON
// [RH] Takes a tag instead of a line
//
void EV_LightTurnOn (int tag, int bright)
{
int secnum = -1;
// [RH] Don't do a linear search
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{
sector_t *sector = sectors + secnum;
// bright = -1 means to search ([RH] Not 0)
// for highest light level
// surrounding sector
if (bright < 0)
{
int j;
bright = 0;
for (j = 0; j < sector->linecount; j++)
{
sector_t *temp = getNextSector (sector->lines[j], sector);
if (!temp)
continue;
if (temp->lightlevel > bright)
bright = temp->lightlevel;
}
}
sector->lightlevel = CLIPLIGHT(bright);
}
}
示例6: EV_DoPillar
BOOL EV_DoPillar (DPillar::EPillar type, int tag, fixed_t speed, fixed_t height,
fixed_t height2, bool crush)
{
BOOL rtn = false;
int secnum = -1;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{
sector_t *sec = §ors[secnum];
fixed_t floorheight = P_FloorHeight(sec);
fixed_t ceilingheight = P_CeilingHeight(sec);
if (sec->floordata || sec->ceilingdata)
continue;
if (type == DPillar::pillarBuild && floorheight == ceilingheight)
continue;
if (type == DPillar::pillarOpen && floorheight != ceilingheight)
continue;
rtn = true;
new DPillar (sec, type, speed, height, height2, crush);
P_AddMovingCeiling(sec);
}
return rtn;
}
示例7: EV_BuildPillar
int EV_BuildPillar(line_t *line, byte *args, boolean crush)
{
int secnum;
sector_t *sec;
pillar_t *pillar;
int newHeight;
int rtn;
rtn = 0;
secnum = -1;
while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0)
{
sec = §ors[secnum];
if(sec->specialdata)
continue; // already moving
if(sec->floorheight == sec->ceilingheight)
{ // pillar is already closed
continue;
}
rtn = 1;
if(!args[2])
{
newHeight = sec->floorheight+
((sec->ceilingheight-sec->floorheight)/2);
}
else
{
newHeight = sec->floorheight+(args[2]<<FRACBITS);
}
pillar = Z_Malloc(sizeof(*pillar), PU_LEVSPEC, 0);
sec->specialdata = pillar;
P_AddThinker(&pillar->thinker);
pillar->thinker.function = T_BuildPillar;
pillar->sector = sec;
if(!args[2])
{
pillar->ceilingSpeed = pillar->floorSpeed = args[1]*(FRACUNIT/8);
}
else if(newHeight-sec->floorheight > sec->ceilingheight-newHeight)
{
pillar->floorSpeed = args[1]*(FRACUNIT/8);
pillar->ceilingSpeed = FixedMul(sec->ceilingheight-newHeight,
FixedDiv(pillar->floorSpeed, newHeight-sec->floorheight));
}
else
{
pillar->ceilingSpeed = args[1]*(FRACUNIT/8);
pillar->floorSpeed = FixedMul(newHeight-sec->floorheight,
FixedDiv(pillar->ceilingSpeed, sec->ceilingheight-newHeight));
}
pillar->floordest = newHeight;
pillar->ceilingdest = newHeight;
pillar->direction = 1;
pillar->crush = crush*args[3];
SN_StartSequence((mobj_t *)&pillar->sector->soundorg,
SEQ_PLATFORM+pillar->sector->seqType);
}
return rtn;
}
示例8: EV_StartFloorWaggle
boolean EV_StartFloorWaggle(int tag, int height, int speed, int offset,
int timer)
{
int sectorIndex;
sector_t *sector;
floorWaggle_t *waggle;
boolean retCode;
retCode = false;
sectorIndex = -1;
while((sectorIndex = P_FindSectorFromTag(tag, sectorIndex)) >= 0)
{
sector = §ors[sectorIndex];
if(sector->specialdata)
{ // Already busy with another thinker
continue;
}
retCode = true;
waggle = Z_Malloc(sizeof(*waggle), PU_LEVSPEC, 0);
sector->specialdata = waggle;
waggle->thinker.function = T_FloorWaggle;
waggle->sector = sector;
waggle->originalHeight = sector->floorheight;
waggle->accumulator = offset*FRACUNIT;
waggle->accDelta = speed<<10;
waggle->scale = 0;
waggle->targetScale = height<<10;
waggle->scaleDelta = waggle->targetScale
/(35+((3*35)*height)/255);
waggle->ticker = timer ? timer*35 : -1;
waggle->state = WGLSTATE_EXPAND;
P_AddThinker(&waggle->thinker);
}
return retCode;
}
示例9: P_DoSectorLightChange
int P_DoSectorLightChange(line_t* line, short tag) {
int j = 0;
int ptr1 = 0;
int ptr2 = 0;
sector_t* sec1;
sector_t* sec2;
int secnum;
int rtn;
secnum = P_FindSectorFromTag(tag);
if(secnum == -1) {
return 0;
}
sec2 = §ors[secnum];
secnum = -1;
rtn = 0;
while((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) {
sec1 = §ors[secnum];
rtn = 1;
for(j = 0; j < 5; j++) {
ptr1 = (sec1->colors[j]);
ptr2 = (sec2->colors[j]);
P_UpdateLightThinker(&lights[ptr1], &lights[ptr2]);
}
}
return 1;
}
示例10: ACS_funcSectorDamage
//
// ACS_funcSectorDamage
//
static void ACS_funcSectorDamage(ACS_FUNCARG)
{
int32_t tag = args[0];
int32_t damage = args[1];
int mod = E_DamageTypeNumForName(ACSVM::GetString(args[2]));
uint32_t flags = args[4];
int secnum = -1;
sector_t *sector;
while((secnum = P_FindSectorFromTag(tag, secnum)) >= 0)
{
sector = §ors[secnum];
for(Mobj *mo = sector->thinglist; mo; mo = mo->snext)
{
if(mo->player && !(flags & SECDAM_PLAYERS))
continue;
if(!mo->player && !(flags & SECDAM_NONPLAYERS))
continue;
if(mo->z != mo->floorz && !(flags & SECDAM_IN_AIR))
continue;
P_DamageMobj(mo, NULL, NULL, damage, mod);
}
}
}
示例11: ACS_thingCountSector
//
// ACS_thingCountSector
//
static int32_t ACS_thingCountSector(int32_t tag, mobjtype_t type, int32_t tid)
{
sector_t *sector;
int count = 0;
int secnum = -1;
while((secnum = P_FindSectorFromTag(tag, secnum)) >= 0)
{
sector = §ors[secnum];
for(Mobj *mo = sector->thinglist; mo; mo = mo->snext)
{
if((type == 0 || mo->type == type) && (tid == 0 || mo->tid == tid))
{
// don't count killable things that are dead
if(((mo->flags & MF_COUNTKILL) || (mo->flags3 & MF3_KILLABLE)) &&
mo->health <= 0)
continue;
++count;
}
}
}
return count;
}
示例12: EV_StartLightFading
void EV_StartLightFading (int tag, int value, int tics)
{
int secnum;
secnum = -1;
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0)
{
sector_t *sec = §ors[secnum];
if (sec->lightingdata)
continue;
if (tics <= 0)
{
sec->SetLightLevel(value);
}
else
{
// No need to fade if lightlevel is already at desired value.
if (sec->lightlevel == value)
continue;
new DGlow2 (sec, sec->lightlevel, value, tics, true);
}
}
}
示例13: EV_LightChange
//
// [RH] New function to adjust tagged sectors' light levels
// by a relative amount. Light levels are clipped to
// within the range 0-255 inclusive.
//
void EV_LightChange (int tag, int value)
{
int secnum = -1;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) {
int newlight = sectors[secnum].lightlevel + value;
sectors[secnum].lightlevel = CLIPLIGHT(newlight);
}
}
示例14: EV_LightChange
void EV_LightChange (int tag, int value)
{
int secnum = -1;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{
sectors[secnum].SetLightLevel(sectors[secnum].lightlevel + value);
}
}
示例15: EV_GlowLight
//
// EV_GlowLight
//
// haleyjd:
// Parameterized glow effect. Uses the fading thinker, but sets it up to
// perpetually fade between two different light levels. The glow always starts
// by fading the sector toward the lower light level, whether that requires
// fading up or down.
//
int EV_GlowLight(line_t *line, int tag, int maxval, int minval, int speed)
{
int i, rtn = 0;
LightFadeThinker *lf;
bool backside = false;
// speed <= 0? hell no.
if(speed <= 0 || maxval == minval)
return rtn;
// ensure min and max have proper relationship
if(maxval < minval)
{
int temp = maxval;
maxval = minval;
minval = temp;
}
if(line && tag == 0)
{
if(!line->backsector)
return rtn;
i = line->backsector - sectors;
backside = true;
goto dobackside;
}
// search all sectors for ones with tag
for(i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;)
{
dobackside:
rtn = 1;
lf = new LightFadeThinker;
lf->addThinker();
lf->sector = §ors[i];
lf->glowmin = minval * FRACUNIT;
lf->glowmax = maxval * FRACUNIT;
lf->glowspeed = speed;
// start out fading to min level
lf->destlevel = lf->glowmin; // dest. light level
lf->lightlevel = lf->sector->lightlevel * FRACUNIT; // curr. light level
lf->step = (lf->destlevel - lf->lightlevel) / speed; // delta per frame
lf->type = fade_glow;
if(backside)
return rtn;
}
return rtn;
}