Use range_for on Dl_indices
This commit is contained in:
parent
1649fc791c
commit
80bbc9c69c
|
@ -352,9 +352,9 @@ struct dl_index {
|
|||
|
||||
#define DL_SCALE 2048 // Divide light to allow 3 bits integer, 5 bits fraction.
|
||||
|
||||
extern dl_index Dl_indices[MAX_DL_INDICES];
|
||||
extern array<dl_index, MAX_DL_INDICES> Dl_indices;
|
||||
extern delta_light Delta_lights[MAX_DELTA_LIGHTS];
|
||||
extern int Num_static_lights;
|
||||
extern unsigned Num_static_lights;
|
||||
|
||||
int subtract_light(segnum_t segnum, int sidenum);
|
||||
int add_light(segnum_t segnum, int sidenum);
|
||||
|
|
|
@ -995,11 +995,15 @@ static int load_game_data(PHYSFS_file *LoadFile)
|
|||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
//================ READ DL_INDICES INFO ===============
|
||||
|
||||
for (int i = 0; i < Num_static_lights; i++) {
|
||||
if (game_top_fileinfo_version < 29) {
|
||||
Int3(); //shouldn't be here!!!
|
||||
} else
|
||||
dl_index_read(&Dl_indices[i], LoadFile);
|
||||
if (game_top_fileinfo_version < 29)
|
||||
{
|
||||
if (Num_static_lights)
|
||||
throw std::logic_error("Static lights in old file");
|
||||
}
|
||||
else
|
||||
{
|
||||
range_for (auto &i, partial_range(Dl_indices, Num_static_lights))
|
||||
dl_index_read(&i, LoadFile);
|
||||
}
|
||||
|
||||
// Indicate that no light has been subtracted from any vertices.
|
||||
|
@ -1511,11 +1515,8 @@ int Errors_in_mine;
|
|||
static int compute_num_delta_light_records(void)
|
||||
{
|
||||
int total = 0;
|
||||
|
||||
for (int i=0; i<Num_static_lights; i++) {
|
||||
total += Dl_indices[i].count;
|
||||
}
|
||||
|
||||
range_for (auto &i, partial_range(Dl_indices, Num_static_lights))
|
||||
total += i.count;
|
||||
return total;
|
||||
|
||||
}
|
||||
|
@ -1623,8 +1624,8 @@ static int save_game_data(PHYSFS_file *SaveFile)
|
|||
if (game_top_fileinfo_version >= 29)
|
||||
{
|
||||
dl_indices_offset = PHYSFS_tell(SaveFile);
|
||||
for (int i = 0; i < Num_static_lights; i++)
|
||||
dl_index_write(&Dl_indices[i], SaveFile);
|
||||
range_for (auto &i, partial_range(Dl_indices, Num_static_lights))
|
||||
dl_index_write(&i, SaveFile);
|
||||
|
||||
delta_light_offset = PHYSFS_tell(SaveFile);
|
||||
for (int i = 0; i < num_delta_lights; i++)
|
||||
|
|
|
@ -49,6 +49,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#endif
|
||||
|
||||
#include "compiler-range_for.h"
|
||||
#include "partial_range.h"
|
||||
#include "highest_valid.h"
|
||||
|
||||
using std::min;
|
||||
|
@ -57,9 +58,9 @@ using std::min;
|
|||
#define PLANE_DIST_TOLERANCE 250
|
||||
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
dl_index Dl_indices[MAX_DL_INDICES];
|
||||
array<dl_index, MAX_DL_INDICES> Dl_indices;
|
||||
delta_light Delta_lights[MAX_DELTA_LIGHTS];
|
||||
int Num_static_lights;
|
||||
unsigned Num_static_lights;
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
@ -1687,12 +1688,11 @@ static void change_segment_light(segnum_t segnum,int sidenum,int dir)
|
|||
// dir = 0 -> you are dumb
|
||||
static void change_light(segnum_t segnum, int sidenum, int dir)
|
||||
{
|
||||
for (int i=0; i<Num_static_lights; i++) {
|
||||
if ((Dl_indices[i].segnum == segnum) && (Dl_indices[i].sidenum == sidenum)) {
|
||||
delta_light *dlp;
|
||||
dlp = &Delta_lights[Dl_indices[i].index];
|
||||
|
||||
for (int j=0; j<Dl_indices[i].count; j++) {
|
||||
range_for (auto &i, partial_range(Dl_indices, Num_static_lights))
|
||||
if (i.segnum == segnum && i.sidenum == sidenum)
|
||||
{
|
||||
auto dlp = &Delta_lights[i.index];
|
||||
for (int j=0; j < i.count; j++) {
|
||||
for (int k=0; k<4; k++) {
|
||||
fix dl,new_l;
|
||||
dl = dir * dlp->vert_light[k] * DL_SCALE;
|
||||
|
@ -1705,7 +1705,6 @@ static void change_light(segnum_t segnum, int sidenum, int dir)
|
|||
dlp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//recompute static light for segment
|
||||
change_segment_light(segnum,sidenum,dir);
|
||||
|
|
Loading…
Reference in a new issue