Skip to content

Commit

Permalink
Fixed: Sky models and various map properties invalid after an engine …
Browse files Browse the repository at this point in the history
…reset
  • Loading branch information
danij-deng committed Dec 5, 2012
1 parent 6a0161d commit 374a5e3
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 38 deletions.
5 changes: 2 additions & 3 deletions doomsday/engine/src/map/dam_main.cpp
Expand Up @@ -262,7 +262,6 @@ boolean DAM_AttemptMapLoad(Uri const* _uri)
if(!dam->lastLoadAttemptFailed)
{
GameMap* map = NULL;
ded_mapinfo_t* mapInfo;

Z_FreeTags(PU_MAP, PU_PURGELEVEL - 1);

Expand All @@ -281,7 +280,6 @@ boolean DAM_AttemptMapLoad(Uri const* _uri)

if(loadedOK)
{
ded_sky_t* skyDef = NULL;
vec2d_t min, max;
uint i;

Expand Down Expand Up @@ -319,13 +317,14 @@ boolean DAM_AttemptMapLoad(Uri const* _uri)
qstrncpy(map->uniqueId, uniqueIdUtf8.constData(), sizeof(map->uniqueId));

// See what mapinfo says about this map.
mapInfo = Def_GetMapInfo(map->uri);
ded_mapinfo_t* mapInfo = Def_GetMapInfo(map->uri);
if(!mapInfo)
{
de::Uri mapUri = de::Uri("*", RC_NULL);
mapInfo = Def_GetMapInfo(reinterpret_cast<uri_s*>(&mapUri));
}

ded_sky_t* skyDef = 0;
if(mapInfo)
{
skyDef = Def_GetSky(mapInfo->skyID);
Expand Down
113 changes: 78 additions & 35 deletions doomsday/engine/src/render/r_main.c
Expand Up @@ -516,6 +516,83 @@ void R_Init(void)
frameCount = 0;
}

static void R_UpdateMap(void)
{
ded_mapinfo_t *mapInfo;
ded_sky_t* skyDef;
uint i;

if(!theMap) return;

// Update all world surfaces.
for(i = 0; i < NUM_SECTORS; ++i)
{
Sector* sec = &sectors[i];
uint j;
for(j = 0; j < sec->planeCount; ++j)
{
Surface_Update(&sec->SP_planesurface(j));
}
}

for(i = 0; i < NUM_SIDEDEFS; ++i)
{
SideDef* side = &sideDefs[i];
Surface_Update(&side->SW_topsurface);
Surface_Update(&side->SW_middlesurface);
Surface_Update(&side->SW_bottomsurface);
}

for(i = 0; i < NUM_POLYOBJS; ++i)
{
Polyobj* po = polyObjs[i];
LineDef** lineIter;
for(lineIter = po->lines; *lineIter; lineIter++)
{
LineDef* line = *lineIter;
SideDef* side = line->L_frontsidedef;
Surface_Update(&side->SW_middlesurface);
}
}

R_MapInitSurfaceLists();

// See what mapinfo says about this map.
mapInfo = Def_GetMapInfo(GameMap_Uri(theMap));
if(!mapInfo)
{
Uri *mapUri = Uri_NewWithPath2("*", RC_NULL);
mapInfo = Def_GetMapInfo(mapUri);
Uri_Delete(mapUri);
}

// Reconfigure the sky
skyDef = 0;
if(mapInfo)
{
skyDef = Def_GetSky(mapInfo->skyID);
if(!skyDef) skyDef = &mapInfo->sky;
}
Sky_Configure(skyDef);

if(mapInfo)
{
theMap->globalGravity = mapInfo->gravity;
theMap->ambientLightLevel = mapInfo->ambient * 255;
}
else
{
// No theMap info found, so set some basic stuff.
theMap->globalGravity = 1.0f;
theMap->ambientLightLevel = 0;
}

theMap->effectiveGravity = theMap->globalGravity;

// Recalculate the light range mod matrix.
Rend_CalcLightModRange();
}

/**
* Re-initialize almost everything.
*/
Expand Down Expand Up @@ -547,41 +624,7 @@ void R_Update(void)
ddpl->pSprites[0].statePtr = ddpl->pSprites[1].statePtr = NULL;
}}

if(theMap)
{
uint i;

// Update all world surfaces.
for(i = 0; i < NUM_SECTORS; ++i)
{
Sector* sec = &sectors[i];
uint j;
for(j = 0; j < sec->planeCount; ++j)
Surface_Update(&sec->SP_planesurface(j));
}

for(i = 0; i < NUM_SIDEDEFS; ++i)
{
SideDef* side = &sideDefs[i];
Surface_Update(&side->SW_topsurface);
Surface_Update(&side->SW_middlesurface);
Surface_Update(&side->SW_bottomsurface);
}

for(i = 0; i < NUM_POLYOBJS; ++i)
{
Polyobj* po = polyObjs[i];
LineDef** lineIter;
for(lineIter = po->lines; *lineIter; lineIter++)
{
LineDef* line = *lineIter;
SideDef* side = line->L_frontsidedef;
Surface_Update(&side->SW_middlesurface);
}
}

R_MapInitSurfaceLists();
}
R_UpdateMap();

// The rendering lists have persistent data that has changed during
// the re-initialization.
Expand Down

0 comments on commit 374a5e3

Please sign in to comment.