Skip to content

Commit

Permalink
Fixed XG: When processing chained events we need to allocate Dummy Si…
Browse files Browse the repository at this point in the history
…deDefs as well as LineDefs. Without these many subsequent ops will fail. Note that it is not sufficent to link the Dummy LineDef to the SideDefs of the reference LineDef, as this too may be a dummy.

Fixed XG: Sector Type functions that utilize a floor/ceiling plane height offset did not work due to an erroneous FLT2FIX conversion.
Fixed XG: Support for the lightref_current reference was completely missing.

As of this revision XG seems to be mostly working now. At least the old xgtest map is once again working. More testing needed.
  • Loading branch information
danij-deng committed Feb 11, 2011
1 parent 4c18dbe commit 4b79b7e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 40 deletions.
58 changes: 34 additions & 24 deletions doomsday/plugins/common/src/p_xgline.c
@@ -1,10 +1,10 @@
/**\file
/**\file p_xgline.c
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2007 Jamie Jones <jamie_jones_au@yahoo.com.au>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1459,7 +1459,7 @@ int C_DECL XLTrav_ChangeWallMaterial(linedef_t* line, boolean dummy,
side = P_GetPtrp(line, DMU_SIDEDEF0);
}

XG_Dev("XLTrav_ChangeWallTexture: Line %i", P_ToIndex(line));
XG_Dev("XLTrav_ChangeWallMaterial: LineDef %i", P_ToIndex(line));

rgba[0] = info->iparm[9];
rgba[1] = info->iparm[10];
Expand Down Expand Up @@ -2529,34 +2529,44 @@ int XL_HitLine(linedef_t *line, int sidenum, mobj_t *thing)
return XL_LineEvent(XLE_HIT, 0, line, sidenum, thing);
}

void XL_DoChain(linedef_t* line, int chain, boolean activating,
mobj_t* actThing)
void XL_DoChain(linedef_t* lineDef, int chain, boolean activating, mobj_t* actThing)
{
linedef_t* dummyLine;
xline_t* xdummyLine;
sidedef_t* dummyFrontSideDef, *dummyBackSideDef;
linedef_t* dummyLineDef;
xline_t* xdummyLineDef;

// We'll use a dummy line for the chain.
dummyLine = P_AllocDummyLine();
xdummyLine = P_ToXLine(dummyLine);
xdummyLine->xg = Z_Malloc(sizeof(xgline_t), PU_MAP, 0);

XG_Dev("XL_DoChain: Line %i, chained type %i", P_ToIndex(line), chain);
XG_Dev(" (dummy line will show up as %i)", P_ToIndex(dummyLine));
// We'll use dummies for the chain.
dummyLineDef = P_AllocDummyLine();
xdummyLineDef = P_ToXLine(dummyLineDef);
xdummyLineDef->xg = Z_Malloc(sizeof(xgline_t), PU_MAP, 0);
dummyFrontSideDef = P_AllocDummySideDef();
P_SetPtrp(dummyLineDef, DMU_SIDEDEF0, dummyFrontSideDef);
P_SetPtrp(dummyFrontSideDef, DMU_LINEDEF, dummyLineDef);
P_SetPtrp(dummyLineDef, DMU_FRONT_SECTOR, P_GetPtrp(lineDef, DMU_FRONT_SECTOR));
if(0 != P_GetPtrp(lineDef, DMU_SIDEDEF1))
{
dummyBackSideDef = P_AllocDummySideDef();
P_SetPtrp(dummyLineDef, DMU_SIDEDEF1, dummyBackSideDef);
P_SetPtrp(dummyBackSideDef, DMU_LINEDEF, dummyLineDef);
P_SetPtrp(dummyLineDef, DMU_BACK_SECTOR, P_GetPtrp(lineDef, DMU_BACK_SECTOR));
}

// Copy all properties to the dummy
P_CopyLine(dummyLine, line);
XG_Dev("XL_DoChain: LineDef %i, chained type %i", P_ToIndex(lineDef), chain);
XG_Dev(" (dummy linedef will show up as %i)", P_ToIndex(dummyLineDef));

P_SetPtrp(dummyLine, DMU_SIDEDEF0, NULL);
P_SetPtrp(dummyLine, DMU_SIDEDEF1, NULL);
// Copy all properties to the dummies.
P_CopyLine(dummyLineDef, lineDef);

xdummyLine->xg->active = !activating;
xdummyLineDef->xg->active = !activating;

// Make the chain event
XL_LineEvent(XLE_CHAIN, chain, dummyLine, 0, actThing);
XL_LineEvent(XLE_CHAIN, chain, dummyLineDef, 0, actThing);

// Free the dummy
Z_Free(xdummyLine->xg);
P_FreeDummyLine(dummyLine);
Z_Free(xdummyLineDef->xg);
P_FreeDummyLine(dummyLineDef);
P_FreeDummySideDef(dummyFrontSideDef);
if(dummyBackSideDef)
P_FreeDummySideDef(dummyBackSideDef);
}

/**
Expand Down
40 changes: 24 additions & 16 deletions doomsday/plugins/common/src/p_xgsec.c
@@ -1,10 +1,10 @@
/**\file
/**\file p_xgsec.c
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -230,11 +230,11 @@ void XF_Init(sector_t *sec, function_t *fn, char *func, int min, int max,
break;

case 'f':
offset += xsec->SP_floororigheight * FRACUNIT;
offset += xsec->SP_floororigheight;
break;

case 'c':
offset += xsec->SP_ceilorigheight * FRACUNIT;
offset += xsec->SP_ceilorigheight;
break;

default:
Expand Down Expand Up @@ -1988,6 +1988,10 @@ int C_DECL XSTrav_SectorLight(sector_t* sector, boolean ceiling,
lightLevel = P_ToXSector(sector)->origLight;
break;

case LIGHTREF_CURRENT:
lightLevel = P_GetFloatp(sector, DMU_LIGHT_LEVEL);
break;

case LIGHTREF_HIGHEST:
P_FindSectorSurroundingHighestLight(sector, &lightLevel);
break;
Expand Down Expand Up @@ -2605,14 +2609,15 @@ void XS_UpdateLight(sector_t* sec)
}
}

void XS_DoChain(sector_t *sec, int ch, int activating, void *act_thing)
void XS_DoChain(sector_t* sec, int ch, int activating, void* act_thing)
{
xgsector_t *xg;
sectortype_t *info;
float flevtime = TIC2FLT(mapTime);
linedef_t *dummyLine;
xline_t *xdummyLine;
linetype_t *ltype;
xgsector_t* xg;
sectortype_t* info;
float flevtime = TIC2FLT(mapTime);
linedef_t* dummyLine;
xline_t* xdummyLine;
linetype_t* ltype;
sidedef_t* dummySideDef;

xg = P_ToXSector(sec)->xg;
info = &xg->info;
Expand All @@ -2634,15 +2639,17 @@ void XS_DoChain(sector_t *sec, int ch, int activating, void *act_thing)
FLT2TIC(info->interval[ch][1]));
}

// Prepare the dummy line to use for the event.
// Prepare the dummies to use for the event.
dummyLine = P_AllocDummyLine();
xdummyLine = P_ToXLine(dummyLine);
xdummyLine->xg = Z_Calloc(sizeof(xgline_t), PU_MAP, 0);
dummySideDef = P_AllocDummySideDef();

P_SetPtrp(dummyLine, DMU_SIDEDEF0, dummySideDef);
P_SetPtrp(dummyLine, DMU_FRONT_SECTOR, sec);
P_SetPtrp(dummySideDef, DMU_LINEDEF, dummyLine);

xdummyLine->special =
(ch == XSCE_FUNCTION ? activating : info->chain[ch]);
xdummyLine->special = (ch == XSCE_FUNCTION ? activating : info->chain[ch]);

xdummyLine->tag = P_ToXSector(sec)->tag;

Expand Down Expand Up @@ -2691,9 +2698,10 @@ void XS_DoChain(sector_t *sec, int ch, int activating, void *act_thing)
}
}

// We're done, free the dummy.
// We're done, free the dummies.
Z_Free(xdummyLine->xg);
P_FreeDummyLine(dummyLine);
P_FreeDummySideDef(dummySideDef);
}

static boolean checkChainRequirements(sector_t* sec, mobj_t* mo, int ch,
Expand Down

0 comments on commit 4b79b7e

Please sign in to comment.