Skip to content

Commit

Permalink
Cleanup: Dumped the sideOwners lookup table
Browse files Browse the repository at this point in the history
SideDef now stores a pointer to it's owning LineDef so there is no
need to duplicate this information.
  • Loading branch information
danij-deng committed Mar 7, 2012
1 parent 929ef00 commit ed64316
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 46 deletions.
1 change: 0 additions & 1 deletion doomsday/engine/portable/include/r_util.h
Expand Up @@ -37,7 +37,6 @@ angle_t R_PointToAngle(float x, float y);
angle_t R_PointToAngle2(float x1, float y1,
float x2, float y2);
float R_PointToDist(const float x, const float y);
linedef_t* R_GetLineForSide(const uint sideIDX);

sector_t* R_GetSectorForOrigin(const void* ddMobjBase);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/cl_world.c
Expand Up @@ -842,7 +842,7 @@ void Cl_ReadSideDelta2(int deltaType, boolean skip)

if(df & SIDF_LINE_FLAGS)
{
linedef_t *line = R_GetLineForSide(num);
linedef_t* line = sid->line;
if(line)
{
// The delta includes the entire lowest byte.
Expand Down
20 changes: 0 additions & 20 deletions doomsday/engine/portable/src/r_util.c
Expand Up @@ -256,26 +256,6 @@ float R_PointToDist(const float x, const float y)
return dist;
}

linedef_t *R_GetLineForSide(const uint sideNumber)
{
uint i;
sidedef_t *side = SIDE_PTR(sideNumber);
sector_t *sector = side->sector;

// All sides may not have a sector.
if(!sector)
return NULL;

for(i = 0; i < sector->lineDefCount; ++i)
if(sector->lineDefs[i]->L_frontside == side ||
sector->lineDefs[i]->L_backside == side)
{
return sector->lineDefs[i];
}

return NULL;
}

void R_AmplifyColor(float rgb[3])
{
float max = 0;
Expand Down
36 changes: 12 additions & 24 deletions doomsday/engine/portable/src/sv_pool.c
Expand Up @@ -123,9 +123,6 @@ static float deltaBaseScores[NUM_DELTA_TYPES];
// the mobj being compared.
static dt_mobj_t dummyZeroMobj;

// Pointer to the owner line for each side.
static linedef_t** sideOwners;

// CODE --------------------------------------------------------------------

/**
Expand Down Expand Up @@ -177,29 +174,21 @@ void Sv_InitPools(void)
pools[i].isFirst = true;
}

// Find the owners of all sides.
sideOwners = Z_Malloc(sizeof(linedef_t *) * NUM_SIDEDEFS, PU_MAP, 0);
for(i = 0; i < NUM_SIDEDEFS; ++i)
{
sideOwners[i] = R_GetLineForSide(i);
}

// Store the current state of the world into both the registers.
Sv_RegisterWorld(&worldRegister, false);
Sv_RegisterWorld(&initialRegister, true);

#ifdef _DEBUG
// How much time did we spend?
Con_Message("Sv_InitPools: World registered, done in %.2f seconds.\n",
(Sys_GetRealTime() - startTime) / 1000.0f);
#endif
DEBUG_Message(("Sv_InitPools: World registered, done in %.2f seconds.\n",
(Sys_GetRealTime() - startTime) / 1000.0f));
}

/**
* Called during server shutdown (when shutting down the engine).
*/
void Sv_ShutdownPools(void)
{
// Nothing to do.
}

/**
Expand Down Expand Up @@ -479,8 +468,8 @@ void Sv_RegisterSector(dt_sector_t* reg, uint number)
*/
void Sv_RegisterSide(dt_side_t* reg, uint number)
{
sidedef_t* side = SIDE_PTR(number);
linedef_t* line = sideOwners[number];
sidedef_t* side = SIDE_PTR(number);
linedef_t* line = side->line;

reg->top.material = side->SW_topmaterial;
reg->middle.material = side->SW_middlematerial;
Expand Down Expand Up @@ -764,12 +753,12 @@ boolean Sv_RegisterCompareSector(cregister_t* reg, uint number,
boolean Sv_RegisterCompareSide(cregister_t* reg, uint number, sidedelta_t* d,
byte doUpdate)
{
const sidedef_t* s = SIDE_PTR(number);
const linedef_t* line = sideOwners[number];
dt_side_t* r = &reg->sideDefs[number];
int df = 0;
byte lineFlags = (line ? line->flags & 0xff : 0);
byte sideFlags = s->flags & 0xff;
const sidedef_t* s = SIDE_PTR(number);
const linedef_t* line = s->line;
dt_side_t* r = &reg->sideDefs[number];
byte lineFlags = (line ? line->flags & 0xff : 0);
byte sideFlags = s->flags & 0xff;
int df = 0;

if(r->top.material != s->SW_topmaterial &&
!(s->SW_topinflags & SUIF_FIX_MISSING_MATERIAL))
Expand Down Expand Up @@ -2277,8 +2266,7 @@ void Sv_NewSideDeltas(cregister_t* reg, boolean doUpdate, pool_t** targets)
for(i = start; i < end; ++i)
{
// The side must be owned by a line.
if(sideOwners[i] == NULL)
continue;
if(sideDefs[i].line == NULL) continue;

if(Sv_RegisterCompareSide(reg, i, &delta, doUpdate))
{
Expand Down

0 comments on commit ed64316

Please sign in to comment.