// Frees the flares as they expire. void animateFlares(flare **flares, short count) { LIGHTING_STATE *lights; boolean inView, fastForward, atLeastOneFlareStillActive; short i; // i iterates through the flare list #ifdef BROGUE_ASSERTS assert(rogue.RNG == RNG_SUBSTANTIVE); #endif lights = backUpLighting(); fastForward = rogue.trueColorMode || rogue.playbackFastForward; do { inView = false; atLeastOneFlareStillActive = false; for (i = 0; i < count; i++) { if (flares[i]) { if (updateFlare(flares[i])) { atLeastOneFlareStillActive = true; if (drawFlareFrame(flares[i])) { inView = true; } } else { free(flares[i]); flares[i] = NULL; } } } demoteVisibility(); updateFieldOfViewDisplay(false, true); if (!fastForward && (inView || rogue.playbackOmniscience) && atLeastOneFlareStillActive) { fastForward = pauseBrogue(10); } recordOldLights(); restoreLighting(lights); } while (atLeastOneFlareStillActive); freeLightingState(lights); updateFieldOfViewDisplay(false, true); }
void updateLighting() { short i, j, k; enum dungeonLayers layer; enum tileType tile; creature *monst; // Copy Light over oldLight recordOldLights(); // and then zero out Light. for (i = 0; i < DCOLS; i++) { for (j = 0; j < DROWS; j++) { for (k=0; k<3; k++) { tmap[i][j].light[k] = 0; } pmap[i][j].flags |= IS_IN_SHADOW; } } // Paint all glowing tiles. for (i = 0; i < DCOLS; i++) { for (j = 0; j < DROWS; j++) { for (layer = 0; layer < NUMBER_TERRAIN_LAYERS; layer++) { tile = pmap[i][j].layers[layer]; if (tileCatalog[tile].glowLight) { paintLight(&(lightCatalog[tileCatalog[tile].glowLight]), i, j, false, false); } } } } // Cycle through monsters and paint their lights: CYCLE_MONSTERS_AND_PLAYERS(monst) { if (monst->info.flags & MONST_INTRINSIC_LIGHT) { paintLight(&lightCatalog[monst->info.intrinsicLightType], monst->xLoc, monst->yLoc, false, false); } if (monst->status[STATUS_BURNING] && !(monst->info.flags & MONST_FIERY)) { paintLight(&lightCatalog[BURNING_CREATURE_LIGHT], monst->xLoc, monst->yLoc, false, false); } if (monsterRevealed(monst)) { paintLight(&lightCatalog[TELEPATHY_LIGHT], monst->xLoc, monst->yLoc, false, true); } } // Also paint telepathy lights for dormant monsters. for (monst = dormantMonsters->nextCreature; monst != NULL; monst = monst->nextCreature) { if (monsterRevealed(monst)) { paintLight(&lightCatalog[TELEPATHY_LIGHT], monst->xLoc, monst->yLoc, false, true); } } updateDisplayDetail(); // Miner's light: paintLight(&rogue.minersLight, player.xLoc, player.yLoc, true, true); if (player.status[STATUS_INVISIBLE]) { player.info.foreColor = &playerInvisibleColor; } else if (playerInDarkness()) { player.info.foreColor = &playerInDarknessColor; } else if (pmap[player.xLoc][player.yLoc].flags & IS_IN_SHADOW) { player.info.foreColor = &playerInShadowColor; } else { player.info.foreColor = &playerInLightColor; } }