Skip to content

Commit

Permalink
Fixed bug in XG that prevented xlthinkers and xsthinkers from working…
Browse files Browse the repository at this point in the history
… due to uninitialized line/sector (respectively) links.

Fixed bug in XG that attempted to switch-swap a material on a line sections even if there was no material to begin with.
  • Loading branch information
danij committed Jul 24, 2008
1 parent 11b8870 commit 6543f1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
16 changes: 11 additions & 5 deletions doomsday/plugins/common/src/p_xgline.c
Expand Up @@ -646,6 +646,7 @@ void XL_SetLineType(linedef_t *line, int id)
xlthinker_t* xl = Z_Calloc(sizeof(*xl), PU_LEVSPEC, 0);

xl->thinker.function = XL_Thinker;
xl->line = line;
P_ThinkerAdd(&xl->thinker);
}
}
Expand Down Expand Up @@ -1833,13 +1834,18 @@ boolean XL_SwitchSwap(sidedef_t *side, int section)

// Which section of the wall are we checking?
if(section == LWS_UPPER)
name = R_MaterialNameForNum(P_GetIntp(side, DMU_TOP_MATERIAL));
material = P_GetIntp(side, DMU_TOP_MATERIAL);
else if(section == LWS_MID)
name = R_MaterialNameForNum(P_GetIntp(side, DMU_MIDDLE_MATERIAL));
else if(section == LWS_LOWER)
name = R_MaterialNameForNum(P_GetIntp(side, DMU_BOTTOM_MATERIAL));
material = P_GetIntp(side, DMU_MIDDLE_MATERIAL);
else
return false;
material = P_GetIntp(side, DMU_BOTTOM_MATERIAL);

if(!material)
return false; // No material on this section.

name = R_MaterialNameForNum(material);
if(!name)
return false; // Most peculiar.

strncpy(buf, name, 8);
buf[8] = 0;
Expand Down
16 changes: 4 additions & 12 deletions doomsday/plugins/common/src/p_xgsec.c
Expand Up @@ -389,6 +389,7 @@ void XS_SetSectorType(struct sector_s* sec, int special)
xsthinker_t* xs = Z_Calloc(sizeof(*xs), PU_LEVSPEC, 0);

xs->thinker.function = XS_Thinker;
xs->sector = sec;
P_ThinkerAdd(&xs->thinker);
}
}
Expand Down Expand Up @@ -2608,13 +2609,7 @@ void XS_UpdateLight(sector_t *sec)
fn = &xg->light;
if(UPDFUNC(fn))
{ // Changed.
lightlevel = fn->value / 255.f;

if(lightlevel < 0)
lightlevel = 0;
if(lightlevel > 1)
lightlevel = 1;

lightlevel = MINMAX_OF(0, fn->value / 255.f, 1);
P_SetFloatp(sec, DMU_LIGHT_LEVEL, lightlevel);
}

Expand All @@ -2626,11 +2621,8 @@ void XS_UpdateLight(sector_t *sec)
continue;

// Changed.
c = fn->value / 255.f;
if(c < 0)
c = 0;
if(c > 1)
c = 1;
c = MINMAX_OF(0, fn->value / 255.f, 1);

P_SetFloatp(sec, TO_DMU_COLOR(i), c);
}
}
Expand Down

0 comments on commit 6543f1f

Please sign in to comment.