示例#1
0
int findNextPlaneHeight(void* ptr, void* context)
{
    findnextplaneheightparams_t* params = (findnextplaneheightparams_t*) context;
    Sector* other = P_GetNextSector((Line*) ptr, params->baseSec);
    coord_t otherHeight;

    if(!other)
        return false; // Continue iteration.

    otherHeight = P_GetDoublep(other, ((params->flags & FNPHF_FLOOR)? DMU_FLOOR_HEIGHT : DMU_CEILING_HEIGHT));
    if(params->flags & FNPHF_ABOVE)
    {
        if(otherHeight < params->val && otherHeight > params->baseHeight)
        {
            params->val = otherHeight;
            params->foundSec = other;
        }
    }
    else if(otherHeight > params->val && otherHeight < params->baseHeight)
    {
        params->val = otherHeight;
        params->foundSec = other;
    }
    return false; // Continue iteration.
}
示例#2
0
int findNextLightLevel(void* ptr, void* context)
{
    findnextlightlevelparams_t *params = (findnextlightlevelparams_t*) context;
    Line* li = (Line*) ptr;
    Sector* other = P_GetNextSector(li, params->baseSec);
    float otherLight;

    if(!other)
        return false; // Continue iteration.

    otherLight = P_GetFloatp(other, DMU_LIGHT_LEVEL);
    if(params->flags & FNLLF_ABOVE)
    {
        if(otherLight < params->val && otherLight > params->baseLight)
        {
            params->val = otherLight;
            params->foundSec = other;

            if(!(params->val > 0))
                return true; // Stop iteration. Can't get any darker.
        }
    }
    else if(otherLight > params->val && otherLight < params->baseLight)
    {
        params->val = otherLight;
        params->foundSec = other;

        if(!(params->val < 1))
            return true; // Stop iteration. Can't get any brighter.
    }
    return false; // Continue iteration.
}
示例#3
0
int findExtremalPlaneHeight(void* ptr, void* context)
{
    findextremalplaneheightparams_t* params = (findextremalplaneheightparams_t*) context;
    Sector* other = P_GetNextSector((Line*) ptr, params->baseSec);
    coord_t height;

    if(!other)
        return false; // Continue iteration.

    height = P_GetDoublep(other, ((params->flags & FEPHF_FLOOR)? DMU_FLOOR_HEIGHT : DMU_CEILING_HEIGHT));
    if(params->flags & FEPHF_MIN)
    {
        if(height < params->val)
        {
            params->val = height;
            params->foundSec = other;
        }
    }
    else if(height > params->val)
    {
        params->val = height;
        params->foundSec = other;
    }

    return false; // Continue iteration.
}
示例#4
0
int findExtremalLightLevelInAdjacentSectors(void* ptr, void* context)
{
    findlightlevelparams_t* params = (findlightlevelparams_t*) context;
    Sector* other = P_GetNextSector((Line*) ptr, params->baseSec);
    float lightLevel;

    if(!other)
        return false; // Continue iteration.

    lightLevel = P_GetFloatp(other, DMU_LIGHT_LEVEL);
    if(params->flags & FELLF_MIN)
    {
        if(lightLevel < params->val)
        {
            params->val = lightLevel;
            params->foundSec = other;
            if(params->val <= 0)
                return true; // Stop iteration. Can't get any darker.
        }
    }
    else if(lightLevel > params->val)
    {
        params->val = lightLevel;
        params->foundSec = other;
        if(params->val >= 1)
            return true; // Stop iteration. Can't get any brighter.
    }
    return false; // Continue iteration.
}
示例#5
0
void EV_TurnTagLightsOff(linedef_t *line)
{
    int         j;
    float       min;
    float       lightlevel;
    sector_t   *sec = NULL, *tsec;
    linedef_t     *other;
    iterlist_t *list;

    list = P_GetSectorIterListForTag(P_ToXLine(line)->tag, false);
    if(!list)
        return;

    P_IterListResetIterator(list, true);
    while((sec = P_IterListIterator(list)) != NULL)
    {
        min = P_GetFloatp(sec, DMU_LIGHT_LEVEL);
        for(j = 0; j < P_GetIntp(sec, DMU_LINEDEF_COUNT); ++j)
        {
            other = P_GetPtrp(sec, DMU_LINEDEF_OF_SECTOR | j);
            tsec = P_GetNextSector(other, sec);

            if(!tsec)
                continue;

            lightlevel = P_GetFloatp(tsec, DMU_LIGHT_LEVEL);

            if(lightlevel < min)
                min = lightlevel;
        }

        P_SetFloatp(sec, DMU_LIGHT_LEVEL, min);
    }
}
示例#6
0
static int findLightSequenceStartSector(void *p, void *context)
{
    Line *li = (Line *) p;
    findlightsequencestartsectorparams_t *params = (findlightsequencestartsectorparams_t *) context;

    if(Sector *sector = P_GetNextSector(li, params->sec))
    {
        if(P_ToXSector(sector)->special == LIGHT_SEQUENCE_START)
        {
            params->nextSec = sector;
        }
    }

    return false; // Continue iteration.
}
示例#7
0
static int findLightSequenceSector(void *p, void *context)
{
    Line *li = (Line *) p;
    findlightsequencesectorparams_t *params = (findlightsequencesectorparams_t *) context;
    Sector *tempSec = P_GetNextSector(li, params->sec);

    if(tempSec)
    {
        if(P_ToXSector(tempSec)->special == params->seqSpecial)
        {
            if(params->seqSpecial == LIGHT_SEQUENCE)
                params->seqSpecial = LIGHT_SEQUENCE_ALT;
            else
                params->seqSpecial = LIGHT_SEQUENCE;

            params->nextSec = tempSec;
            params->count++;
        }
    }

    return false; // Continue iteration.
}
示例#8
0
void EV_LightTurnOn(linedef_t *line, float max)
{
    int         j;
    float       lightlevel;
    sector_t   *sec = NULL, *tsec;
    linedef_t     *tline;
    iterlist_t *list;

    list = P_GetSectorIterListForTag(P_ToXLine(line)->tag, false);
    if(!list)
        return;

    P_IterListResetIterator(list, true);
    while((sec = P_IterListIterator(list)) != NULL)
    {
        // max = 0 means to search
        // for highest light level
        // surrounding sector
        if(!max)
        {
            for(j = 0; j < P_GetIntp(sec, DMU_LINEDEF_COUNT); ++j)
            {
                tline = P_GetPtrp(sec, DMU_LINEDEF_OF_SECTOR | j);
                tsec = P_GetNextSector(tline, sec);

                if(!tsec)
                    continue;

                lightlevel = P_GetFloatp(tsec, DMU_LIGHT_LEVEL);

                if(lightlevel > max)
                    max = lightlevel;
            }
        }
        P_SetFloatp(sec, DMU_LIGHT_LEVEL, max);
    }
}