Skip to content

Commit

Permalink
Fixed problem of light sequences not working in jHexen.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij committed Oct 28, 2008
1 parent eb0cf66 commit d28a095
Showing 1 changed file with 84 additions and 52 deletions.
136 changes: 84 additions & 52 deletions doomsday/plugins/jhexen/src/p_lights.c
Expand Up @@ -285,72 +285,104 @@ void P_SpawnPhasedLight(sector_t *sector, float base, int index)
P_ToXSector(sector)->special = 0;
}

void P_SpawnLightSequence(sector_t *sector, int indexStep)
typedef struct {
int seqSpecial, count;
sector_t* sec, *nextSec;
} findlightsequencesectorparams_t;

static int findLightSequenceSector(void* p, void* context)
{
#if 0
int i, seqSpecial, count;
float base;
fixed_t index, indexDelta;
sector_t *sec, *nextSec, *tempSec;

seqSpecial = LIGHT_SEQUENCE; // Look for Light_Sequence, first.
sec = sector;
count = 1;
do
linedef_t* li = (linedef_t*) p;
findlightsequencesectorparams_t* params =
(findlightsequencesectorparams_t*) context;
sector_t* tempSec = P_GetNextSector(li, params->sec);

if(tempSec)
{
nextSec = NULL;
// make sure that the search doesn't back up.
P_ToXSector(sec)->special = LIGHT_SEQUENCE_START;
for(i = 0; i < P_GetIntp(sec, DMU_LINEDEF_COUNT); ++i)
if(P_ToXSector(tempSec)->special == params->seqSpecial)
{
tempSec = P_GetNextSector(P_GetPtrp(sec, DMU_LINEDEF_OF_SECTOR | i), sec);
if(!tempSec)
continue;
if(params->seqSpecial == LIGHT_SEQUENCE)
params->seqSpecial = LIGHT_SEQUENCE_ALT;
else
params->seqSpecial = LIGHT_SEQUENCE;

if(P_ToXSector(tempSec)->special == seqSpecial)
{
if(seqSpecial == LIGHT_SEQUENCE)
{
seqSpecial = LIGHT_SEQUENCE_ALT;
}
else
{
seqSpecial = LIGHT_SEQUENCE;
}
nextSec = tempSec;
count++;
}
params->nextSec = tempSec;
params->count++;
}
sec = nextSec;
} while(sec);
}

return 1; // Continue iteration.
}

typedef struct {
sector_t* sec, *nextSec;
} findlightsequencestartsectorparams_t;

static int findLightSequenceStartSector(void* p, void* context)
{
linedef_t* li = (linedef_t*) p;
findlightsequencestartsectorparams_t* params =
(findlightsequencestartsectorparams_t*) context;
sector_t* tempSec = P_GetNextSector(li, params->sec);

if(tempSec)
{
if(P_ToXSector(tempSec)->special == LIGHT_SEQUENCE_START)
{
params->nextSec = tempSec;
}
}

return 1; // Continue iteration.
}

sec = sector;
void P_SpawnLightSequence(sector_t* sector, int indexStep)
{
int count;

{
findlightsequencesectorparams_t params;

params.seqSpecial = LIGHT_SEQUENCE; // Look for Light_Sequence, first.
params.count = 1;
params.sec = sector;
do
{
// Make sure that the search doesn't back up.
P_ToXSector(params.sec)->special = LIGHT_SEQUENCE_START;

params.nextSec = NULL;
P_Iteratep(params.sec, DMU_LINEDEF, &params,
findLightSequenceSector);
params.sec = params.nextSec;
} while(params.sec);

count = params.count;
}

{
findlightsequencestartsectorparams_t params;
float base;
fixed_t index, indexDelta;

params.sec = sector;
count *= indexStep;
index = 0;
indexDelta = FixedDiv(64 * FRACUNIT, count * FRACUNIT);
base = P_SectorLight(sector);
do
{
nextSec = NULL;
if(P_SectorLight(sec))
if(P_SectorLight(params.sec))
{
base = P_SectorLight(sec);
base = P_SectorLight(params.sec);
}
P_SpawnPhasedLight(sec, base, index >> FRACBITS);
P_SpawnPhasedLight(params.sec, base, index >> FRACBITS);
index += indexDelta;

for(i = 0; i < P_GetIntp(sec, DMU_LINEDEF_COUNT); ++i)
{
tempSec = P_GetNextSector(P_GetPtrp(sec, DMU_LINEDEF_OF_SECTOR | i), sec);
if(!tempSec)
continue;

if(P_ToXSector(tempSec)->special == LIGHT_SEQUENCE_START)
{
nextSec = tempSec;
}
}
sec = nextSec;
} while(sec);
#endif
params.nextSec = NULL;
P_Iteratep(params.sec, DMU_LINEDEF, &params,
findLightSequenceStartSector);
params.sec = params.nextSec;
} while(params.sec);
}
}

0 comments on commit d28a095

Please sign in to comment.